From 238825c42e190ecfdcb27f8df605eee76953750c Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Wed, 26 Feb 2025 22:22:03 -0700 Subject: [PATCH] Create BusterResizeableGrid.stories.tsx --- .../ui/grid/BusterResizeableGrid.stories.tsx | 149 ++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 web/src/components/ui/grid/BusterResizeableGrid.stories.tsx diff --git a/web/src/components/ui/grid/BusterResizeableGrid.stories.tsx b/web/src/components/ui/grid/BusterResizeableGrid.stories.tsx new file mode 100644 index 000000000..930884d54 --- /dev/null +++ b/web/src/components/ui/grid/BusterResizeableGrid.stories.tsx @@ -0,0 +1,149 @@ +import type { Meta, StoryObj } from '@storybook/react'; +import { BusterResizeableGrid } from './BusterResizeableGrid'; +import { v4 as uuidv4 } from 'uuid'; +import { MIN_ROW_HEIGHT } from './config'; +import { useContext } from 'react'; +import { SortableItemContext } from './_BusterSortableItemDragContainer'; +import { Hand } from '../icons'; +import { cn } from '@/lib/classMerge'; + +const meta: Meta = { + title: 'Base/Grid/BusterResizeableGrid', + component: BusterResizeableGrid, + parameters: { + layout: 'padded' + }, + tags: ['autodocs'], + decorators: [ + (Story) => ( +
+ +
+ ) + ] +}; + +export default meta; +type Story = StoryObj; + +// Example content component for the grid items +const ExampleContent: React.FC<{ text: string }> = ({ text }) => { + const { attributes, listeners, isDragging } = useContext(SortableItemContext); + + return ( +
+
+ +
+ {text} +
+ ); +}; + +const defaultRows = [ + { + id: uuidv4(), + items: [ + { + id: uuidv4(), + children: + }, + { + id: uuidv4(), + children: + } + ], + columnSizes: [6, 6], + rowHeight: MIN_ROW_HEIGHT + }, + { + id: uuidv4(), + items: [ + { + id: uuidv4(), + children: + }, + { + id: uuidv4(), + children: + }, + { + id: uuidv4(), + children: + } + ], + columnSizes: [4, 4, 4], + rowHeight: MIN_ROW_HEIGHT + } +]; + +export const Default: Story = { + args: { + rows: defaultRows, + onRowLayoutChange: (newLayout) => console.log('Layout changed:', newLayout), + allowEdit: true + } +}; + +export const ReadOnly: Story = { + args: { + rows: defaultRows, + onRowLayoutChange: (newLayout) => console.log('Layout changed:', newLayout), + allowEdit: false + } +}; + +export const SingleRow: Story = { + args: { + rows: [defaultRows[0]], + onRowLayoutChange: (newLayout) => console.log('Layout changed:', newLayout), + allowEdit: true + } +}; + +export const ThreeColumns: Story = { + args: { + rows: [ + { + id: uuidv4(), + items: [ + { + id: uuidv4(), + children: + }, + { + id: uuidv4(), + children: + }, + { + id: uuidv4(), + children: + } + ], + columnSizes: [4, 4, 4], + rowHeight: 200 + } + ], + onRowLayoutChange: (newLayout) => console.log('Layout changed:', newLayout), + allowEdit: true + } +}; + +export const CustomOverlay: Story = { + args: { + rows: defaultRows, + onRowLayoutChange: (newLayout) => console.log('Layout changed:', newLayout), + allowEdit: true, + overlayComponent: ( +
+ Dragging... +
+ ) + } +};