Skip to content

Commit

Permalink
refactor layout
Browse files Browse the repository at this point in the history
  • Loading branch information
yongenaelf committed Jul 18, 2024
1 parent efa2820 commit d22c017
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 12 deletions.
5 changes: 0 additions & 5 deletions app/@bottom/page.tsx

This file was deleted.

3 changes: 3 additions & 0 deletions app/@left/@bottom/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function LeftBottom() {
return <p>bottom left</p>;
}
2 changes: 1 addition & 1 deletion app/@left/page.tsx → app/@left/@top/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import FileExplorer from "@/components/file-explorer";

export default function Left() {
export default function LeftTop() {
return <FileExplorer />;
}
6 changes: 6 additions & 0 deletions app/@left/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import TopBottom from "@/components/top-bottom";
import { ReactNode } from "react";

export default function Left(props: { top: ReactNode; bottom: ReactNode }) {
return <TopBottom {...props} />;
}
12 changes: 12 additions & 0 deletions app/@right/@bottom/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use client";

import { TerminalContextProvider } from "react-terminal";
import Cli from "@/components/cli";

export default function Bottom() {
return (
<TerminalContextProvider>
<Cli />
</TerminalContextProvider>
);
}
File renamed without changes.
6 changes: 6 additions & 0 deletions app/@right/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import TopBottom from "@/components/top-bottom";
import { ReactNode } from "react";

export default function Right(props: { top: ReactNode; bottom: ReactNode }) {
return <TopBottom {...props} />;
}
20 changes: 14 additions & 6 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { Inter } from "next/font/google";
import "./globals.css";
import { ThemeProvider } from "@/components/theme-provider";
import { MenubarComponent } from "@/components/menu";
import { Shell } from "@/components/shell";
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from "@/components/ui/resizable";

const inter = Inter({ subsets: ["latin"] });

Expand All @@ -13,13 +17,11 @@ export const metadata: Metadata = {
};

export default function RootLayout({
bottom,
left,
top,
right,
}: Readonly<{
bottom: React.ReactNode;
left: React.ReactNode;
top: React.ReactNode;
right: React.ReactNode;
}>) {
return (
<html lang="en">
Expand All @@ -31,7 +33,13 @@ export default function RootLayout({
disableTransitionOnChange
>
<MenubarComponent />
<Shell left={left} top={top} bottom={bottom} />
<div className="h-[calc(100vh-40px)]">
<ResizablePanelGroup direction="horizontal" className="border">
<ResizablePanel defaultSize={25}>{left}</ResizablePanel>
<ResizableHandle />
<ResizablePanel defaultSize={75}>{right}</ResizablePanel>
</ResizablePanelGroup>
</div>
</ThemeProvider>
</body>
</html>
Expand Down
26 changes: 26 additions & 0 deletions components/top-bottom.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from "@/components/ui/resizable";
import { ReactNode } from "react";

export default function TopBottom({
top,
bottom,
}: {
top: ReactNode;
bottom: ReactNode;
}) {
return (
<div className="h-[calc(100vh-40px)]">
<ResizablePanelGroup direction="vertical">
<ResizablePanel defaultSize={70} className="overflow-y-auto">
{top}
</ResizablePanel>
<ResizableHandle />
<ResizablePanel defaultSize={30}>{bottom}</ResizablePanel>
</ResizablePanelGroup>
</div>
);
}

0 comments on commit d22c017

Please sign in to comment.