Add Prettier and ESLint tooling (Refs #77)
This commit is contained in:
@@ -2,12 +2,41 @@
|
||||
import Button from './primitives/Button.svelte';
|
||||
let { value, label = 'ID' }: { value: string; label?: string } = $props();
|
||||
let copyStatus = $state('');
|
||||
$effect(() => { value; copyStatus = ''; });
|
||||
$effect(() => {
|
||||
void value;
|
||||
copyStatus = '';
|
||||
});
|
||||
async function copy() {
|
||||
copyStatus = '';
|
||||
try { await navigator.clipboard.writeText(value); copyStatus = `${label} copied.`; }
|
||||
catch { copyStatus = 'Copy unavailable. Select and copy the text directly.'; }
|
||||
try {
|
||||
await navigator.clipboard.writeText(value);
|
||||
copyStatus = `${label} copied.`;
|
||||
} catch {
|
||||
copyStatus = 'Copy unavailable. Select and copy the text directly.';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<div class="copy"><code>{value}</code><Button variant="ghost" size="sm" ariaLabel={`Copy ${label}`} onclick={copy}>Copy</Button>{#if copyStatus}<span class="copy-status" role="status">{copyStatus}</span>{/if}</div>
|
||||
<style>.copy-status { font-size: var(--text-xs); } .copy { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); color: var(--text-secondary); } code { font: var(--text-xs) var(--font-mono); user-select: all; overflow-wrap: anywhere; }</style>
|
||||
|
||||
<div class="copy">
|
||||
<code>{value}</code><Button variant="ghost" size="sm" ariaLabel={`Copy ${label}`} onclick={copy}
|
||||
>Copy</Button
|
||||
>{#if copyStatus}<span class="copy-status" role="status">{copyStatus}</span>{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.copy-status {
|
||||
font-size: var(--text-xs);
|
||||
}
|
||||
.copy {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-2);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
code {
|
||||
font: var(--text-xs) var(--font-mono);
|
||||
user-select: all;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user