import React, { useCallback, useState } from 'react' import { Copy, Check } from 'lucide-react' interface CopyButtonProps { value: string size?: number title?: string className?: string onCopy?: () => void } // Button that morphs between copy icon and check icon for 1.5s after click. export function CopyButton({ value, size = 14, title, className, onCopy }: CopyButtonProps): React.ReactElement { const [copied, setCopied] = useState(false) const handleClick = useCallback(async (e: React.MouseEvent) => { e.stopPropagation() try { await navigator.clipboard.writeText(value) setCopied(true) onCopy?.() window.setTimeout(() => setCopied(false), 1500) } catch { // noop } }, [value, onCopy]) return ( ) } export default CopyButton