Skip to content

Commit 14f6403

Browse files
committed
feat: add controls to the VirtualizedGridListGrid story
1 parent 1eca9a5 commit 14f6403

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

packages/react-aria-components/stories/GridList.stories.tsx

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,20 @@ export const VirtualizedGridList: StoryObj<typeof VirtualizedGridListRender> = {
200200
}
201201
};
202202

203-
export let VirtualizedGridListGrid: GridListStory = () => {
203+
interface VirtualizedGridListGridProps {
204+
maxItemSizeWidth?: number,
205+
maxColumns?: number,
206+
minHorizontalSpace?: number,
207+
maxHorizontalSpace?: number
208+
}
209+
210+
export let VirtualizedGridListGrid: StoryFn<VirtualizedGridListGridProps> = (args) => {
211+
const {
212+
maxItemSizeWidth = 65,
213+
maxColumns = Infinity,
214+
minHorizontalSpace = 0,
215+
maxHorizontalSpace = Infinity
216+
} = args;
204217
let items: {id: number, name: string}[] = [];
205218
for (let i = 0; i < 10000; i++) {
206219
items.push({id: i, name: `Item ${i}`});
@@ -211,7 +224,10 @@ export let VirtualizedGridListGrid: GridListStory = () => {
211224
layout={GridLayout}
212225
layoutOptions={{
213226
minItemSize: new Size(40, 40),
214-
maxSpace: 5
227+
maxItemSize: new Size(maxItemSizeWidth, 40),
228+
minSpace: new Size(minHorizontalSpace, 18),
229+
maxColumns,
230+
maxHorizontalSpace
215231
}}>
216232
<GridList className={styles.menu} layout="grid" style={{height: 400, width: 400}} aria-label="virtualized listbox" items={items}>
217233
{item => <MyGridListItem>{item.name}</MyGridListItem>}
@@ -220,6 +236,37 @@ export let VirtualizedGridListGrid: GridListStory = () => {
220236
);
221237
};
222238

239+
VirtualizedGridListGrid.story = {
240+
args: {
241+
maxItemSizeWidth: 65,
242+
maxColumns: undefined,
243+
minHorizontalSpace: 0,
244+
maxHorizontalSpace: undefined
245+
},
246+
argTypes: {
247+
maxItemSizeWidth: {
248+
control: 'number',
249+
description: 'Maximum width of each item in the grid list.',
250+
defaultValue: 65
251+
},
252+
maxColumns: {
253+
control: 'number',
254+
description: 'Maximum number of columns in the grid list.',
255+
defaultValue: undefined
256+
},
257+
minHorizontalSpace: {
258+
control: 'number',
259+
description: 'Minimum horizontal space between grid items.',
260+
defaultValue: 0
261+
},
262+
maxHorizontalSpace: {
263+
control: 'number',
264+
description: 'Maximum horizontal space between grid items.',
265+
defaultValue: undefined
266+
}
267+
}
268+
};
269+
223270
let renderEmptyState = ({isLoading}) => {
224271
return (
225272
<div style={{height: 30, width: '100%'}}>

0 commit comments

Comments
 (0)