gitscope
← marzneshin / v0.7.0 / dashboard/src/common/components/ui/resizable.tsx
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/common/components/ui/resizable.tsx · TypeScript
Blame Raw
 1import { GripVertical } from "lucide-react"
 2import * as ResizablePrimitive from "react-resizable-panels"
 3
 4import { cn } from "@marzneshin/common/utils"
 5
 6const ResizablePanelGroup = ({
 7    className,
 8    ...props
 9}: React.ComponentProps<typeof ResizablePrimitive.PanelGroup>) => (
10    <ResizablePrimitive.PanelGroup
11        className={cn(
12            "flex h-full w-full data-[panel-group-direction=vertical]:flex-col",
13            className
14        )}
15        {...props}
16    />
17)
18
19const ResizablePanel = ResizablePrimitive.Panel
20
21const ResizableHandle = ({
22    withHandle,
23    className,
24    ...props
25}: React.ComponentProps<typeof ResizablePrimitive.PanelResizeHandle> & {
26    withHandle?: boolean
27}) => (
28    <ResizablePrimitive.PanelResizeHandle
29        className={cn(
30            "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",
31            className
32        )}
33        {...props}
34    >
35        {withHandle && (
36            <div className="z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border">
37                <GripVertical className="h-2.5 w-2.5" />
38            </div>
39        )}
40    </ResizablePrimitive.PanelResizeHandle>
41)
42
43export { ResizablePanelGroup, ResizablePanel, ResizableHandle }