Download 6.0.0-dev.4/code/shared/Copy.svelte from gradio/frontend: direct link, hf CLI and curl.
- Browser
- Download file 666 Bytes
-
https://huggingface.co/datasets/gradio/frontend/resolve/refs%2Fpr%2F1/6.0.0-dev.4/code/shared/Copy.svelte
- Command line
-
hf download hf://datasets/gradio/frontend@refs/pr/1/6.0.0-dev.4/code/shared/Copy.svelte
-
curl -L -o Copy.svelte https://huggingface.co/datasets/gradio/frontend/resolve/refs%2Fpr%2F1/6.0.0-dev.4/code/shared/Copy.svelte
666 Bytes
| <script lang="ts"> | |
| import { onDestroy } from "svelte"; | |
| import { Copy, Check } from "@gradio/icons"; | |
| import { IconButton } from "@gradio/atoms"; | |
| let copied = false; | |
| export let value: string; | |
| let timer: NodeJS.Timeout; | |
| function copy_feedback(): void { | |
| copied = true; | |
| if (timer) clearTimeout(timer); | |
| timer = setTimeout(() => { | |
| copied = false; | |
| }, 2000); | |
| } | |
| async function handle_copy(): Promise<void> { | |
| if ("clipboard" in navigator) { | |
| await navigator.clipboard.writeText(value); | |
| copy_feedback(); | |
| } | |
| } | |
| onDestroy(() => { | |
| if (timer) clearTimeout(timer); | |
| }); | |
| </script> | |
| <IconButton Icon={copied ? Check : Copy} on:click={handle_copy} /> | |