resizable.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use client';
  2. import * as ResizablePrimitive from 'react-resizable-panels';
  3. import { cn } from '@/lib/utils';
  4. function ResizablePanelGroup({
  5. className,
  6. ...props
  7. }: ResizablePrimitive.GroupProps) {
  8. return (
  9. <ResizablePrimitive.Group
  10. data-slot="resizable-panel-group"
  11. className={cn(
  12. 'flex h-full w-full aria-[orientation=vertical]:flex-col',
  13. className,
  14. )}
  15. {...props}
  16. />
  17. );
  18. }
  19. function ResizablePanel({ ...props }: ResizablePrimitive.PanelProps) {
  20. return <ResizablePrimitive.Panel data-slot="resizable-panel" {...props} />;
  21. }
  22. function ResizableHandle({
  23. withHandle,
  24. className,
  25. ...props
  26. }: ResizablePrimitive.SeparatorProps & {
  27. withHandle?: boolean;
  28. }) {
  29. return (
  30. <ResizablePrimitive.Separator
  31. data-slot="resizable-handle"
  32. className={cn(
  33. 'relative flex w-px items-center justify-center bg-border ring-offset-background 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-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90',
  34. className,
  35. )}
  36. {...props}
  37. >
  38. {withHandle && (
  39. <div className="bg-border h-6 w-1 rounded-lg z-10 flex shrink-0" />
  40. )}
  41. </ResizablePrimitive.Separator>
  42. );
  43. }
  44. export { ResizableHandle, ResizablePanel, ResizablePanelGroup };