feat(layout): create MainLayout and MainPage components with editor features

This commit is contained in:
ngc2207 2025-01-05 01:05:14 +08:00
parent 274cb40b73
commit 545422cd5f
3 changed files with 47 additions and 3 deletions

14
src/app/(main)/layout.tsx Normal file
View File

@ -0,0 +1,14 @@
import Header from "./components/header";
export default function MainLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<div className="h-full flex flex-col">
<Header />
<div className="flex-1">{children}</div>
</div>
);
}

33
src/app/(main)/page.tsx Normal file
View File

@ -0,0 +1,33 @@
"use client";
import * as monaco from "monaco-editor";
import Editor from "@monaco-editor/react";
import { loader } from "@monaco-editor/react";
import ThemeSelector from "./components/theme-selector";
import FontSizeSlider from "./components/font-size-slider";
import LanguageSelector from "./components/language-selector";
import { useCodeEditorStore } from "@/store/useCodeEditorStore";
import { highlightMonacoEditor } from "@/constants/editor/themes";
loader.config({ monaco });
export default function MainPage() {
const { language, theme, fontSize, setEditor } = useCodeEditorStore();
return (
<div className="h-full flex flex-col gap-2">
<div className="flex items-center px-4 gap-2">
<LanguageSelector />
<ThemeSelector />
<FontSizeSlider />
</div>
<Editor
language={language}
theme={theme}
beforeMount={highlightMonacoEditor}
onMount={setEditor}
options={{ fontSize, automaticLayout: true }}
/>
</div>
);
}

View File

@ -1,3 +0,0 @@
export default function HomePage() {
return null;
}