|
1 | 1 | import React from 'react'; |
2 | | -import { action } from '@storybook/addon-actions'; |
3 | | -import { select } from '@storybook/addon-knobs'; |
4 | 2 | import { SalesPath } from '../src/scripts'; |
5 | | -export default { |
| 3 | +import { ComponentMeta, ComponentStoryObj } from '@storybook/react'; |
| 4 | + |
| 5 | +/** |
| 6 | + * |
| 7 | + */ |
| 8 | +const meta: ComponentMeta<typeof SalesPath> = { |
6 | 9 | title: 'SalesPath', |
| 10 | + component: SalesPath, |
| 11 | + subcomponents: { SalesPathItem: SalesPath.PathItem }, |
| 12 | + argTypes: { |
| 13 | + onSelect: { action: 'select' }, |
| 14 | + }, |
7 | 15 | }; |
8 | | -export const ControlledWithKnobs = { |
9 | | - render: () => { |
10 | | - const activeKey = select( |
11 | | - 'activeKey', |
12 | | - { |
13 | | - 1: '1', |
14 | | - 2: '2', |
15 | | - 3: '3', |
16 | | - 4: '4', |
17 | | - 5: '5', |
| 16 | +export default meta; |
| 17 | + |
| 18 | +/** |
| 19 | + * |
| 20 | + */ |
| 21 | +export const ControlledWithKnobs: ComponentStoryObj<typeof SalesPath> = { |
| 22 | + render: (args) => ( |
| 23 | + <SalesPath {...args}> |
| 24 | + <SalesPath.PathItem eventKey='1' title='Contacted' /> |
| 25 | + <SalesPath.PathItem eventKey='2' title='Open' /> |
| 26 | + <SalesPath.PathItem eventKey='3' title='Unqualified' /> |
| 27 | + <SalesPath.PathItem eventKey='4' title='Nurturing' /> |
| 28 | + <SalesPath.PathItem eventKey='5' title='Closed' /> |
| 29 | + </SalesPath> |
| 30 | + ), |
| 31 | + name: 'Controlled with knobs', |
| 32 | + args: { |
| 33 | + activeKey: '1', |
| 34 | + }, |
| 35 | + argTypes: { |
| 36 | + activeKey: { |
| 37 | + control: { |
| 38 | + type: 'select', |
| 39 | + options: ['1', '2', '3', '4', '5'], |
18 | 40 | }, |
19 | | - '1' |
20 | | - ); |
21 | | - return ( |
22 | | - <SalesPath activeKey={activeKey} onSelect={action('onSelect')}> |
23 | | - <SalesPath.PathItem eventKey='1' title='Contacted' /> |
24 | | - <SalesPath.PathItem eventKey='2' title='Open' /> |
25 | | - <SalesPath.PathItem eventKey='3' title='Unqualified' /> |
26 | | - <SalesPath.PathItem eventKey='4' title='Nurturing' /> |
27 | | - <SalesPath.PathItem eventKey='5' title='Closed' /> |
28 | | - </SalesPath> |
29 | | - ); |
| 41 | + }, |
30 | 42 | }, |
31 | | - name: 'Controlled with knobs', |
32 | 43 | parameters: { |
33 | | - info: 'Sales Path controlled with knobs', |
| 44 | + docs: { |
| 45 | + description: { |
| 46 | + story: 'Sales Path controlled with knobs', |
| 47 | + }, |
| 48 | + }, |
34 | 49 | }, |
35 | 50 | }; |
36 | | -export const Default = { |
37 | | - render: () => { |
38 | | - return ( |
39 | | - <SalesPath activeKey='3' onSelect={action('onSelect')}> |
40 | | - <SalesPath.PathItem eventKey='1' title='Contacted' /> |
41 | | - <SalesPath.PathItem eventKey='2' title='Open' /> |
42 | | - <SalesPath.PathItem eventKey='3' title='Unqualified' /> |
43 | | - <SalesPath.PathItem eventKey='4' title='Nurturing' /> |
44 | | - <SalesPath.PathItem eventKey='5' title='Closed' /> |
45 | | - </SalesPath> |
46 | | - ); |
| 51 | + |
| 52 | +/** |
| 53 | + * |
| 54 | + */ |
| 55 | +export const Default: ComponentStoryObj<typeof SalesPath> = { |
| 56 | + ...ControlledWithKnobs, |
| 57 | + name: 'Default', |
| 58 | + args: { |
| 59 | + activeKey: '3', |
47 | 60 | }, |
48 | 61 | parameters: { |
49 | | - info: 'Sales Path', |
| 62 | + docs: { |
| 63 | + description: { |
| 64 | + story: 'Sales Path', |
| 65 | + }, |
| 66 | + }, |
50 | 67 | }, |
51 | 68 | }; |
0 commit comments