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>
|
||||
let slot
|
||||
function copy_code() {
|
||||
navigator.clipboard.writeText(slot?.innerText)
|
||||
let copied = false
|
||||
async function copy_code() {
|
||||
await navigator.clipboard.writeText(slot?.innerText)
|
||||
copied = true
|
||||
}
|
||||
</script>
|
||||
|
||||
<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>
|
||||
</pre>
|
||||
|
||||
|
|
Loading…
Reference in a new issue