From d3764904827cea4035205ed45b83b51fdfd8cc91 Mon Sep 17 00:00:00 2001 From: yuguangzhou Date: Wed, 10 Jul 2024 23:53:47 +0800 Subject: [PATCH] feat: add resizable --- apps/fronted/package.json | 1 + .../app/workbench/compoents/Editor/index.tsx | 7 ++- .../src/app/workbench/compoents/Project.tsx | 8 +++- apps/fronted/src/app/workbench/page.tsx | 19 +++++++- apps/fronted/src/components/ui/resizable.tsx | 45 +++++++++++++++++++ pnpm-lock.yaml | 13 ++++++ 6 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 apps/fronted/src/components/ui/resizable.tsx diff --git a/apps/fronted/package.json b/apps/fronted/package.json index 6d608fa..0f351d2 100644 --- a/apps/fronted/package.json +++ b/apps/fronted/package.json @@ -29,6 +29,7 @@ "react": "^18", "react-day-picker": "^8.10.1", "react-dom": "^18", + "react-resizable-panels": "^2.0.20", "tailwind-merge": "^2.3.0", "tailwindcss-animate": "^1.0.7" }, diff --git a/apps/fronted/src/app/workbench/compoents/Editor/index.tsx b/apps/fronted/src/app/workbench/compoents/Editor/index.tsx index 6350a48..a090912 100644 --- a/apps/fronted/src/app/workbench/compoents/Editor/index.tsx +++ b/apps/fronted/src/app/workbench/compoents/Editor/index.tsx @@ -49,7 +49,7 @@ const Editor = () => { } ]; return ( -
+
{tabList.map((item, index) => { return ( @@ -63,7 +63,10 @@ const Editor = () => { ); })}
-
+
前端-xx-x年
diff --git a/apps/fronted/src/app/workbench/compoents/Project.tsx b/apps/fronted/src/app/workbench/compoents/Project.tsx index dbafeb6..59e702b 100644 --- a/apps/fronted/src/app/workbench/compoents/Project.tsx +++ b/apps/fronted/src/app/workbench/compoents/Project.tsx @@ -1,5 +1,11 @@ +import Tiptap from "@/components/Tiptap"; + const Project = () => { - return
; + return ( +
+ +
+ ); }; export default Project; diff --git a/apps/fronted/src/app/workbench/page.tsx b/apps/fronted/src/app/workbench/page.tsx index 9e6499a..563e833 100644 --- a/apps/fronted/src/app/workbench/page.tsx +++ b/apps/fronted/src/app/workbench/page.tsx @@ -1,12 +1,27 @@ "use client"; import Editor from "./compoents/Editor"; +import { + ResizableHandle, + ResizablePanel, + ResizablePanelGroup +} from "@/components/ui/resizable"; import Preview from "./compoents/Preview"; import styles from "./index.module.scss"; const WorkBench = () => { return (
- - + + + + + + + + +
); }; diff --git a/apps/fronted/src/components/ui/resizable.tsx b/apps/fronted/src/components/ui/resizable.tsx new file mode 100644 index 0000000..f4bc558 --- /dev/null +++ b/apps/fronted/src/components/ui/resizable.tsx @@ -0,0 +1,45 @@ +"use client" + +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 b6d0c00..7d4e135 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -152,6 +152,9 @@ importers: react-dom: specifier: ^18 version: 18.3.1(react@18.3.1) + react-resizable-panels: + specifier: ^2.0.20 + version: 2.0.20(react-dom@18.3.1)(react@18.3.1) tailwind-merge: specifier: ^2.3.0 version: 2.3.0 @@ -6665,6 +6668,16 @@ packages: use-sidecar: 1.1.2(@types/react@18.3.2)(react@18.3.1) dev: false + /react-resizable-panels@2.0.20(react-dom@18.3.1)(react@18.3.1): + resolution: {integrity: sha512-aMbK3VF8U+VBICG+rwhE0Rr/eFZaRzmNq3akBRL1TrayIpLXz7Rbok0//kYeWj6SQRsjcQ3f4eRplJicM+oL6w==} + peerDependencies: + react: ^16.14.0 || ^17.0.0 || ^18.0.0 + react-dom: ^16.14.0 || ^17.0.0 || ^18.0.0 + dependencies: + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + dev: false + /react-style-singleton@2.2.1(@types/react@18.3.2)(react@18.3.1): resolution: {integrity: sha512-ZWj0fHEMyWkHzKYUr2Bs/4zU6XLmq9HsgBURm7g5pAVfyn49DgUiNgY2d4lXRlYSiCif9YBGpQleewkcqddc7g==} engines: {node: '>=10'}