import type { Story, Meta } from '@storybook/react' import React, { useEffect, useState } from 'react' import type { ComponentArgTypes } from '../../../typings/utils' import type { CheckboxProps } from '../Checkbox' import Component from '../Checkbox' import mdx from './Checkbox.mdx' const CheckboxTemplate: Story = ({ checked, onClick, ...props }) => { const [localChecked, setLocalChecked] = useState(checked) useEffect(() => { setLocalChecked(checked) }, [checked]) return ( { onClick?.(e) setLocalChecked(!localChecked) }} /> ) } export const Checkbox = CheckboxTemplate.bind({}) Checkbox.args = { checked: true, } const controls: ComponentArgTypes = { checked: { control: { type: 'boolean', }, }, } const actions: ComponentArgTypes = { onClick: { action: 'clicked', table: { disable: true } }, } export default { title: 'Atoms/Checkbox', argTypes: { ...controls, ...actions, }, parameters: { docs: { page: mdx, }, }, } as Meta