|
1 | | -import React from 'react'; |
2 | | -import { action } from '@storybook/addon-actions'; |
3 | | -import { text, boolean } from '@storybook/addon-knobs'; |
4 | 1 | 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> = { |
6 | 8 | title: 'Toggle', |
| 9 | + component: Toggle, |
| 10 | + argTypes: { |
| 11 | + onChange: { action: 'change' }, |
| 12 | + }, |
7 | 13 | }; |
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> = { |
19 | 20 | name: 'Controlled with knobs', |
| 21 | + args: { |
| 22 | + label: 'Toggle Label', |
| 23 | + }, |
20 | 24 | parameters: { |
21 | | - info: 'Toggle controlled with knobs', |
| 25 | + docs: { |
| 26 | + description: { |
| 27 | + story: 'Toggle controlled with knobs', |
| 28 | + }, |
| 29 | + }, |
22 | 30 | }, |
23 | 31 | }; |
24 | | -export const Default = { |
25 | | - render: () => <Toggle onChange={action('change')} />, |
| 32 | + |
| 33 | +/** |
| 34 | + * |
| 35 | + */ |
| 36 | +export const Default: ComponentStoryObj<typeof Toggle> = { |
| 37 | + args: {}, |
26 | 38 | parameters: { |
27 | | - info: 'Toggle control', |
| 39 | + docs: { |
| 40 | + description: { |
| 41 | + story: 'Toggle control', |
| 42 | + }, |
| 43 | + }, |
28 | 44 | }, |
29 | 45 | }; |
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 | + }, |
32 | 54 | parameters: { |
33 | | - info: 'Toggle control with checked status', |
| 55 | + docs: { |
| 56 | + description: { |
| 57 | + story: 'Toggle control with checked status', |
| 58 | + }, |
| 59 | + }, |
34 | 60 | }, |
35 | 61 | }; |
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 | + }, |
38 | 70 | parameters: { |
39 | | - info: 'Toggle control with disabled status', |
| 71 | + docs: { |
| 72 | + description: { |
| 73 | + story: 'Toggle control with disabled status', |
| 74 | + }, |
| 75 | + }, |
40 | 76 | }, |
41 | 77 | }; |
0 commit comments