import { Meta, StoryObj } from '@storybook/react-webpack5'; import { fn } from 'storybook/test'; import { lorem10 } from '../../test-utils'; import List from '../../list'; import { ListItem } from '../ListItem'; import { SB_LIST_ITEM_ADDITIONAL_INFO as INFO, SB_LIST_ITEM_PROMPTS as PROMPTS, SB_LIST_ITEM_MEDIA as MEDIA, } from '../_stories/subcomponents'; import type { ListItemNavigationProps } from './ListItemNavigation'; const meta: Meta = { component: ListItem.Navigation, title: 'Content/ListItem/ListItem.Navigation', args: { href: 'https://wise.com', onClick: fn(), target: undefined, }, argTypes: { onClick: { description: 'If `href` is falsy and `onClick` is set, the component will render as an HTML button.', }, target: { control: 'select', options: [undefined, '_blank', '_self', '_parent', '_top'], description: 'The `target` attribute for HTML anchor. If set to `_blank`, `rel="noopener noreferrer"` is automatically added to the rendered node.', }, }, } satisfies Meta; export default meta; type Story = StoryObj; export const Playground: Story = { render: (args: ListItemNavigationProps) => { return ( } additionalInfo={INFO.nonInteractive} /> ); }, }; /** * Navigation control can be rendered as HTML anchor or a button */ export const AsButton: Story = { args: { onClick: fn(), }, parameters: { controls: { disable: true }, }, render: (args) => { return ( } title="Navigation as link" subtitle="This will navigate to an external URL" media={MEDIA.avatarSingle} /> } title="Navigation as button" subtitle="This will trigger a click handler" media={MEDIA.avatarSingle} /> ); }, };