import { Fragment } from 'react'; import { Meta, StoryObj } from '@storybook/react-webpack5'; import List from '../../list'; import { ListItem, type ListItemProps } from '../ListItem'; import { lorem10, lorem20, lorem5 } from '../../test-utils'; import portraitImage from '../../test-utils/assets/placeholder-landscape.svg'; import landscapeImage from '../../test-utils/assets/placeholder-portrait.svg'; import { SB_LIST_ITEM_CONTROLS as CONTROLS, SB_LIST_ITEM_MEDIA as MEDIA } from './subcomponents'; import { ListItemMediaSize } from '../ListItemContext'; import { withSizedContainer } from './helpers'; import { LISTITEM_CQ } from '../constants'; export default { title: 'Content/ListItem/Tests/layout', tags: ['!autodocs', '!manifest'], parameters: { controls: { disable: true }, actions: { disable: true }, a11y: { disable: true }, knobs: { disable: true }, }, } satisfies Meta; type Story = StoryObj; export const LongButton: Story = { render: () => ( {}, }} /> } control={ {}}>Click me Click me Click me Click me } /> ), decorators: [withSizedContainer(400, false)], }; export const GapsBetweenItems: Story = { render: () => { const props = { title: lorem5, subtitle: lorem10, media: MEDIA.image, control: CONTROLS.switch, }; return ( ); }, }; type PreviewStoryArgs = ListItemProps & { previewImageSize: ListItemMediaSize; previewWithLineGuides: boolean; previewPrompt: boolean | ListItemProps['prompt']; }; const previewArgGroup = { category: 'Preview options', type: { summary: undefined, }, }; const previewArgTypes = { previewImageSize: { options: [24, 32, 40, 48, 56, 72], control: { type: 'inline-radio', }, name: 'Preview with image size', table: previewArgGroup, }, previewWithLineGuides: { control: { type: 'boolean', }, name: 'Preview with line guides', table: previewArgGroup, }, previewPrompt: { control: { type: 'boolean', }, mapping: { true: This is a prompt, false: null, }, name: 'Preview with `prompt`', table: previewArgGroup, }, } as const; const getPropsForPreview = (args: PreviewStoryArgs) => { const { previewImageSize, previewWithLineGuides, previewPrompt, ...props } = args as { previewImageSize: ListItemMediaSize; previewWithLineGuides: boolean; previewPrompt: boolean | ListItemProps['prompt']; title: ListItemProps['title']; subtitle: ListItemProps['subtitle']; [key: string]: any; }; return [ { ...props, prompt: previewPrompt, }, { previewImageSize, previewWithLineGuides, }, ] as const; }; // Create a completely untyped story object export const ImageAlignment: StoryObj = { parameters: { controls: { disable: false }, }, args: { title: lorem5, subtitle: lorem10, previewImageSize: 48, previewWithLineGuides: true, previewPrompt: false, }, argTypes: previewArgTypes, decorators: [ (Story: any, { args }: { args: PreviewStoryArgs }) => ( <> {args.previewWithLineGuides && (