feat(component): add storybook (#5079)

This commit is contained in:
Cats Juice
2023-12-04 08:32:19 +00:00
parent 9c50dbc362
commit d911d21d1c
30 changed files with 1640 additions and 50 deletions

View File

@@ -0,0 +1,65 @@
import type { Meta, StoryFn } from '@storybook/react';
import { useState } from 'react';
import { Checkbox } from './checkbox';
export default {
title: 'UI/Checkbox',
component: Checkbox,
parameters: {
chromatic: { disableSnapshot: true },
},
} satisfies Meta<typeof Checkbox>;
export const Basic: StoryFn<typeof Checkbox> = props => {
const [checked, setChecked] = useState(props.checked);
const handleChange = (
_event: React.ChangeEvent<HTMLInputElement>,
checked: boolean
) => {
setChecked(checked);
props.onChange?.(_event, checked);
};
return (
<div
style={{
display: 'flex',
flexDirection: 'column',
gap: '1rem',
justifyContent: 'center',
}}
>
<Checkbox
style={{ fontSize: 14 }}
{...props}
checked={checked}
onChange={handleChange}
/>
<Checkbox
style={{ fontSize: 16 }}
{...props}
checked={checked}
onChange={handleChange}
/>
<Checkbox
style={{ fontSize: 18 }}
{...props}
checked={checked}
onChange={handleChange}
/>
<Checkbox
style={{ fontSize: 24 }}
{...props}
checked={checked}
onChange={handleChange}
/>
</div>
);
};
Basic.args = {
checked: true,
disabled: false,
indeterminate: false,
onChange: console.log,
};