aboutsummaryrefslogtreecommitdiff
path: root/src/components/SpanCopyable.vue
diff options
context:
space:
mode:
authorGravatar cgoIT <carsten.goetzinger@concedro.com> 2023-04-19 20:30:45 +0200
committerGravatar GitHub <noreply@github.com> 2023-04-19 20:30:45 +0200
commitdf989e24b3937876f094301e33762677d604888a (patch)
tree672ea49abff8e3b1a33fcb41bdfbeade0227ee0f /src/components/SpanCopyable.vue
parent6d2202597c269925422af02a862c64d1b0548093 (diff)
downloadit-tools-df989e24b3937876f094301e33762677d604888a.tar.gz
it-tools-df989e24b3937876f094301e33762677d604888a.tar.zst
it-tools-df989e24b3937876f094301e33762677d604888a.zip
feat(ipv4-range-expander): expands a given IPv4 start and end address to a valid IPv4 subnet (#366)
* feat(ipv4-range-expander): expands a given IPv4 start and end address to a valid IPv4 subnet * feat(ipv4-range-expander): remove old component copyable-ip-like.vue * feat(ipv4-range-expander): fix sonar findings * feat(ipv4-range-expander): changes due to review * feat(ipv4-range-expander): only show n-alert if both ipv4 addresses are valid
Diffstat (limited to 'src/components/SpanCopyable.vue')
-rw-r--r--src/components/SpanCopyable.vue35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/components/SpanCopyable.vue b/src/components/SpanCopyable.vue
new file mode 100644
index 0000000..caac35d
--- /dev/null
+++ b/src/components/SpanCopyable.vue
@@ -0,0 +1,35 @@
+<template>
+ <n-tooltip trigger="hover">
+ <template #trigger>
+ <span class="value" @click="handleClick">{{ value }}</span>
+ </template>
+ {{ tooltipText }}
+ </n-tooltip>
+</template>
+
+<script setup lang="ts">
+import { useClipboard } from '@vueuse/core';
+import { ref, toRefs } from 'vue';
+
+const props = withDefaults(defineProps<{ value?: string }>(), { value: '' });
+const { value } = toRefs(props);
+
+const initialText = 'Copy to clipboard';
+const tooltipText = ref(initialText);
+
+const { copy } = useClipboard({ source: value });
+
+function handleClick() {
+ copy();
+ tooltipText.value = 'Copied!';
+
+ setTimeout(() => (tooltipText.value = initialText), 1000);
+}
+</script>
+
+<style scoped lang="less">
+.value {
+ cursor: pointer;
+ font-family: monospace;
+}
+</style>