resizable.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use client"
  2. import { GripVertical } from "lucide-react"
  3. import * as ResizablePrimitive from "react-resizable-panels"
  4. import { cn } from "@/lib/utils"
  5. const ResizablePanelGroup = ({
  6. className,
  7. ...props
  8. }: React.ComponentProps<typeof ResizablePrimitive.PanelGroup>) => (
  9. <ResizablePrimitive.PanelGroup
  10. className={cn(
  11. "flex h-full w-full data-[panel-group-direction=vertical]:flex-col",
  12. className
  13. )}
  14. {...props}
  15. />
  16. )
  17. const ResizablePanel = ResizablePrimitive.Panel
  18. const ResizableHandle = ({
  19. withHandle,
  20. className,
  21. ...props
  22. }: React.ComponentProps<typeof ResizablePrimitive.PanelResizeHandle> & {
  23. withHandle?: boolean
  24. }) => (
  25. <ResizablePrimitive.PanelResizeHandle
  26. className={cn(
  27. "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",
  28. className
  29. )}
  30. {...props}
  31. >
  32. {withHandle && (
  33. <div className="z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border">
  34. <GripVertical className="h-2.5 w-2.5" />
  35. </div>
  36. )}
  37. </ResizablePrimitive.PanelResizeHandle>
  38. )
  39. export { ResizablePanelGroup, ResizablePanel, ResizableHandle }