Skip to content

Commit

Permalink
feat: Add resizeable panels (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
amareshsm authored Dec 13, 2024
1 parent b61d954 commit efd344c
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 20 deletions.
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"npm-run-all": "^4.1.5",
"postcss": "^8",
"prettier": "^3.3.3",
"react-resizable-panels": "^2.1.2",
"tailwindcss": "^3.4.4",
"typescript": "^5.5.3",
"typescript-eslint": "^8.3.0",
Expand Down
52 changes: 33 additions & 19 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { tools } from "./lib/tools";
import { Editor } from "./components/editor";
import { ToolSelector } from "./components/tool-selector";
import { ThemeProvider } from "./components/theme-provider";
import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";

function App() {
const { language, tool, code, setCode } = useExplorer();
Expand All @@ -15,26 +16,39 @@ function App() {
<div className="flex flex-col h-screen">
<Navbar />
<div className="h-full overflow-hidden">
<div className="grid sm:grid-cols-2 divide-x border-t h-full">
<Editor
value={code[language]}
onChange={value => {
setCode({ ...code, [language]: value });
}}
/>
<div className="bg-muted overflow-auto h-[70dvh] sm:h-full relative flex flex-col">
<div className="flex sm:items-center flex-col sm:flex-row justify-between p-4 gap-2 z-10">
<ToolSelector />
<div className="flex items-center gap-1">
{activeTool.options.map(
(Option, index) => (
<Option key={index} />
),
)}
<div className="border-t h-full">
<PanelGroup
direction="horizontal"
className="border-t h-full"
>
<Panel defaultSize={50} minSize={25}>
<Editor
value={code[language]}
onChange={value => {
setCode({
...code,
[language]: value,
});
}}
/>
</Panel>
<PanelResizeHandle className="w-2 bg-gutter dark:bg-gray-600 bg-gray-200 bg-no-repeat bg-center" />
<Panel defaultSize={50} minSize={25}>
<div className="bg-muted overflow-auto h-[70dvh] sm:h-full relative flex flex-col">
<div className="flex sm:items-center flex-col sm:flex-row justify-between p-4 gap-2 z-10">
<ToolSelector />
<div className="flex items-center gap-1">
{activeTool.options.map(
(Option, index) => (
<Option key={index} />
),
)}
</div>
</div>
<activeTool.component />
</div>
</div>
<activeTool.component />
</div>
</Panel>
</PanelGroup>
</div>
</div>
</div>
Expand Down
Binary file added src/assets/gutter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/logo.svg

This file was deleted.

6 changes: 6 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ module.exports = {
"accordion-down": "accordion-down 0.2s ease-out",
"accordion-up": "accordion-up 0.2s ease-out",
},
backgroundImage: {
gutter: "url('./assets/gutter.png')",
},
backgroundPosition: {
center: "50%",
},
},
},
plugins: [
Expand Down

0 comments on commit efd344c

Please sign in to comment.