Skip to content

Commit ed28471

Browse files
committed
feat(#52): TextField Storybook 생성
1 parent 4b04dc1 commit ed28471

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
import { useState } from "react";
3+
4+
import { TextField } from "./TextField";
5+
6+
const meta: Meta<typeof TextField> = {
7+
title: "Components/TextField",
8+
component: TextField,
9+
tags: ["autodocs"],
10+
args: {
11+
title: "Title",
12+
placeholder: "텍스트를 입력해 주세요.",
13+
helperText: "보조 메세지입니다.",
14+
disabled: false,
15+
},
16+
argTypes: {
17+
value: {
18+
control: "text",
19+
},
20+
status: {
21+
control: "select",
22+
options: ["inactive", "negative"],
23+
},
24+
helperText: {
25+
control: "text",
26+
},
27+
placeholder: {
28+
control: "text",
29+
},
30+
disabled: {
31+
control: "boolean",
32+
},
33+
onChange: { action: "changed" },
34+
},
35+
};
36+
37+
export default meta;
38+
39+
type Story = StoryObj<typeof TextField>;
40+
41+
export const Inactive: Story = {
42+
render: args => <TextFieldWithHooks {...args} />,
43+
};
44+
45+
export const Negative: Story = {
46+
render: args => <TextFieldWithHooks {...args} />,
47+
args: {
48+
status: "negative",
49+
value: "텍스트를 입력해 주세요.",
50+
helperText: "에러 메시지입니다.",
51+
},
52+
};
53+
54+
const TextFieldWithHooks = (args: React.ComponentProps<typeof TextField>) => {
55+
const [value, setValue] = useState(args.value ?? "");
56+
57+
return (
58+
<TextField
59+
{...args}
60+
value={value}
61+
onChange={e => setValue(e.target.value)}
62+
/>
63+
);
64+
};

0 commit comments

Comments
 (0)