aboutsummaryrefslogtreecommitdiff
path: root/src/ui/c-text-copyable/c-text-copyable.vue
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/c-text-copyable/c-text-copyable.vue')
-rw-r--r--src/ui/c-text-copyable/c-text-copyable.vue17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/ui/c-text-copyable/c-text-copyable.vue b/src/ui/c-text-copyable/c-text-copyable.vue
new file mode 100644
index 0000000..b78e4cd
--- /dev/null
+++ b/src/ui/c-text-copyable/c-text-copyable.vue
@@ -0,0 +1,17 @@
+<script setup lang="ts">
+import { useCopy } from '@/composable/copy';
+
+const props = withDefaults(defineProps<{ value?: string; displayedValue?: string; showIcon?: boolean }>(), { value: '', displayedValue: undefined, showIcon: true });
+const { value, displayedValue, showIcon } = toRefs(props);
+
+const { copy, isJustCopied } = useCopy({ source: value, createToast: false });
+</script>
+
+<template>
+ <c-tooltip :tooltip="isJustCopied ? 'Copied!' : 'Copy to clipboard'" cursor-pointer @click="copy">
+ <span flex items-center gap-2>
+ {{ displayedValue ?? value }}
+ <icon-mdi-content-copy v-if="showIcon" op-40 />
+ </span>
+ </c-tooltip>
+</template>