2
0

resizable.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import * as React from "react"
  2. import { GripVerticalIcon } from "lucide-react"
  3. import * as ResizablePrimitive from "react-resizable-panels"
  4. import { cn } from "@/client/lib/utils"
  5. function ResizablePanelGroup({
  6. className,
  7. ...props
  8. }: React.ComponentProps<typeof ResizablePrimitive.PanelGroup>) {
  9. return (
  10. <ResizablePrimitive.PanelGroup
  11. data-slot="resizable-panel-group"
  12. className={cn(
  13. "flex h-full w-full data-[panel-group-direction=vertical]:flex-col",
  14. className
  15. )}
  16. {...props}
  17. />
  18. )
  19. }
  20. function ResizablePanel({
  21. ...props
  22. }: React.ComponentProps<typeof ResizablePrimitive.Panel>) {
  23. return <ResizablePrimitive.Panel data-slot="resizable-panel" {...props} />
  24. }
  25. function ResizableHandle({
  26. withHandle,
  27. className,
  28. ...props
  29. }: React.ComponentProps<typeof ResizablePrimitive.PanelResizeHandle> & {
  30. withHandle?: boolean
  31. }) {
  32. return (
  33. <ResizablePrimitive.PanelResizeHandle
  34. data-slot="resizable-handle"
  35. className={cn(
  36. "bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden 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-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",
  37. className
  38. )}
  39. {...props}
  40. >
  41. {withHandle && (
  42. <div className="bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border">
  43. <GripVerticalIcon className="size-2.5" />
  44. </div>
  45. )}
  46. </ResizablePrimitive.PanelResizeHandle>
  47. )
  48. }
  49. export { ResizablePanelGroup, ResizablePanel, ResizableHandle }