import { Meta, StoryObj } from '@storybook/react-webpack5'; import { fn } from 'storybook/test'; import List from '../../../List'; import { ListItem } from '../../..'; import { SB_LIST_ITEM_ADDITIONAL_INFO as INFO, 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} /> ); }, }; /** * Use `hideIndicator` when surrounding context (e.g. trailing value content) makes the * interactive affordance clear without a chevron.
* **NB:** This feature should be used with great care as it can result in the item looking * as non-interactive, significantly degrading accessibility, UX, and conversion, * especially if used on busy screens with multiple Lists. */ export const WithoutIndicator: Story = { parameters: { controls: { disable: true }, }, render: (args) => { return ( } title="Navigation without chevron" subtitle="Interactive row — no directional indicator" valueTitle="£1,234.56" media={MEDIA.avatarSingle} /> } title="Navigation without chevron (button)" subtitle="Triggers a click handler" media={MEDIA.avatarSingle} /> ); }, }; /** * 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} /> ); }, };