feat(playground): restructure app layout and implement playground with resizable panels

This commit is contained in:
cfngc4594 2025-02-21 21:06:26 +08:00
parent a699fc8069
commit 326cce7836
4 changed files with 40 additions and 13 deletions

View File

@ -1,16 +1,5 @@
import CodeEditor from "@/components/code-editor";
import { DEFAULT_PROBLEM } from "@/config/problem";
import MdxPreview from "@/components/problem-description";
import { redirect } from "next/navigation";
export default function HomePage() {
return (
<div className="h-full flex items-center">
<div className="h-full w-1/2">
<MdxPreview source={DEFAULT_PROBLEM} />
</div>
<div className="h-full w-1/2">
<CodeEditor />
</div>
</div>
);
redirect("/playground");
}

View File

@ -0,0 +1,6 @@
import MdxPreview from "@/components/mdx-preview";
import { DEFAULT_PROBLEM } from "@/config/problem";
export default function ProblemDescriptionPage() {
return <MdxPreview source={DEFAULT_PROBLEM} />;
}

View File

@ -0,0 +1,27 @@
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from "@/components/ui/resizable";
interface PlaygroundLayoutProps {
children: React.ReactNode;
problemDescription: React.ReactNode;
}
export default function PlaygroundLayout({
children,
problemDescription,
}: PlaygroundLayoutProps) {
return (
<ResizablePanelGroup direction="horizontal">
<ResizablePanel defaultSize={50}>
{problemDescription}
</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel defaultSize={50}>
{children}
</ResizablePanel>
</ResizablePanelGroup>
);
}

View File

@ -0,0 +1,5 @@
import CodeEditor from "@/components/code-editor";
export default function PlaygroundPage() {
return <CodeEditor />;
}