import { Page } from 'puppeteer' import React from 'react' import { MenuButton } from '../' import { HIDE_CONTROL, Story, STRING } from '../helpers/storybook' const stopNav = (e: React.MouseEvent): void => e.preventDefault() const action = (msg: string) => () => console.log(msg) export default { title: 'MenuButton', component: MenuButton, argTypes: { label: STRING, menuActions: { control: 'array' }, children: HIDE_CONTROL, }, args: { menuActions: ['Action One', 'Action Two', 'Action Three'] }, } as const type ActionArg = { menuActions: string[] } export const BasicUsage: Story< typeof MenuButton, ActionArg & { labelFilled: string labelUnfilled: string labelDisabled: string } > = ({ labelFilled, labelUnfilled, labelDisabled, menuActions }) => { const children = menuActions.map((a, i) => ( {a} )) return (
{children} {children} {children}
) } BasicUsage.argTypes = { label: HIDE_CONTROL, disabled: HIDE_CONTROL, variant: HIDE_CONTROL } BasicUsage.args = { labelFilled: 'Filled', labelUnfilled: 'Unfilled', labelDisabled: 'Disabled' } export const WithLinks: Story = ({ menuActions, ...args }) => ( {menuActions.map((a, i) => ( ))} ) WithLinks.args = { label: 'Demo', menuActions: ['Link One', 'Link Two', 'Link Three'] } WithLinks.storyName = 'with Links' WithLinks.parameters = { beforeScreenshot: async (page: Page) => { await page.click('button') }, } export const WithCollisions: Story = ({ menuActions, ...args }) => ( {menuActions.map((a, i) => ( ))} ) WithCollisions.args = { label: 'Demo' } WithCollisions.storyName = 'with Collisions' WithCollisions.parameters = { cactus: { overrides: { height: '220vh', width: '220vw', display: 'flex', justifyContent: 'center', alignItems: 'center', }, }, storyshots: false, }