import React from 'react' import { SplitButton } from '../' import { actions, ActionWrap, HIDE_CONTROL, Icon, ICON_ARG, Story, STRING, } from '../helpers/storybook' const icon = (name: string) => ({ ...ICON_ARG, name, defaultValue: undefined }) export default { title: 'SplitButton', component: SplitButton, argTypes: { mainActionLabel: STRING, onSelectMainAction: HIDE_CONTROL, mainActionIcon: icon('mainActionIcon'), ...actions({ name: 'onSelect', wrapper: true }), }, args: { mainActionLabel: 'Main Action', disabled: false, }, } as const type SelectArg = { onSelect: ActionWrap } type IconStory = Story< typeof SplitButton, SelectArg & { ActionIcon1: Icon ActionIcon2: Icon } > const SplitButtonBase: IconStory = ({ ActionIcon1, ActionIcon2, onSelect, ...args }) => { return ( Action One Action Two ) } export const BasicUsage: IconStory = (args) => { return ( <> ) } BasicUsage.argTypes = { variant: HIDE_CONTROL, ActionIcon1: icon('actionIcon1'), ActionIcon2: icon('actionIcon2'), } BasicUsage.args = { mainActionLabel: 'standard' } type MultiStory = Story export const WithCollisions: MultiStory = ({ actions: _actions, onSelect, ...args }) => (
Scroll down and to the right
{_actions.map((a, i) => ( ))}
) WithCollisions.args = { actions: ['Action One', 'Action Two'] } WithCollisions.parameters = { cactus: { overrides: { height: '220vh', width: '220vw', display: 'flex', justifyContent: 'center', alignItems: 'center', }, }, storyshots: false, } export const FixedWidthContainer: Story = ({ onSelect, ...args }) => (
Action One Action Two
)