|
| 1 | +import { TextField } from '@shared/ui/TextField/TextField'; |
| 2 | +import type { Meta, StoryObj } from '@storybook/react-vite'; |
| 3 | + |
| 4 | +const meta = { |
| 5 | + title: 'Shared/UI/TextField', |
| 6 | + component: TextField, |
| 7 | + parameters: { |
| 8 | + layout: 'centered', |
| 9 | + }, |
| 10 | + tags: ['autodocs'], |
| 11 | + argTypes: { |
| 12 | + type: { |
| 13 | + control: 'select', |
| 14 | + options: ['text', 'char', 'textarea', 'price'], |
| 15 | + description: 'TextField type', |
| 16 | + }, |
| 17 | + label: { control: 'text' }, |
| 18 | + placeholder: { control: 'text' }, |
| 19 | + disabled: { control: 'boolean' }, |
| 20 | + error: { control: 'boolean' }, |
| 21 | + helperText: { control: 'text' }, |
| 22 | + showCharacterCount: { control: 'boolean' }, |
| 23 | + value: { control: 'text' }, |
| 24 | + defaultValue: { control: 'text' }, |
| 25 | + }, |
| 26 | +} satisfies Meta<typeof TextField>; |
| 27 | + |
| 28 | +export default meta; |
| 29 | +type Story = StoryObj<typeof meta>; |
| 30 | + |
| 31 | +export const Showcase: Story = { |
| 32 | + name: 'Playground Showcase (9)', |
| 33 | + render: () => ( |
| 34 | + <div className="flex flex-wrap gap-10"> |
| 35 | + {/* Char Field */} |
| 36 | + <div className="flex flex-col gap-4"> |
| 37 | + <h3 className="typo-caption-1 font-semibold">Char Field</h3> |
| 38 | + |
| 39 | + <div className="w-127.25"> |
| 40 | + <TextField |
| 41 | + type="char" |
| 42 | + label="Char Field" |
| 43 | + placeholder="Enter your username" |
| 44 | + showCharacterCount |
| 45 | + helperText="Default" |
| 46 | + /> |
| 47 | + </div> |
| 48 | + |
| 49 | + <div className="w-127.25"> |
| 50 | + <TextField |
| 51 | + type="char" |
| 52 | + label="Char Field" |
| 53 | + placeholder="Enter your username" |
| 54 | + showCharacterCount |
| 55 | + error |
| 56 | + helperText="Error" |
| 57 | + /> |
| 58 | + </div> |
| 59 | + |
| 60 | + <div className="w-127.25"> |
| 61 | + <TextField |
| 62 | + type="char" |
| 63 | + label="Char Field" |
| 64 | + placeholder="Enter your username" |
| 65 | + showCharacterCount |
| 66 | + disabled |
| 67 | + helperText="Disabled" |
| 68 | + /> |
| 69 | + </div> |
| 70 | + </div> |
| 71 | + |
| 72 | + {/* TextArea Field */} |
| 73 | + <div className="flex flex-col gap-4"> |
| 74 | + <h3 className="typo-caption-1 font-semibold">TextArea Field</h3> |
| 75 | + |
| 76 | + <div className="w-127.25"> |
| 77 | + <TextField |
| 78 | + type="textarea" |
| 79 | + label="TextArea Field" |
| 80 | + placeholder="Enter a description" |
| 81 | + showCharacterCount |
| 82 | + helperText="Default" |
| 83 | + /> |
| 84 | + </div> |
| 85 | + |
| 86 | + <div className="w-127.25"> |
| 87 | + <TextField |
| 88 | + type="textarea" |
| 89 | + label="TextArea Field" |
| 90 | + placeholder="Enter a description" |
| 91 | + showCharacterCount |
| 92 | + error |
| 93 | + helperText="Error" |
| 94 | + /> |
| 95 | + </div> |
| 96 | + |
| 97 | + <div className="w-127.25"> |
| 98 | + <TextField |
| 99 | + type="textarea" |
| 100 | + label="TextArea Field" |
| 101 | + placeholder="Enter a description" |
| 102 | + showCharacterCount |
| 103 | + disabled |
| 104 | + helperText="Disabled" |
| 105 | + /> |
| 106 | + </div> |
| 107 | + </div> |
| 108 | + |
| 109 | + {/* Price Field */} |
| 110 | + <div className="flex flex-col gap-4"> |
| 111 | + <h3 className="typo-caption-1 font-semibold">Price Field</h3> |
| 112 | + |
| 113 | + <div className="w-127.25"> |
| 114 | + <TextField |
| 115 | + type="price" |
| 116 | + label="Price Field" |
| 117 | + placeholder="Enter price" |
| 118 | + defaultValue="10000" |
| 119 | + helperText="Default" |
| 120 | + /> |
| 121 | + </div> |
| 122 | + |
| 123 | + <div className="w-127.25"> |
| 124 | + <TextField |
| 125 | + type="price" |
| 126 | + label="Price Field" |
| 127 | + placeholder="Enter price" |
| 128 | + defaultValue="10000" |
| 129 | + error |
| 130 | + helperText="Error" |
| 131 | + /> |
| 132 | + </div> |
| 133 | + |
| 134 | + <div className="w-127.25"> |
| 135 | + <TextField |
| 136 | + type="price" |
| 137 | + label="Price Field" |
| 138 | + placeholder="Enter price" |
| 139 | + defaultValue="10000" |
| 140 | + disabled |
| 141 | + helperText="Disabled" |
| 142 | + /> |
| 143 | + </div> |
| 144 | + </div> |
| 145 | + </div> |
| 146 | + ), |
| 147 | +}; |
| 148 | + |
| 149 | +/** |
| 150 | + * (옵션) 단일 스토리들도 기본적인 확인용으로 남겨두고 싶으면 최소만 유지 |
| 151 | + */ |
| 152 | +export const CharDefault: Story = { |
| 153 | + args: { |
| 154 | + type: 'char', |
| 155 | + label: 'Char Field', |
| 156 | + placeholder: 'Enter your username', |
| 157 | + showCharacterCount: true, |
| 158 | + helperText: 'Default', |
| 159 | + }, |
| 160 | +}; |
| 161 | + |
| 162 | +export const TextareaDefault: Story = { |
| 163 | + args: { |
| 164 | + type: 'textarea', |
| 165 | + label: 'TextArea Field', |
| 166 | + placeholder: 'Enter a description', |
| 167 | + showCharacterCount: true, |
| 168 | + helperText: 'Default', |
| 169 | + }, |
| 170 | +}; |
| 171 | + |
| 172 | +export const PriceDefault: Story = { |
| 173 | + args: { |
| 174 | + type: 'price', |
| 175 | + label: 'Price Field', |
| 176 | + placeholder: 'Enter price', |
| 177 | + defaultValue: '10000', |
| 178 | + helperText: 'Default', |
| 179 | + }, |
| 180 | +}; |
0 commit comments