import React, { useEffect } from 'react'; import { ComponentMeta, ComponentStory } from '@storybook/react'; import { Flex } from '../Layout'; import { Switch } from './Switch'; import SwitchDocs from './Switch.mdx'; export default { title: 'UI Components/Switch', component: Switch, argTypes: { asChild: { control: false }, }, args: { disabled: false, checked: true, required: false, }, parameters: { docs: { page: SwitchDocs, }, }, } as ComponentMeta; //👇 We create a “template” of how args map to rendering const Template: ComponentStory = ({ checked: initialChecked, ...args }) => { const [checked, onCheckedChange] = React.useState(false); useEffect(() => { onCheckedChange(!!initialChecked); }, [initialChecked]); return ( ); }; export const Playground = Template.bind({}); Playground.storyName = 'Switch'; Playground.args = { checked: false, onCheckedChange: () => { return; }, };