Skip to content

Commit a467297

Browse files
committed
[#98] ✨ Add Storybook for Form component (WIP, to be updated after authentication page development)
1 parent 60eb73f commit a467297

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { SubmitHandler, useForm } from 'react-hook-form'
2+
3+
import { Meta, StoryObj } from '@storybook/react'
4+
5+
import { Form } from '@/components/shared/form'
6+
7+
const meta: Meta = {
8+
title: 'Shared/Form/Form',
9+
component: Form,
10+
parameters: {
11+
layout: 'centered',
12+
},
13+
argTypes: {},
14+
}
15+
16+
export default meta
17+
type Story = StoryObj<typeof Form>
18+
19+
interface FormValues {
20+
email: string
21+
name: string
22+
password: string
23+
confirmPassword: string
24+
githubUrl: string
25+
agreements: string[]
26+
}
27+
28+
const FormWrapper = () => {
29+
const methods = useForm<FormValues>({
30+
defaultValues: {
31+
agreements: [],
32+
},
33+
})
34+
35+
const onSubmit: SubmitHandler<FormValues> = () => {}
36+
37+
return (
38+
<div className='w-420'>
39+
<Form
40+
methods={methods}
41+
onSubmit={methods.handleSubmit(onSubmit)}
42+
className='w-full'
43+
>
44+
<Form.Checkbox
45+
variant='checkbox'
46+
name='agreements'
47+
label='동의 항목'
48+
options={[
49+
{ label: '만 14세 이상입니다 (필수)', value: 'age' },
50+
{ label: '서비스 이용약관 동의 (필수)', value: 'terms' },
51+
{ label: '개인정보 수집 및 이용 동의 (필수)', value: 'privacy' },
52+
{
53+
label: '이벤트 등 마케팅 정보 수신 동의 (선택)',
54+
value: 'marketing',
55+
},
56+
]}
57+
/>
58+
<Form.Checkbox
59+
variant='check'
60+
name='agreements'
61+
label='동의 항목'
62+
options={[
63+
{ label: '만 14세 이상입니다 (필수)', value: 'age' },
64+
{ label: '서비스 이용약관 동의 (필수)', value: 'terms' },
65+
{ label: '개인정보 수집 및 이용 동의 (필수)', value: 'privacy' },
66+
{
67+
label: '이벤트 등 마케팅 정보 수신 동의 (선택)',
68+
value: 'marketing',
69+
},
70+
]}
71+
/>
72+
</Form>
73+
</div>
74+
)
75+
}
76+
77+
export const Default: Story = {
78+
render: () => <FormWrapper />,
79+
}

0 commit comments

Comments
 (0)