|
| 1 | +import { Meta, StoryObj } from '@storybook/react' |
| 2 | +import { useState } from 'react' |
| 3 | + |
| 4 | +import { CheckboxInput } from '@/components/common/input/CheckboxInput' |
| 5 | + |
| 6 | +const meta: Meta<typeof CheckboxInput> = { |
| 7 | + component: CheckboxInput, |
| 8 | + title: 'Common/Input/CheckboxInput', |
| 9 | + args: { |
| 10 | + label: '전체 동의', |
| 11 | + variant: 'checkbox', |
| 12 | + disabled: false, |
| 13 | + }, |
| 14 | +} |
| 15 | + |
| 16 | +export default meta |
| 17 | + |
| 18 | +type Story = StoryObj<typeof CheckboxInput> |
| 19 | + |
| 20 | +export const Default: Story = { |
| 21 | + args: { |
| 22 | + label: '전체 동의', |
| 23 | + variant: 'checkbox', |
| 24 | + checked: false, |
| 25 | + disabled: false, |
| 26 | + }, |
| 27 | + render: function Render(args: any) { |
| 28 | + const [checked, setChecked] = useState(false) |
| 29 | + |
| 30 | + const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { |
| 31 | + setChecked(e.target.checked) |
| 32 | + } |
| 33 | + |
| 34 | + return <CheckboxInput {...args} checked={checked} onChange={handleChange} /> |
| 35 | + }, |
| 36 | +} |
| 37 | + |
| 38 | +export const Check: Story = { |
| 39 | + args: { |
| 40 | + label: '이메일 수신 동의', |
| 41 | + variant: 'check', |
| 42 | + checked: false, |
| 43 | + disabled: false, |
| 44 | + }, |
| 45 | + render: function Render(args: any) { |
| 46 | + const [checked, setChecked] = useState(false) |
| 47 | + |
| 48 | + const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { |
| 49 | + setChecked(e.target.checked) |
| 50 | + } |
| 51 | + |
| 52 | + return <CheckboxInput {...args} checked={checked} onChange={handleChange} /> |
| 53 | + }, |
| 54 | +} |
| 55 | + |
| 56 | +export const DisabledCheckbox: Story = { |
| 57 | + args: { |
| 58 | + label: '비활성화된 체크박스', |
| 59 | + variant: 'checkbox', |
| 60 | + checked: false, |
| 61 | + disabled: true, |
| 62 | + }, |
| 63 | + render: function Render(args: any) { |
| 64 | + return <CheckboxInput {...args} /> |
| 65 | + }, |
| 66 | +} |
| 67 | + |
| 68 | +export const DisabledCheck: Story = { |
| 69 | + args: { |
| 70 | + label: '비활성화된 체크', |
| 71 | + variant: 'check', |
| 72 | + checked: false, |
| 73 | + disabled: true, |
| 74 | + }, |
| 75 | + render: function Render(args: any) { |
| 76 | + return <CheckboxInput {...args} /> |
| 77 | + }, |
| 78 | +} |
0 commit comments