import type { Meta, StoryObj } from '@storybook/react'; import { VirtualizedList } from './virtualized-list'; // Generate 1000 items interface ListItem { id: number; text: string; description: string; } const items: ListItem[] = Array.from({ length: 1000 }, (_, i) => ({ id: i, text: `Item ${i + 1}`, description: `This is the description for item ${i + 1}. Scrolling is optimized.`, })); const meta = { title: 'UI/VirtualizedList', component: VirtualizedList, tags: ['autodocs'], argTypes: { itemHeight: { control: 'number' }, containerHeight: { control: 'number' }, overscan: { control: 'number' }, }, } satisfies Meta; export default meta; type Story = StoryObj; export const Default: Story = { args: { items, itemHeight: 70, containerHeight: 400, className: 'border border-border rounded-md', renderItem: (item: unknown) => { const typedItem = item as ListItem; return (
{typedItem.text} {typedItem.description}
); }, }, }; export const SmallItems: Story = { args: { items, itemHeight: 30, containerHeight: 300, className: 'border border-border rounded-md', renderItem: (item: unknown) => { const typedItem = item as ListItem; return (
{typedItem.text}
); }, }, };