aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/Copy.svelte
blob: 0d8518ecd028d5c8a4e3952200f2118fbe37fe9f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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>