-
Notifications
You must be signed in to change notification settings - Fork 9
/
TextField.stories.tsx
118 lines (109 loc) · 2.66 KB
/
TextField.stories.tsx
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import { type StoryObj, type Meta } from "@storybook/react";
import TextField from "./TextField";
import React, { useState } from "react";
export default {
title: "Components/TextField",
component: TextField,
parameters: {
design: {
type: "figma",
url: "https://www.figma.com/file/p7LKna9JMU0JEkcKamzs53/%F0%9F%93%90-Syntax?node-id=1007%3A4103",
},
},
args: {
label: "Label",
placeholder: "Placeholder",
disabled: false,
errorText: "",
helperText: "",
size: "md",
type: "text",
"data-testid": "",
id: "",
value: "",
},
argTypes: {
autoComplete: {
options: ["current-password", "new-password", "off", "on", "email"],
control: { type: "select" },
},
disabled: {
control: "boolean",
},
placeholder: {
control: "text",
},
size: {
options: ["sm", "md", "lg"],
control: { type: "radio" },
},
type: {
options: [
"button",
"checkbox",
"color",
"date",
"datetime-local",
"email",
"file",
"hidden",
"image",
"month",
"number",
"password",
"radio",
"range",
"reset",
"search",
"submit",
"tel",
"text",
"time",
"url",
"week",
],
control: { type: "select" },
},
},
tags: ["autodocs"],
} as Meta<typeof TextField>;
function TextFieldDefault({
label = "Label",
placeholder = "Placeholder",
value: initialValue = "",
...rest
}) {
const [value, setValue] = useState("");
return (
<TextField
label={label}
placeholder={placeholder}
onChange={(event) => {
setValue(event.target.value);
}}
value={initialValue || value}
{...rest}
/>
);
}
export const Default: StoryObj<typeof TextField> = {
render: (args) => <TextFieldDefault {...args} />,
};
export const SizeSmClassicOnly: StoryObj<typeof TextField> = {
render: (args) => <TextFieldDefault size="sm" {...args} />,
};
export const SizeMd: StoryObj<typeof TextField> = {
render: (args) => <TextFieldDefault size="md" {...args} />,
};
export const SizeLgClassicOnly: StoryObj<typeof TextField> = {
render: (args) => <TextFieldDefault size="lg" {...args} />,
};
export const helperText: StoryObj<typeof TextField> = {
render: (args) => <TextFieldDefault helperText="Helper text" {...args} />,
};
export const ErrorText: StoryObj<typeof TextField> = {
render: (args) => <TextFieldDefault errorText="This is an error" {...args} />,
};
export const TypeNumber: StoryObj<typeof TextField> = {
render: (args) => <TextFieldDefault type="number" {...args} />,
};