import { Page } from 'puppeteer' import React from 'react' import { Tab, TabController, TabList, TabPanel } from '../' import { FlexItemProps } from '../helpers/flexItem' import { split } from '../helpers/omit' import { Story } from '../helpers/storybook' const LABELS = [ 'Ready!', 'And...action!', 'Cookies', 'Crumble', 'There was an old lady', 'Who swallowed a fly', "I don't know why", 'She swallowed a fly', "Perhaps she'll die", 'A life lived in fear is a life half-lived', 'I should probably have more than one', 'Menu item that is quite long', 'But I', 'Also need', 'Some short ones', 'Ein', 'Zwei', 'Drei', 'Uno', 'Dos', 'Tres', ] export default { title: 'Tabs', component: TabList, } as const export const BasicUsage: Story = ({ tabCount, ...args }) => { const [active, setActive] = React.useState(-1) const tabProps = split(args, 'flex', 'flexGrow', 'flexShrink', 'flexBasis') const tabs = [] for (let i = 1; i < tabCount; i++) { const label = LABELS[i % LABELS.length] tabs.push( setActive(i)} children={label} {...tabProps} /> ) } return ( {tabCount > 0 && ( { e.preventDefault() setActive(0) }} children={LABELS[0]} {...tabProps} /> )} {tabs} ) } BasicUsage.args = { tabCount: 6, justifyContent: 'space-evenly', flex: '', flexGrow: 0, flexShrink: 0, flexBasis: '', } export const WithController: Story = (args) => { const tabProps = split(args, 'flex', 'flexGrow', 'flexShrink', 'flexBasis') return ( Name Rank Serial #

Nebby Nebulous

Cloudy Nebula

N3BU14

) } WithController.args = { justifyContent: 'space-evenly', flex: '', flexGrow: 0, flexShrink: 0, flexBasis: '', } WithController.parameters = { beforeScreenshot: async (page: Page) => { await page.focus('#serial-num') }, }