aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Copy.svelte15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/Copy.svelte b/src/lib/Copy.svelte
new file mode 100644
index 0000000..0d8518e
--- /dev/null
+++ b/src/lib/Copy.svelte
@@ -0,0 +1,15 @@
+<script>
+ let { text = $bindable() } = $props();
+ let justCopied = $state();
+ const copy = () => {
+ navigator.clipboard.writeText(text);
+ justCopied = true;
+ setTimeout(() => (justCopied = false), 1000);
+ };
+</script>
+
+<div data-tip="Copied!" class:tooltip={justCopied}>
+ <button type="button" class="btn" onclick={copy}>
+ <iconify-icon icon="ph:copy-bold" width={32} />
+ </button>
+</div>