import { Check, Copy } from "lucide-react"; import { useState } from "react"; import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { tomorrow } from "react-syntax-highlighter/dist/cjs/styles/prism"; import { Button } from "./ui/button"; type CodeComponentProps = { code: string; language: string; }; export default function CodeComponent({ code, language }: CodeComponentProps) { const [isCopied, setIsCopied] = useState(false); const copyToClipboard = () => { if (!navigator.clipboard || !navigator.clipboard.writeText) { return; } navigator.clipboard.writeText(code).then(() => { setIsCopied(true); setTimeout(() => { setIsCopied(false); }, 2000); }); }; return (
{code}
); }