Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Select): 서브 컴포넌트 사용 케이스를 나누어 스토리북 작성 #149

Merged
merged 5 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기존 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>
Comment on lines +56 to +58
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TriggerContent를 쓰지 않는 케이스의 경우, Trigger의 자식요소로 mds 요청에서 문의 주셨던 아이콘을 넣어놨어요.

</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
Loading