Skip to content

Commit cd73567

Browse files
committed
adjust textarea story as csf3
1 parent 756f1db commit cd73567

File tree

1 file changed

+100
-47
lines changed

1 file changed

+100
-47
lines changed

stories/Textarea.stories.tsx

Lines changed: 100 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,123 @@
1-
import React from 'react';
2-
import { action } from '@storybook/addon-actions';
3-
import { text, boolean } from '@storybook/addon-knobs';
41
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> = {
68
title: 'Textarea',
9+
component: Textarea,
10+
argTypes: {
11+
onChange: { action: 'change' },
12+
onBlur: { action: 'blur' },
13+
},
714
};
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> = {
2221
name: 'Controlled with knobs',
22+
args: {
23+
label: 'Textarea Label',
24+
},
2325
parameters: {
24-
info: 'Textarea controlled with knobs',
26+
docs: {
27+
description: {
28+
story: 'Textarea controlled with knobs',
29+
},
30+
},
2531
},
2632
};
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+
},
3142
parameters: {
32-
info: 'Default Textarea control',
43+
docs: {
44+
description: {
45+
story: 'Default Textarea control',
46+
},
47+
},
3348
},
3449
};
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+
},
3960
parameters: {
40-
info: 'Textarea control with required attribute',
61+
docs: {
62+
description: {
63+
story: 'Textarea control with required attribute',
64+
},
65+
},
4166
},
4267
};
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+
},
5279
parameters: {
53-
info: 'Textarea control with error message',
80+
docs: {
81+
description: {
82+
story: 'Textarea control with error message',
83+
},
84+
},
5485
},
5586
};
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+
},
6097
parameters: {
61-
info: 'Textarea control with disabled status',
98+
docs: {
99+
description: {
100+
story: 'Textarea control with disabled status',
101+
},
102+
},
62103
},
63104
};
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> = {
66110
name: 'Read only',
111+
args: {
112+
label: 'Textarea Label',
113+
value: 'Read Only',
114+
readOnly: true,
115+
},
67116
parameters: {
68-
info: 'Textarea control with readOnly status',
117+
docs: {
118+
description: {
119+
story: 'Textarea control with readOnly status',
120+
},
121+
},
69122
},
70123
};

0 commit comments

Comments
 (0)