mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-20 14:56:17 -04:00
27 lines
681 B
Vue
27 lines
681 B
Vue
<script setup lang="ts">
|
|
import { useCopy } from '@/composable/copy';
|
|
|
|
const props = withDefaults(defineProps<{ value?: string }>(), { value: '' });
|
|
const { value } = toRefs(props);
|
|
|
|
const initialText = 'Copy to clipboard';
|
|
|
|
const { copy, isJustCopied } = useCopy({ source: value, createToast: false });
|
|
const tooltipText = computed(() => isJustCopied.value ? 'Copied!' : initialText);
|
|
</script>
|
|
|
|
<template>
|
|
<n-tooltip trigger="hover">
|
|
<template #trigger>
|
|
<span class="value" @click="copy()">{{ value }}</span>
|
|
</template>
|
|
{{ tooltipText }}
|
|
</n-tooltip>
|
|
</template>
|
|
|
|
<style scoped lang="less">
|
|
.value {
|
|
cursor: pointer;
|
|
font-family: monospace;
|
|
}
|
|
</style>
|