File tree Expand file tree Collapse file tree 1 file changed +64
-0
lines changed
src/components/ui/TextField Expand file tree Collapse file tree 1 file changed +64
-0
lines changed Original file line number Diff line number Diff line change 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+ } ;
You can’t perform that action at this time.
0 commit comments