chore: publish current DataStack updates
Publish the current application, design, and Phase 1 deployment updates. Excludes ignored personal notes, local MCP config, and generated TypeScript build info.
This commit is contained in:
1 parent
d39d9f92f9
commit
fcc4f4db2d
88 files changed
+21248
-2213
No files matched your search
@@ -0,0 +1,49 @@
|
||||
'use client';
|
||||
|
||||
import { Check, Copy } from 'lucide-react';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
|
||||
type CopyState = 'idle' | 'copied' | 'failed';
|
||||
|
||||
export function CopyButton({ value }: { value: string }) {
|
||||
const [state, setState] = useState<CopyState>('idle');
|
||||
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
useEffect(() => () => {
|
||||
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
||||
}, []);
|
||||
|
||||
const copyValue = async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(value);
|
||||
setState('copied');
|
||||
} catch {
|
||||
setState('failed');
|
||||
}
|
||||
|
||||
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
||||
timeoutRef.current = setTimeout(() => setState('idle'), 1200);
|
||||
};
|
||||
|
||||
const label = state === 'copied'
|
||||
? 'Copied to clipboard'
|
||||
: state === 'failed'
|
||||
? 'Clipboard unavailable'
|
||||
: 'Copy to clipboard';
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={copyValue}
|
||||
aria-label={label}
|
||||
title={label}
|
||||
className="grid h-5 w-5 shrink-0 place-items-center text-[var(--text-faint)] transition-colors hover:text-[var(--text)]"
|
||||
>
|
||||
{state === 'copied'
|
||||
? <Check className="h-3 w-3" aria-hidden="true" />
|
||||
: <Copy className="h-3 w-3" aria-hidden="true" />}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
export default CopyButton;
|
||||
Reference in new issue
Block a user