import { h, VNode } from "preact"; import { useEffect, useState } from "preact/hooks"; export function CopyIcon(): VNode { return ( ) }; export function CopiedIcon(): VNode { return ( ) }; export function CopyButton({ getContent }: { getContent: () => string }): VNode { const [copied, setCopied] = useState(false); function copyText(): void { navigator.clipboard.writeText(getContent() || ""); setCopied(true); } useEffect(() => { if (copied) { setTimeout(() => { setCopied(false); }, 1000); } }, [copied]); if (!copied) { return ( ); } return (
); }