|
1 | | -import React from 'react'; |
2 | | -import { action } from '@storybook/addon-actions'; |
3 | | -import { text, boolean } from '@storybook/addon-knobs'; |
4 | 1 | import { Textarea } from '../src/scripts'; |
5 | | -export default { |
| 2 | +import { ComponentMeta, ComponentStoryObj } from '@storybook/react'; |
| 3 | + |
| 4 | +/** |
| 5 | + * |
| 6 | + */ |
| 7 | +const meta: ComponentMeta<typeof Textarea> = { |
6 | 8 | title: 'Textarea', |
| 9 | + component: Textarea, |
| 10 | + argTypes: { |
| 11 | + onChange: { action: 'change' }, |
| 12 | + onBlur: { action: 'blur' }, |
| 13 | + }, |
7 | 14 | }; |
8 | | -export const ControlledWithKnobs = { |
9 | | - render: () => ( |
10 | | - <Textarea |
11 | | - label={text('label', 'Textarea Label')} |
12 | | - error={text('error', '')} |
13 | | - required={boolean('required', false)} |
14 | | - value={text('value', '')} |
15 | | - placeholder={text('placeholder', '')} |
16 | | - disabled={boolean('disabled', false)} |
17 | | - readOnly={boolean('readOnly', false)} |
18 | | - onChange={action('change')} |
19 | | - onBlur={action('blur')} |
20 | | - /> |
21 | | - ), |
| 15 | +export default meta; |
| 16 | + |
| 17 | +/** |
| 18 | + * |
| 19 | + */ |
| 20 | +export const ControlledWithKnobs: ComponentStoryObj<typeof Textarea> = { |
22 | 21 | name: 'Controlled with knobs', |
| 22 | + args: { |
| 23 | + label: 'Textarea Label', |
| 24 | + }, |
23 | 25 | parameters: { |
24 | | - info: 'Textarea controlled with knobs', |
| 26 | + docs: { |
| 27 | + description: { |
| 28 | + story: 'Textarea controlled with knobs', |
| 29 | + }, |
| 30 | + }, |
25 | 31 | }, |
26 | 32 | }; |
27 | | -export const Default = { |
28 | | - render: () => ( |
29 | | - <Textarea label='Textarea Label' placeholder='Placeholder Text' /> |
30 | | - ), |
| 33 | + |
| 34 | +/** |
| 35 | + * |
| 36 | + */ |
| 37 | +export const Default: ComponentStoryObj<typeof Textarea> = { |
| 38 | + args: { |
| 39 | + label: 'Textarea Label', |
| 40 | + placeholder: 'Placeholder', |
| 41 | + }, |
31 | 42 | parameters: { |
32 | | - info: 'Default Textarea control', |
| 43 | + docs: { |
| 44 | + description: { |
| 45 | + story: 'Default Textarea control', |
| 46 | + }, |
| 47 | + }, |
33 | 48 | }, |
34 | 49 | }; |
35 | | -export const Required = { |
36 | | - render: () => ( |
37 | | - <Textarea label='Textarea Label' placeholder='Placeholder Text' required /> |
38 | | - ), |
| 50 | + |
| 51 | +/** |
| 52 | + * |
| 53 | + */ |
| 54 | +export const Required: ComponentStoryObj<typeof Textarea> = { |
| 55 | + args: { |
| 56 | + label: 'Textarea Label', |
| 57 | + placeholder: 'Placeholder', |
| 58 | + required: true, |
| 59 | + }, |
39 | 60 | parameters: { |
40 | | - info: 'Textarea control with required attribute', |
| 61 | + docs: { |
| 62 | + description: { |
| 63 | + story: 'Textarea control with required attribute', |
| 64 | + }, |
| 65 | + }, |
41 | 66 | }, |
42 | 67 | }; |
43 | | -export const Error = { |
44 | | - render: () => ( |
45 | | - <Textarea |
46 | | - label='Textarea Label' |
47 | | - placeholder='Placeholder Text' |
48 | | - required |
49 | | - error='This field is required' |
50 | | - /> |
51 | | - ), |
| 68 | + |
| 69 | +/** |
| 70 | + * |
| 71 | + */ |
| 72 | +export const Error: ComponentStoryObj<typeof Textarea> = { |
| 73 | + args: { |
| 74 | + label: 'Textarea Label', |
| 75 | + placeholder: 'Placeholder', |
| 76 | + required: true, |
| 77 | + error: 'This field is required', |
| 78 | + }, |
52 | 79 | parameters: { |
53 | | - info: 'Textarea control with error message', |
| 80 | + docs: { |
| 81 | + description: { |
| 82 | + story: 'Textarea control with error message', |
| 83 | + }, |
| 84 | + }, |
54 | 85 | }, |
55 | 86 | }; |
56 | | -export const Disabled = { |
57 | | - render: () => ( |
58 | | - <Textarea label='Textarea Label' placeholder='Placeholder Text' disabled /> |
59 | | - ), |
| 87 | + |
| 88 | +/** |
| 89 | + * |
| 90 | + */ |
| 91 | +export const Disabled: ComponentStoryObj<typeof Textarea> = { |
| 92 | + args: { |
| 93 | + label: 'Textarea Label', |
| 94 | + placeholder: 'Placeholder', |
| 95 | + disabled: true, |
| 96 | + }, |
60 | 97 | parameters: { |
61 | | - info: 'Textarea control with disabled status', |
| 98 | + docs: { |
| 99 | + description: { |
| 100 | + story: 'Textarea control with disabled status', |
| 101 | + }, |
| 102 | + }, |
62 | 103 | }, |
63 | 104 | }; |
64 | | -export const ReadOnly = { |
65 | | - render: () => <Textarea label='Textarea Label' value='Read Only' readOnly />, |
| 105 | + |
| 106 | +/** |
| 107 | + * |
| 108 | + */ |
| 109 | +export const ReadOnly: ComponentStoryObj<typeof Textarea> = { |
66 | 110 | name: 'Read only', |
| 111 | + args: { |
| 112 | + label: 'Textarea Label', |
| 113 | + value: 'Read Only', |
| 114 | + readOnly: true, |
| 115 | + }, |
67 | 116 | parameters: { |
68 | | - info: 'Textarea control with readOnly status', |
| 117 | + docs: { |
| 118 | + description: { |
| 119 | + story: 'Textarea control with readOnly status', |
| 120 | + }, |
| 121 | + }, |
69 | 122 | }, |
70 | 123 | }; |
0 commit comments