import { useMemo, useState } from "react"; import Editor from "@monaco-editor/react"; import { cn } from "@/lib/utils"; const sampleFiles = [ { name: "main.tsx", path: "src/main.tsx", language: "typescript", content: `import React from "react" import ReactDOM from "react-dom/client" import App from "./App" import "./index.css" ReactDOM.createRoot(document.getElementById("root")!).render( ) `, }, { name: "server.ts", path: "server/index.ts", language: "typescript", content: `import express from "express" const app = express() app.get("/health", (_req, res) => res.json({ ok: true })) app.listen(3000, () => console.log("Server listening on :3000")) `, }, { name: "styles.css", path: "src/styles.css", language: "css", content: `:root { --accent: #00d9ff; } body { margin: 0; font-family: system-ui, sans-serif; } `, }, ]; export default function IdePage() { const [activePath, setActivePath] = useState(sampleFiles[0].path); const [contents, setContents] = useState>(() => { const initial: Record = {}; sampleFiles.forEach((file) => { initial[file.path] = file.content; }); return initial; }); const activeFile = useMemo(() => sampleFiles.find((f) => f.path === activePath)!, [activePath]); return ( AeThex IDE (Monaco) Active file: {activeFile.path} Ctrl/Cmd + S to save (stub) Monaco powered { setContents((prev) => ({ ...prev, [activeFile.path]: val ?? "" })); }} options={{ fontSize: 14, minimap: { enabled: false }, smoothScrolling: true, scrollBeyondLastLine: false, wordWrap: "on", automaticLayout: true, }} loading={Loading Monaco editor...} /> ); }