2024-06-05 10:15:29 -07:00

20 lines
473 B
Svelte

<script lang="ts">
import Clipboard from '$components/Clipboard.svelte'
import TinyButton from './helpers/TinyButton.svelte'
let isCopied = false
export let code: string
export let copy: () => void
const handleCopy = () => {
isCopied = true
copy()
}
</script>
<Clipboard text={code} let:copy on:copy={handleCopy}>
<TinyButton click={copy} style={isCopied ? 'success' : 'primary'}
>{isCopied ? 'Copied!' : 'Copy'}</TinyButton
>
</Clipboard>