Skip to content

Commit 21ae453

Browse files
committed
chore: Select storybook 수정
1 parent dad8767 commit 21ae453

File tree

1 file changed

+44
-27
lines changed

1 file changed

+44
-27
lines changed

src/shared/ui/Select/Select.stories.tsx

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Fragment } from 'react';
1+
import { Fragment, useState } from 'react';
22
import type { Meta, StoryObj } from '@storybook/react';
33

44
import { GroupingSelect, Select } from './index';
@@ -21,7 +21,6 @@ const meta = {
2121
} satisfies Meta<typeof Select>;
2222

2323
export default meta;
24-
2524
type Story = StoryObj<typeof Select>;
2625

2726
const defaultContents = ['객관식', '단답형', '체크박스', '드롭다운', '파일'];
@@ -35,20 +34,27 @@ export const Basic: Story = {
3534
},
3635
},
3736
args: {
37+
value: '유형을 선택해주세요',
3838
size: 'md',
3939
defaultValue: '유형을 선택해주세요',
4040
},
41-
render: (args) => (
42-
<Select {...args}>
43-
{defaultContents.map((item, index) => (
44-
<Select.Option key={index} id={String(index + 1)} name={item} />
45-
))}
46-
</Select>
47-
),
41+
render: (args) => {
42+
const [value, setValue] = useState(args.defaultValue);
43+
return (
44+
<div className="h-50">
45+
<Select {...args} value={value} onChange={setValue}>
46+
{defaultContents.map((item, index) => (
47+
<Select.Option key={index} name={item} />
48+
))}
49+
</Select>
50+
</div>
51+
);
52+
},
4853
};
4954

5055
export const LargeSize: Story = {
5156
args: {
57+
value: '유형을 선택해주세요',
5258
size: 'lg',
5359
defaultValue: '유형을 선택해주세요',
5460
},
@@ -59,13 +65,18 @@ export const LargeSize: Story = {
5965
},
6066
},
6167
},
62-
render: (args) => (
63-
<Select {...args}>
64-
{defaultContents.map((item, index) => (
65-
<Select.Option key={index} id={index.toString()} name={item} />
66-
))}
67-
</Select>
68-
),
68+
render: (args) => {
69+
const [value, setValue] = useState(args.defaultValue);
70+
return (
71+
<div className="h-62">
72+
<Select {...args} value={value} onChange={setValue}>
73+
{defaultContents.map((item, index) => (
74+
<Select.Option key={index} name={item} />
75+
))}
76+
</Select>
77+
</div>
78+
);
79+
},
6980
};
7081

7182
const groupingContents = {
@@ -114,16 +125,22 @@ export const Grouping: StoryObj<typeof GroupingSelect> = {
114125
},
115126
},
116127
},
117-
render: (args) => (
118-
<GroupingSelect {...args}>
119-
{Object.entries(groupingContents).map(([group, departments]) => (
120-
<Fragment key={group}>
121-
<GroupingSelect.Group name={group} />
122-
{departments.map((dept, idx) => (
123-
<GroupingSelect.Option key={`${group}-${idx}`} id={`${group}-${idx}`} name={dept} />
128+
render: (args) => {
129+
const [value, setValue] = useState(args.defaultValue);
130+
131+
return (
132+
<div className="h-62">
133+
<GroupingSelect {...args} value={value} onChange={setValue}>
134+
{Object.entries(groupingContents).map(([group, departments]) => (
135+
<Fragment key={group}>
136+
<GroupingSelect.Group name={group} />
137+
{departments.map((dept, idx) => (
138+
<GroupingSelect.Option key={`${group}-${idx}`} name={dept} />
139+
))}
140+
</Fragment>
124141
))}
125-
</Fragment>
126-
))}
127-
</GroupingSelect>
128-
),
142+
</GroupingSelect>
143+
</div>
144+
);
145+
},
129146
};

0 commit comments

Comments
 (0)