MCPcopy Create free account
hub / github.com/code100x/daily-code / CodeBlock

Function CodeBlock

apps/web/components/CodeBlock.tsx:10–39  ·  view source on GitHub ↗
({ block }: { block: any })

Source from the content-addressed store, hash-verified

8import { Copy } from "lucide-react";
9
10export default function CodeBlock({ block }: { block: any }) {
11 const { toast } = useToast();
12
13 const code: string = block.properties.title[0].toString();
14 hljs.registerLanguage("javascript", javascript);
15
16 useEffect(() => {
17 hljs.highlightAll();
18 }, []);
19
20 const handleCopyClick = () => {
21 navigator.clipboard.writeText(code).then(() => {
22 toast({
23 description: "Copied to clipboard",
24 });
25 });
26 };
27
28 return (
29 <div className="w-full relative">
30 <div className="absolute rounded-s-md w-1 inset-y-0 bg-gradient-to-b from-blue-400 to-blue-700" />
31 <pre className="rounded-md text-sm sm:text-base !bg-[#151515] px-4 sm:px-6 md:px-8 whitespace-pre-wrap break-word flex justify-between">
32 <code className="language-javascript">{code}</code>
33 </pre>
34 <button className="text-gray-500 p-2 absolute top-2 right-2 hover:opacity-80" onClick={handleCopyClick}>
35 <Copy className="size-5 text-primary/50" />
36 </button>
37 </div>
38 );
39}

Callers

nothing calls this directly

Calls 1

useToastFunction · 0.90

Tested by

no test coverage detected