2022-10-07 02:54:09 +00:00
|
|
|
<template>
|
2023-01-22 06:15:23 +00:00
|
|
|
<button class="" @click="copyText">
|
2022-10-07 02:54:09 +00:00
|
|
|
<label
|
|
|
|
class="swap swap-rotate"
|
|
|
|
:class="{
|
|
|
|
'swap-active': copied,
|
|
|
|
}"
|
|
|
|
>
|
2023-01-22 06:15:23 +00:00
|
|
|
<Icon
|
|
|
|
class="swap-off"
|
|
|
|
name="mdi-content-copy"
|
|
|
|
:style="{
|
|
|
|
height: `${iconSize}px`,
|
|
|
|
width: `${iconSize}px`,
|
|
|
|
}"
|
|
|
|
/>
|
|
|
|
<Icon
|
|
|
|
class="swap-on"
|
|
|
|
name="mdi-clipboard"
|
|
|
|
:style="{
|
|
|
|
height: `${iconSize}px`,
|
|
|
|
width: `${iconSize}px`,
|
|
|
|
}"
|
|
|
|
/>
|
2022-10-07 02:54:09 +00:00
|
|
|
</label>
|
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
const props = defineProps({
|
|
|
|
text: {
|
|
|
|
type: String as () => string,
|
|
|
|
default: "",
|
|
|
|
},
|
2023-01-22 06:15:23 +00:00
|
|
|
iconSize: {
|
|
|
|
type: Number as () => number,
|
|
|
|
default: 20,
|
|
|
|
},
|
2022-10-07 02:54:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const copied = ref(false);
|
|
|
|
|
|
|
|
const { copy } = useClipboard();
|
|
|
|
|
|
|
|
function copyText() {
|
|
|
|
copy(props.text);
|
|
|
|
copied.value = true;
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
copied.value = false;
|
|
|
|
}, 1000);
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped></style>
|