import { ReactNode, useState } from "react"; import { theme } from "../theme"; import { IconCheck, IconClipboard } from "@tabler/icons-react"; export function CodeBlock({ children, enableCopy, }: { children: ReactNode; enableCopy?: boolean; }) { const [copySuccess, setCopySuccess] = useState(false); const handleCopy = (text: string) => { return () => { navigator.clipboard.writeText(text).then(() => { setCopySuccess(true); setTimeout(() => { setCopySuccess(false); }, 3000); }); }; }; return (

{children}

{enableCopy && navigator.clipboard && (copySuccess ? ( ) : ( ))}
); }