import { clientEntry, css, on, type Handle, type SerializableProps } from 'remix/ui' const FADE_MS = 180 const HOLD_MS = 1200 type CopyState = 'idle' | 'copied' | 'failed' | 'resetting' interface PromptButtonProps extends SerializableProps { text: string } // This component hydrates independently; the rest of the page stays static HTML. export const PromptButton = clientEntry( import.meta.url, function PromptButton(handle: Handle) { let state: CopyState = 'idle' return () => { let promptLabel = `\u201C${handle.props.text}\u201D` let label = state === 'copied' || state === 'resetting' ? 'Copied to clipboard' : state === 'failed' ? 'Copy failed' : promptLabel let active = state === 'copied' || state === 'failed' || state === 'resetting' return ( ) } }, ) export function CopyIcon() { return () => ( ) } function wait(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)) } const buttonStyle = css({ appearance: 'none', font: 'inherit', textAlign: 'left', cursor: 'pointer', width: '100%', display: 'flex', gap: '16px', alignItems: 'center', padding: '16px', border: 0, borderRadius: '12px', color: 'var(--text-primary)', background: 'transparent', transition: 'background-color 150ms ease, color 150ms ease', '&:hover, &:focus-visible': { background: 'var(--surface-4)', color: 'var(--brand-blue)', outline: 'none', }, }) const iconSlotStyle = css({ flex: '0 0 24px', width: '24px', display: 'flex', alignItems: 'center', justifyContent: 'center', '& svg': { width: '20px', height: '20px', display: 'block', transform: 'rotate(180deg)', }, })