Skip to content

Commit

Permalink
feat(Select): 서브 컴포넌트 사용 케이스를 나누어 스토리북 작성 (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
suwonthugger authored Sep 25, 2024
1 parent f80fe2a commit bafb50f
Show file tree
Hide file tree
Showing 6 changed files with 484 additions and 83 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-plants-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'docs': patch
---

SelectV2 스토리북 작성
2 changes: 1 addition & 1 deletion apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@sopt-makers/colors": "^3.0.1",
"@sopt-makers/fonts": "^2.0.1",
"@sopt-makers/icons": "^1.0.5",
"@sopt-makers/ui": "^2.2.0"
"@sopt-makers/ui": "^2.3.0"
},
"devDependencies": {
"@storybook/addon-essentials": "^7.6.3",
Expand Down
150 changes: 82 additions & 68 deletions apps/docs/src/stories/Select.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,70 +1,84 @@
import type { Meta, StoryObj } from "@storybook/react";
import { Select } from "@sopt-makers/ui";
import { IconSend } from "@sopt-makers/icons";
import type { Meta, StoryObj } from '@storybook/react';
import { Select } from '@sopt-makers/ui';
import { IconSend } from '@sopt-makers/icons';
import { fn } from '@storybook/test';

const selectOptions = [{
label: 'All',
value: '',
description: 'select all',
icon: <IconSend />,
}, {
label: 'Option 1',
value: 'option1',
description: 'Description 1',
icon: <IconSend />,
}, {
label: 'Option 2',
value: 'option2',
description: 'Description 2',
icon: <IconSend />,
}, {
label: 'Option 3',
value: 'option3',
description: 'Description 3',
icon: <IconSend />,
}, {
label: 'Option 4',
value: 'option4',
description: 'Description 4',
icon: <IconSend />,
}, {
label: 'Option 5',
value: 'option5',
description: 'Description 5',
icon: <IconSend />,
}];
const selectOptions = [
{
label: 'All',
value: '',
description: 'select all',
icon: <IconSend />,
},
{
label: 'Option 1',
value: 'option1',
description: 'Description 1',
icon: <IconSend />,
},
{
label: 'Option 2',
value: 'option2',
description: 'Description 2',
icon: <IconSend />,
},
{
label: 'Option 3',
value: 'option3',
description: 'Description 3',
icon: <IconSend />,
},
{
label: 'Option 4',
value: 'option4',
description: 'Description 4',
icon: <IconSend />,
},
{
label: 'Option 5',
value: 'option5',
description: 'Description 5',
icon: <IconSend />,
},
];

const userOptions = [{
label: 'Person 1',
value: 1,
description: 'person 1 desc',
}, {
label: 'Person 2',
value: 2,
description: 'person 2 desc',
}, {
label: 'Person 3',
value: 3,
description: 'person 3 desc',
}, {
label: 'Person 4',
value: 4,
description: 'person 4 desc',
}, {
label: 'Person 5',
value: 5,
description: 'person 5 desc',
}, {
label: 'Person 6',
value: 6,
description: 'person 6 desc',
}];
const userOptions = [
{
label: 'Person 1',
value: 1,
description: 'person 1 desc',
},
{
label: 'Person 2',
value: 2,
description: 'person 2 desc',
},
{
label: 'Person 3',
value: 3,
description: 'person 3 desc',
},
{
label: 'Person 4',
value: 4,
description: 'person 4 desc',
},
{
label: 'Person 5',
value: 5,
description: 'person 5 desc',
},
{
label: 'Person 6',
value: 6,
description: 'person 6 desc',
},
];

const meta = {
title: "Components/Input/Select",
title: 'Components/Input/deprecated/Select',
component: Select,
tags: ["autodocs"],
tags: ['autodocs'],
args: {
placeholder: 'Placeholder',
visibleOptions: 3,
Expand All @@ -74,7 +88,7 @@ const meta = {
defaultValue: { control: 'select', options: ['', 'option1', 'option2', 'option3', 'option4', 'option5'] },
placeholder: { control: 'text' },
visibleOptions: { control: 'number' },
}
},
} as Meta<typeof Select>;

export default meta;
Expand All @@ -86,7 +100,7 @@ export const Text: StoryObj = {
},
argTypes: {
type: { control: 'radio', options: ['text', 'textDesc', 'textIcon'] },
}
},
};

export const TextDesc: StoryObj = {
Expand All @@ -96,7 +110,7 @@ export const TextDesc: StoryObj = {
},
argTypes: {
type: { control: 'radio', options: ['text', 'textDesc', 'textIcon'] },
}
},
};

export const TextIcon: StoryObj = {
Expand All @@ -106,7 +120,7 @@ export const TextIcon: StoryObj = {
},
argTypes: {
type: { control: 'radio', options: ['text', 'textDesc', 'textIcon'] },
}
},
};

