blob: 938a518cbc4a05e27065fbdad1d1ab6b40036a90 [file] [log] [blame]
giod0026612025-05-08 13:00:36 +00001import * as ResizablePrimitive from "react-resizable-panels";
gio5f2f1002025-03-20 18:38:48 +04002
giod0026612025-05-08 13:00:36 +00003import { cn } from "@/lib/utils";
4import { DragHandleDots2Icon } from "@radix-ui/react-icons";
gio5f2f1002025-03-20 18:38:48 +04005
giod0026612025-05-08 13:00:36 +00006const ResizablePanelGroup = ({ className, ...props }: React.ComponentProps<typeof ResizablePrimitive.PanelGroup>) => (
7 <ResizablePrimitive.PanelGroup
8 className={cn("flex h-full w-full data-[panel-group-direction=vertical]:flex-col", className)}
9 {...props}
10 />
11);
gio5f2f1002025-03-20 18:38:48 +040012
giod0026612025-05-08 13:00:36 +000013const ResizablePanel = ResizablePrimitive.Panel;
gio5f2f1002025-03-20 18:38:48 +040014
15const ResizableHandle = ({
giod0026612025-05-08 13:00:36 +000016 withHandle,
17 className,
18 ...props
gio5f2f1002025-03-20 18:38:48 +040019}: React.ComponentProps<typeof ResizablePrimitive.PanelResizeHandle> & {
giod0026612025-05-08 13:00:36 +000020 withHandle?: boolean;
gio5f2f1002025-03-20 18:38:48 +040021}) => (
giod0026612025-05-08 13:00:36 +000022 <ResizablePrimitive.PanelResizeHandle
23 className={cn(
24 "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",
25 className,
26 )}
27 {...props}
28 >
29 {withHandle && (
30 <div className="z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border">
31 <DragHandleDots2Icon className="h-2.5 w-2.5" />
32 </div>
33 )}
34 </ResizablePrimitive.PanelResizeHandle>
35);
gio5f2f1002025-03-20 18:38:48 +040036
giod0026612025-05-08 13:00:36 +000037export { ResizablePanelGroup, ResizablePanel, ResizableHandle };