From c7183269812f58e3a30e8e6204270266c15dd3ea Mon Sep 17 00:00:00 2001 From: arsam Date: Fri, 18 Sep 2026 23:10:31 +0330 Subject: [PATCH] Import source: src/components/common/code-editor Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality. --- src/components/common/code-editor.tsx | 76 +++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/components/common/code-editor.tsx diff --git a/src/components/common/code-editor.tsx b/src/components/common/code-editor.tsx new file mode 100644 index 0000000..62e06b4 --- /dev/null +++ b/src/components/common/code-editor.tsx @@ -0,0 +1,76 @@ +"use client"; + +import dynamic from "next/dynamic"; +import { useEffect, useState } from "react"; +import { Code2 } from "lucide-react"; +import { Button } from "@/components/ui/button"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { useUiStore } from "@/stores/ui-store"; + +const MonacoEditor = dynamic(() => import("@monaco-editor/react"), { + ssr: false, + loading: () =>
, +}); + +export function CodeEditor({ + title, + language, + value, + autoLoad = false, +}: { + title: string; + language: string; + value: string; + autoLoad?: boolean; +}) { + const themePref = useUiStore((state) => state.theme); + const [dark, setDark] = useState(true); + const [open, setOpen] = useState(autoLoad); + + useEffect(() => { + const frame = requestAnimationFrame(() => { + setDark(document.documentElement.classList.contains("dark")); + }); + return () => cancelAnimationFrame(frame); + }, [themePref]); + + return ( + + + + {title} + + {language} + + + + + {open ? ( + + ) : ( + <> +
+              {value}
+            
+ + + )} +
+
+ ); +}