Skip to content

Commit ede6c9f

Browse files
committed
[#46] ✅ Add Storybook for Switch component
1 parent fd3b994 commit ede6c9f

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { useState } from 'react'
2+
3+
import { Meta, StoryFn } from '@storybook/react'
4+
5+
import { Switch } from '@/components/common/switch/Switch'
6+
7+
export default {
8+
title: 'Common/Switch/Switch',
9+
component: Switch,
10+
parameters: {
11+
layout: 'centered',
12+
},
13+
argTypes: {
14+
label: { control: 'text' },
15+
isOn: { control: 'boolean', table: { disable: true } },
16+
disabled: { control: 'boolean' },
17+
},
18+
} as Meta
19+
20+
const Template: StoryFn = args => {
21+
const [isOn, setIsOn] = useState<boolean>(args.isOn || false)
22+
23+
const toggleSwitch = () => setIsOn((prev: boolean) => !prev)
24+
25+
return <Switch {...args} isOn={isOn} onToggle={toggleSwitch} />
26+
}
27+
28+
export const Default = Template.bind({})
29+
Default.args = {
30+
isOn: false,
31+
label: '모집 중만 보기',
32+
disabled: false,
33+
}
34+
35+
export const Disabled = Template.bind({})
36+
Disabled.args = {
37+
isOn: false,
38+
label: '모집 중만 보기',
39+
disabled: true,
40+
}

0 commit comments

Comments
 (0)