Skip to content

Commit a8bb484

Browse files
committed
[feat] ListTab 스토리북 구성
1 parent 2dfea74 commit a8bb484

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
'use client';
2+
3+
import type { Meta, StoryObj } from '@storybook/react';
4+
import { useState } from 'react';
5+
import { ListTab, ListTabProps } from './ListTab';
6+
import { TabInfo } from '../tab/Tab';
7+
8+
// ListTab 타입 정의
9+
type ListTabType = 'all' | 'inProgress' | 'completed';
10+
11+
const defaultTabInfo: TabInfo<ListTabType> = [
12+
{ tabType: 'all', label: '전체', count: 7 },
13+
{ tabType: 'inProgress', label: '진행 중', count: 5 },
14+
{ tabType: 'completed', label: '진행 완료' },
15+
];
16+
17+
const meta: Meta<typeof ListTab> = {
18+
title: 'components/ListTab',
19+
component: ListTab,
20+
argTypes: {
21+
selectedTab: { control: 'text' },
22+
onClick: { action: 'clicked' },
23+
},
24+
};
25+
export default meta;
26+
27+
type Story = StoryObj<ListTabProps<ListTabType>>;
28+
29+
// 기본 Tab UI
30+
export const Default: Story = {
31+
render: (args) => {
32+
const [selectedTab, setSelectedTab] = useState<ListTabType>('all');
33+
34+
return (
35+
<ListTab {...args} selectedTab={selectedTab} onClick={setSelectedTab} />
36+
);
37+
},
38+
args: {
39+
tabInfo: defaultTabInfo,
40+
},
41+
};
42+
43+
// count가 있는 Tab
44+
export const WithCounts: Story = {
45+
render: (args) => {
46+
const [selectedTab, setSelectedTab] = useState<ListTabType>('all');
47+
48+
return (
49+
<ListTab
50+
{...args}
51+
tabInfo={[
52+
{ tabType: 'all', label: '전체', count: 7 },
53+
{ tabType: 'inProgress', label: '진행 중', count: 5 },
54+
{ tabType: 'completed', label: '진행 완료', count: 2 },
55+
]}
56+
selectedTab={selectedTab}
57+
onClick={setSelectedTab}
58+
/>
59+
);
60+
},
61+
};

0 commit comments

Comments
 (0)