export const UserList: StoryObj = {
Expand All @@ -116,7 +130,7 @@ export const UserList: StoryObj = {
},
argTypes: {
type: { control: 'radio', options: ['userList', 'userListDesc'] },
}
},
};

export const UserListDesc: StoryObj = {
Expand All @@ -126,5 +140,5 @@ export const UserListDesc: StoryObj = {
},
argTypes: {
type: { control: 'radio', options: ['userList', 'userListDesc'] },
}
};
},
};
170 changes: 170 additions & 0 deletions apps/docs/src/stories/SelectV2NoTriggerContent.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
import type { Meta, StoryObj } from '@storybook/react';
import { SelectV2 } from '@sopt-makers/ui';
import { IconSend, IconDotsVertical } from '@sopt-makers/icons';
import { fn } from '@storybook/test';

const selectOptions = [
{
label: '수정',
value: '',
description: '수정',
icon: <IconSend />,
},
{
label: '삭제',
value: 'option1',
description: '삭제',
icon: <IconSend />,
},
];

const userOptions = [
{
label: '수정',
value: 1,
description: '수정',
},
{
label: '삭제',
value: 2,
description: '삭제',
},
];

const style = { width: 24, height: 24, color: 'white' };

const meta: Meta<typeof SelectV2.Root> = {
title: 'Components/Input/SelectV2/NoTriggerContent',
component: SelectV2.Root,
tags: ['autodocs'],
args: {
visibleOptions: 3,
onChange: fn(),
},
argTypes: {
defaultValue: { control: 'select', options: ['', 'option1', 'option2', 'option3', 'option4', 'option5'] },
visibleOptions: { control: 'number' },
},
};

export default meta;

export const Text: StoryObj<typeof SelectV2.Root> = {
render: (args) => (
<SelectV2.Root {...args}>
<SelectV2.Trigger>
<div>
<IconDotsVertical style={style} />
</div>
</SelectV2.Trigger>
<SelectV2.Menu>
{selectOptions.map((option) => (
<SelectV2.MenuItem key={option.value} option={option} />
))}
</SelectV2.Menu>
</SelectV2.Root>
),
args: {
type: 'text',
visibleOptions: 3,
},
argTypes: {
type: { control: 'radio', options: ['text', 'textDesc', 'textIcon'] },
},
};

export const TextDesc: StoryObj<typeof SelectV2.Root> = {
render: (args) => (
<SelectV2.Root {...args}>
<SelectV2.Trigger>
<div>
<IconDotsVertical style={style} />
</div>
</SelectV2.Trigger>
<SelectV2.Menu>
{selectOptions.map((option) => (
<SelectV2.MenuItem key={option.value} option={option} />
))}
</SelectV2.Menu>
</SelectV2.Root>
),
args: {
type: 'textDesc',
visibleOptions: 3,
},
argTypes: {
type: { control: 'radio', options: ['text', 'textDesc', 'textIcon'] },
},
};

export const TextIcon: StoryObj<typeof SelectV2.Root> = {
render: (args) => (
<SelectV2.Root {...args}>
<SelectV2.Trigger>
<div>
<IconDotsVertical style={style} />
</div>
</SelectV2.Trigger>
<SelectV2.Menu>
{selectOptions.map((option) => (
<SelectV2.MenuItem key={option.value} option={option} />
))}
</SelectV2.Menu>
</SelectV2.Root>
),
args: {
type: 'textIcon',
visibleOptions: 3,
},
argTypes: {
type: { control: 'radio', options: ['text', 'textDesc', 'textIcon'] },
},
};

export const UserList: StoryObj<typeof SelectV2.Root> = {
render: (args) => (
<SelectV2.Root {...args}>
<SelectV2.Trigger>
<div>
<IconDotsVertical style={style} />
</div>
</SelectV2.Trigger>
<SelectV2.Menu>
{userOptions.map((option) => (
<SelectV2.MenuItem key={option.value} option={option} />
))}
</SelectV2.Menu>
</SelectV2.Root>
),
args: {
type: 'userList',
visibleOptions: 3,
},
argTypes: {
type: { control: 'radio', options: ['userList', 'userListDesc'] },
},
};

export const UserListDesc: StoryObj<typeof SelectV2.Root> = {
render: (args) => (
<SelectV2.Root {...args}>
<SelectV2.Trigger>
<div>
<IconDotsVertical style={style} />
</div>
</SelectV2.Trigger>
<SelectV2.Menu>
{userOptions.map((option) => (
<SelectV2.MenuItem key={option.value} option={option} />
))}
</SelectV2.Menu>
</SelectV2.Root>
),
args: {
type: 'userListDesc',
visibleOptions: 3,
},
argTypes: {
type: { control: 'radio', options: ['userList', 'userListDesc'] },
},
};
Loading

0 comments on commit bafb50f

Please sign in to comment.