Skip to content

Commit c6f8db8

Browse files
committed
adjust toggle story as csf3
1 parent cd73567 commit c6f8db8

File tree

1 file changed

+61
-25
lines changed

1 file changed

+61
-25
lines changed

stories/Toggle.stories.tsx

Lines changed: 61 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,77 @@
1-
import React from 'react';
2-
import { action } from '@storybook/addon-actions';
3-
import { text, boolean } from '@storybook/addon-knobs';
41
import { Toggle } from '../src/scripts';
5-
export default {
2+
import { ComponentMeta, ComponentStoryObj } from '@storybook/react';
3+
4+
/**
5+
*
6+
*/
7+
const meta: ComponentMeta<typeof Toggle> = {
68
title: 'Toggle',
9+
component: Toggle,
10+
argTypes: {
11+
onChange: { action: 'change' },
12+
},
713
};
8-
export const ControlledWithKnobs = {
9-
render: () => (
10-
<Toggle
11-
label={text('label', 'Toggle Label')}
12-
required={boolean('required', false)}
13-
error={text('error', '')}
14-
checked={boolean('checked', false)}
15-
disabled={boolean('disabled', false)}
16-
onChange={action('change')}
17-
/>
18-
),
14+
export default meta;
15+
16+
/**
17+
*
18+
*/
19+
export const ControlledWithKnobs: ComponentStoryObj<typeof Toggle> = {
1920
name: 'Controlled with knobs',
21+
args: {
22+
label: 'Toggle Label',
23+
},
2024
parameters: {
21-
info: 'Toggle controlled with knobs',
25+
docs: {
26+
description: {
27+
story: 'Toggle controlled with knobs',
28+
},
29+
},
2230
},
2331
};
24-
export const Default = {
25-
render: () => <Toggle onChange={action('change')} />,
32+
33+
/**
34+
*
35+
*/
36+
export const Default: ComponentStoryObj<typeof Toggle> = {
37+
args: {},
2638
parameters: {
27-
info: 'Toggle control',
39+
docs: {
40+
description: {
41+
story: 'Toggle control',
42+
},
43+
},
2844
},
2945
};
30-
export const Checked = {
31-
render: () => <Toggle checked onChange={action('change')} />,
46+
47+
/**
48+
*
49+
*/
50+
export const Checked: ComponentStoryObj<typeof Toggle> = {
51+
args: {
52+
checked: true,
53+
},
3254
parameters: {
33-
info: 'Toggle control with checked status',
55+
docs: {
56+
description: {
57+
story: 'Toggle control with checked status',
58+
},
59+
},
3460
},
3561
};
36-
export const Disabled = {
37-
render: () => <Toggle disabled onChange={action('change')} />,
62+
63+
/**
64+
*
65+
*/
66+
export const Disabled: ComponentStoryObj<typeof Toggle> = {
67+
args: {
68+
disabled: true,
69+
},
3870
parameters: {
39-
info: 'Toggle control with disabled status',
71+
docs: {
72+
description: {
73+
story: 'Toggle control with disabled status',
74+
},
75+
},
4076
},
4177
};

0 commit comments

Comments
 (0)