From aa7e8d3ef9b1c870d7d41e49b38319973a30c055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Schl=C3=A4fli?= Date: Thu, 8 Aug 2024 11:33:26 +0200 Subject: [PATCH] add resizable --- packages/design-system/package.json | 3 +- .../src/ui/resizable.stories.tsx | 39 +++++++++++++++++ packages/design-system/src/ui/resizable.tsx | 43 +++++++++++++++++++ pnpm-lock.yaml | 14 ++++++ 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 packages/design-system/src/ui/resizable.stories.tsx create mode 100644 packages/design-system/src/ui/resizable.tsx diff --git a/packages/design-system/package.json b/packages/design-system/package.json index cd6db22..81ed7df 100644 --- a/packages/design-system/package.json +++ b/packages/design-system/package.json @@ -26,7 +26,8 @@ "date-fns": "3.6.0", "react-colorful": "5.6.1", "react-countdown": "2.3.5", - "react-day-picker": "8.10.1" + "react-day-picker": "8.10.1", + "react-resizable-panels": "2.0.22" }, "devDependencies": { "@ladle/react": "4.1.0", diff --git a/packages/design-system/src/ui/resizable.stories.tsx b/packages/design-system/src/ui/resizable.stories.tsx new file mode 100644 index 0000000..2cdc79e --- /dev/null +++ b/packages/design-system/src/ui/resizable.stories.tsx @@ -0,0 +1,39 @@ +import { + ResizableHandle, + ResizablePanel, + ResizablePanelGroup, +} from '@/ui/resizable' +import type { Story, StoryDefault } from '@ladle/react' + +export default { + title: 'Shadcn/Resizable', +} satisfies StoryDefault + +export const Default: Story = () => ( + + +
+ One +
+
+ + + + +
+ Two +
+
+ + +
+ Three +
+
+
+
+
+) diff --git a/packages/design-system/src/ui/resizable.tsx b/packages/design-system/src/ui/resizable.tsx new file mode 100644 index 0000000..cd3cb0e --- /dev/null +++ b/packages/design-system/src/ui/resizable.tsx @@ -0,0 +1,43 @@ +import { GripVertical } from "lucide-react" +import * as ResizablePrimitive from "react-resizable-panels" + +import { cn } from "@/lib/utils" + +const ResizablePanelGroup = ({ + className, + ...props +}: React.ComponentProps) => ( + +) + +const ResizablePanel = ResizablePrimitive.Panel + +const ResizableHandle = ({ + withHandle, + className, + ...props +}: React.ComponentProps & { + withHandle?: boolean +}) => ( + div]:rotate-90", + className + )} + {...props} + > + {withHandle && ( +
+ +
+ )} +
+) + +export { ResizablePanelGroup, ResizablePanel, ResizableHandle } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4ebcf69..dda56f5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -137,6 +137,9 @@ importers: react-dom: specifier: ^18.3.1 version: 18.3.1(react@18.3.1) + react-resizable-panels: + specifier: 2.0.22 + version: 2.0.22(react-dom@18.3.1(react@18.3.1))(react@18.3.1) tailwind-merge: specifier: ^2.4.0 version: 2.4.0 @@ -5261,6 +5264,12 @@ packages: '@types/react': optional: true + react-resizable-panels@2.0.22: + resolution: {integrity: sha512-G8x8o7wjQxCG+iF4x4ngKVBpe0CY+DAZ/SaiDoqBEt0yuKJe9OE/VVYMBMMugQ3GyQ65NnSJt23tujlaZZe75A==} + peerDependencies: + react: ^16.14.0 || ^17.0.0 || ^18.0.0 + react-dom: ^16.14.0 || ^17.0.0 || ^18.0.0 + react-style-singleton@2.2.1: resolution: {integrity: sha512-ZWj0fHEMyWkHzKYUr2Bs/4zU6XLmq9HsgBURm7g5pAVfyn49DgUiNgY2d4lXRlYSiCif9YBGpQleewkcqddc7g==} engines: {node: '>=10'} @@ -12347,6 +12356,11 @@ snapshots: optionalDependencies: '@types/react': 18.3.3 + react-resizable-panels@2.0.22(react-dom@18.3.1(react@18.3.1))(react@18.3.1): + dependencies: + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + react-style-singleton@2.2.1(@types/react@18.3.3)(react@18.3.1): dependencies: get-nonce: 1.0.1