Show feedback when code is copied
This commit is contained in:
parent
5d81440577
commit
8563199bfa
1 changed files with 5 additions and 3 deletions
|
@ -1,12 +1,14 @@
|
||||||
<script>
|
<script>
|
||||||
let slot
|
let slot
|
||||||
function copy_code() {
|
let copied = false
|
||||||
navigator.clipboard.writeText(slot?.innerText)
|
async function copy_code() {
|
||||||
|
await navigator.clipboard.writeText(slot?.innerText)
|
||||||
|
copied = true
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
<button on:click={copy_code}>Copy code</button>
|
<button on:click={copy_code}>Copy code</button> {#if copied}<span style="display: inline">Copied!</span>{/if}
|
||||||
<span bind:this={slot}><slot></slot></span>
|
<span bind:this={slot}><slot></slot></span>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue