-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathTextarea.stories.tsx
More file actions
80 lines (73 loc) · 2.1 KB
/
Textarea.stories.tsx
File metadata and controls
80 lines (73 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import React, { MouseEvent, useState } from 'react';
import { Textarea, Button, Input } from '../../src';
import { Meta, StoryObj } from '@storybook/react';
const meta: Meta<typeof Textarea> = {
title: 'Components/Textarea',
component: Textarea,
args: {
label: 'Can you provide more detail?',
hint: "Don't include personal or financial information, eg your National Insurance number or credit card details.",
id: 'more-detail',
name: 'more-detail',
rows: 5,
},
};
export default meta;
type Story = StoryObj<typeof Textarea>;
export const Standard: Story = {};
export const TextareaWithAutoCompleteAttribute: Story = {
args: {
autoComplete: 'street-address',
label: 'Full address',
id: 'textarea-with-autocomplete-attribute',
},
};
export const TextareaWithErrorBoolean: Story = {
render: function TextareaWithErrorBooleanRender() {
const [error, setError] = useState<boolean>(true);
return (
<>
<Textarea
error={error}
id="no-ni-reason"
name="no-ni-reason"
rows={5}
label="Why can't you provide a National Insurance number?"
/>
<Button
onClick={(e: MouseEvent<HTMLButtonElement>) => {
e.preventDefault();
setError(!error);
}}
>
Toggle Error
</Button>
</>
);
},
name: 'Textarea With Error (Boolean)',
};
export const TextareaWithErrorString: Story = {
render: function TextareaWithErrorStringRender() {
const [error, setError] = useState<string>('You must provide an explanation');
return (
<>
<Textarea
error={error}
id="no-ni-reason"
name="no-ni-reason"
rows={5}
label="Why can't you provide a National Insurance number?"
/>
<Input
id="no-ni-reason-input"
name="no-ni-reason-input"
label="Use this input to change the error message"
onChange={(e) => setError(e.currentTarget.value)}
value={error}
/>
</>
);
},
name: 'Textarea With Error (String)',
};