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,
|
|
|
|
}"
|
|
|
|
>
|
2024-03-01 01:20:18 +00:00
|
|
|
<MdiContentCopy
|
2023-01-22 06:15:23 +00:00
|
|
|
class="swap-off"
|
|
|
|
:style="{
|
|
|
|
height: `${iconSize}px`,
|
|
|
|
width: `${iconSize}px`,
|
|
|
|
}"
|
|
|
|
/>
|
2024-03-01 01:20:18 +00:00
|
|
|
<MdiClipboard
|
2023-01-22 06:15:23 +00:00
|
|
|
class="swap-on"
|
|
|
|
:style="{
|
|
|
|
height: `${iconSize}px`,
|
|
|
|
width: `${iconSize}px`,
|
|
|
|
}"
|
|
|
|
/>
|
2022-10-07 02:54:09 +00:00
|
|
|
</label>
|
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2024-03-01 01:20:18 +00:00
|
|
|
import MdiContentCopy from "~icons/mdi/content-copy";
|
|
|
|
import MdiClipboard from "~icons/mdi/clipboard";
|
|
|
|
|
2022-10-07 02:54:09 +00:00
|
|
|
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>
|