Skip to content

Database diagrams editor that allows you to visualize and design your DB with a single query.

resizeable panel

Guy Ben-Aharon327bc007b7cc
diff --git a/package-lock.json b/package-lock.json
index 4e11dd38..1956ce5d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -19,6 +19,7 @@
"lucide-react": "^0.424.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
+ "react-resizable-panels": "^2.0.22",
"react-router-dom": "^6.26.0",
"tailwind-merge": "^2.4.0",
"tailwindcss-animate": "^1.0.7"
@@ -5943,6 +5944,16 @@
}
}
},
+ "node_modules/react-resizable-panels": {
+ "version": "2.0.22",
+ "resolved": "https://registry.npmjs.org/react-resizable-panels/-/react-resizable-panels-2.0.22.tgz",
+ "integrity": "sha512-G8x8o7wjQxCG+iF4x4ngKVBpe0CY+DAZ/SaiDoqBEt0yuKJe9OE/VVYMBMMugQ3GyQ65NnSJt23tujlaZZe75A==",
+ "license": "MIT",
+ "peerDependencies": {
+ "react": "^16.14.0 || ^17.0.0 || ^18.0.0",
+ "react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0"
+ }
+ },
"node_modules/react-router": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-6.26.0.tgz",
diff --git a/package.json b/package.json
index 61348cbe..e64ba760 100644
--- a/package.json
+++ b/package.json
@@ -22,6 +22,7 @@
"lucide-react": "^0.424.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
+ "react-resizable-panels": "^2.0.22",
"react-router-dom": "^6.26.0",
"tailwind-merge": "^2.4.0",
"tailwindcss-animate": "^1.0.7"
diff --git a/src/components/button/button.tsx b/src/components/button/button.tsx
index f6c1dbc7..e83057db 100644
--- a/src/components/button/button.tsx
+++ b/src/components/button/button.tsx
@@ -1,4 +1,4 @@
-import * as React from 'react';
+import React from 'react';
import { Slot } from '@radix-ui/react-slot';
import { type VariantProps } from 'class-variance-authority';
diff --git a/src/components/card/card.tsx b/src/components/card/card.tsx
index c22c0b46..7645f6ab 100644
--- a/src/components/card/card.tsx
+++ b/src/components/card/card.tsx
@@ -1,5 +1,4 @@
-import * as React from 'react';
-
+import React from 'react';
import { cn } from '@/lib/utils';
const Card = React.forwardRef<
diff --git a/src/components/label/label.tsx b/src/components/label/label.tsx
index 31f9321d..aa0e9ea0 100644
--- a/src/components/label/label.tsx
+++ b/src/components/label/label.tsx
@@ -1,4 +1,4 @@
-import * as React from 'react';
+import React from 'react';
import * as LabelPrimitive from '@radix-ui/react-label';
import { cva, type VariantProps } from 'class-variance-authority';
diff --git a/src/components/menubar/menubar.tsx b/src/components/menubar/menubar.tsx
index c06ab703..12689c19 100644
--- a/src/components/menubar/menubar.tsx
+++ b/src/components/menubar/menubar.tsx
@@ -1,4 +1,4 @@
-import * as React from 'react';
+import React from 'react';
import {
CheckIcon,
ChevronRightIcon,
diff --git a/src/components/resizable/resizable.tsx b/src/components/resizable/resizable.tsx
new file mode 100644
index 00000000..d61a479e
--- /dev/null
+++ b/src/components/resizable/resizable.tsx
@@ -0,0 +1,44 @@
+import React from 'react';
+import { DragHandleDots2Icon } from '@radix-ui/react-icons';
+import * as ResizablePrimitive from 'react-resizable-panels';
+
+import { cn } from '@/lib/utils';
+
+const ResizablePanelGroup = ({
+ className,
+ ...props
+}: React.ComponentProps<typeof ResizablePrimitive.PanelGroup>) => (
+ <ResizablePrimitive.PanelGroup
+ className={cn(
+ 'flex h-full w-full data-[panel-group-direction=vertical]:flex-col',
+ className
+ )}
+ {...props}
+ />
+);
+
+const ResizablePanel = ResizablePrimitive.Panel;
+
+const ResizableHandle = ({
+ withHandle,
+ className,
+ ...props
+}: React.ComponentProps<typeof ResizablePrimitive.PanelResizeHandle> & {
+ withHandle?: boolean;
+}) => (
+ <ResizablePrimitive.PanelResizeHandle
+ className={cn(
+ 'relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90',
+ className
+ )}
+ {...props}
+ >
+ {withHandle && (
+ <div className="z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border">
+ <DragHandleDots2Icon className="h-2.5 w-2.5" />
+ </div>
+ )}
+ </ResizablePrimitive.PanelResizeHandle>
+);
+
+export { ResizablePanelGroup, ResizablePanel, ResizableHandle };
diff --git a/src/components/separator/separator.tsx b/src/components/separator/separator.tsx
index 25959909..2f9a2acc 100644
--- a/src/components/separator/separator.tsx
+++ b/src/components/separator/separator.tsx
@@ -1,4 +1,4 @@
-import * as React from 'react';
+import React from 'react';
import * as SeparatorPrimitive from '@radix-ui/react-separator';
import { cn } from '@/lib/utils';
diff --git a/src/pages/editor-page/canvas/canvas.tsx b/src/pages/editor-page/canvas/canvas.tsx
new file mode 100644
index 00000000..e1f62b6a
--- /dev/null
+++ b/src/pages/editor-page/canvas/canvas.tsx
@@ -0,0 +1,7 @@
+import React from 'react';
+
+export interface CanvasProps {}
+
+export const Canvas: React.FC<CanvasProps> = () => {
+ return <div className="flex h-full"></div>;
+};
diff --git a/src/pages/editor-page/editor-page.tsx b/src/pages/editor-page/editor-page.tsx
index 9cdb859a..dce5114d 100644
--- a/src/pages/editor-page/editor-page.tsx
+++ b/src/pages/editor-page/editor-page.tsx
@@ -1,12 +1,28 @@
import React from 'react';
import { TopNavbar } from './top-navbar/top-navbar';
import { Toolbar } from './toolbar/toolbar';
+import {
+ ResizableHandle,
+ ResizablePanel,
+ ResizablePanelGroup,
+} from '@/components/resizable/resizable';
+import { SidePanel } from './side-panel/side-panel';
+import { Canvas } from './canvas/canvas';
export const EditorPage: React.FC = () => {
return (
- <section className="bg-background">
+ <section className="bg-background h-screen w-screen">
<TopNavbar />
<Toolbar />
+ <ResizablePanelGroup direction="horizontal" className="h-full">
+ <ResizablePanel defaultSize={25} minSize={25} maxSize={99}>
+ <SidePanel />
+ </ResizablePanel>
+ <ResizableHandle />
+ <ResizablePanel defaultSize={75}>
+ <Canvas />
+ </ResizablePanel>
+ </ResizablePanelGroup>
</section>
);
};
diff --git a/src/pages/editor-page/side-panel/side-panel.tsx b/src/pages/editor-page/side-panel/side-panel.tsx
new file mode 100644
index 00000000..a5944853
--- /dev/null
+++ b/src/pages/editor-page/side-panel/side-panel.tsx
@@ -0,0 +1,7 @@
+import React from 'react';
+
+export interface SidePanelProps {}
+
+export const SidePanel: React.FC<SidePanelProps> = () => {
+ return <aside className="flex h-full"></aside>;
+};