Last active
August 20, 2025 01:50
-
-
Save mariocesar/946b8b3850ed49a4acb7b0c0bcb1735d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| import { onMount } from "svelte"; | |
| let wrapper; | |
| let copied = false; | |
| async function copyText() { | |
| const text = wrapper.innerText.trim(); | |
| try { | |
| await navigator.clipboard.writeText(text); | |
| copied = true; | |
| setTimeout(() => (copied = false), 1500); | |
| } catch (err) { | |
| console.error("No se pudo copiar:", err); | |
| } | |
| } | |
| </script> | |
| <div bind:this={wrapper} style="display: inline-flex; align-items: center; gap: 0.25rem;"> | |
| <slot></slot> | |
| <button | |
| on:click={copyText} | |
| style="background: none; border: none; cursor: pointer; font-size: 1rem;" | |
| aria-label="Copiar al portapapeles" | |
| > | |
| 📋 | |
| </button> | |
| {#if copied} | |
| <span style="font-size: 0.8rem; color: green;">copiado!</span> | |
| {/if} | |
| </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment