@idbrnd/design-system 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +388 -200
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# @idbrnd/design-system
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
3
8
|
React 기반 IDB 디자인 시스템 컴포넌트 라이브러리입니다.
|
|
4
9
|
|
|
5
10
|
## 설치
|
|
@@ -26,105 +31,171 @@ export default function App() {
|
|
|
26
31
|
}
|
|
27
32
|
```
|
|
28
33
|
|
|
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
|
-
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 컴포넌트
|
|
37
|
+
|
|
38
|
+
- [버튼](#버튼)
|
|
39
|
+
- [FillButton](#fillbutton)
|
|
40
|
+
- [OutlineButton](#outlinebutton)
|
|
41
|
+
- [TextButton](#textbutton)
|
|
42
|
+
- [WeakButton](#weakbutton)
|
|
43
|
+
- [아이콘 버튼](#아이콘-버튼)
|
|
44
|
+
- [BasicIconButton](#basiciconbutton)
|
|
45
|
+
- [FillIconButton](#filliconbutton)
|
|
46
|
+
- [OutlineIconButton](#outlineiconbutton)
|
|
47
|
+
- [입력](#입력)
|
|
48
|
+
- [Input](#input)
|
|
49
|
+
- [SearchBar](#searchbar)
|
|
50
|
+
- [컨트롤](#컨트롤)
|
|
51
|
+
- [CheckBox](#checkbox)
|
|
52
|
+
- [Radio](#radio)
|
|
53
|
+
- [ToggleSwitch](#toggleswitch)
|
|
54
|
+
- [피드백](#피드백)
|
|
55
|
+
- [Toast](#toast)
|
|
56
|
+
- [Snackbar](#snackbar)
|
|
57
|
+
- [PushBadge](#pushbadge)
|
|
58
|
+
- [Content](#content)
|
|
59
|
+
- [ContentBadge](#contentbadge)
|
|
60
|
+
- [StateBadge](#statebadge)
|
|
61
|
+
- [기타](#기타)
|
|
62
|
+
- [Spinner](#spinner)
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 버튼
|
|
67
|
+
|
|
68
|
+
### FillButton
|
|
56
69
|
|
|
57
70
|
```tsx
|
|
58
|
-
import {
|
|
59
|
-
FillButton,
|
|
60
|
-
OutlineButton,
|
|
61
|
-
TextButton,
|
|
62
|
-
WeakButton,
|
|
63
|
-
} from "@idbrnd/design-system";
|
|
71
|
+
import { FillButton } from "@idbrnd/design-system";
|
|
64
72
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
<FillButton variant="primary">저장</FillButton>
|
|
69
|
-
<OutlineButton variant="secondary">취소</OutlineButton>
|
|
70
|
-
<TextButton size="small" variant="assistive">
|
|
71
|
-
텍스트 버튼
|
|
72
|
-
</TextButton>
|
|
73
|
-
<WeakButton size="xsmall" variant="error">
|
|
74
|
-
삭제
|
|
75
|
-
</WeakButton>
|
|
76
|
-
</>
|
|
77
|
-
);
|
|
78
|
-
}
|
|
73
|
+
<FillButton variant="primary" size="large">저장</FillButton>
|
|
74
|
+
<FillButton variant="error" loading>삭제 중</FillButton>
|
|
75
|
+
<FillButton variant="primary" disabled>비활성화</FillButton>
|
|
79
76
|
```
|
|
80
77
|
|
|
81
|
-
|
|
78
|
+
| Prop | 타입 | 기본값 | 설명 |
|
|
79
|
+
|------|------|--------|------|
|
|
80
|
+
| `variant` | `"primary"` \| `"assistive"` \| `"error"` | `"primary"` | 색상 변형 |
|
|
81
|
+
| `size` | `"xsmall"` \| `"small"` \| `"medium"` \| `"large"` | `"medium"` | 크기 |
|
|
82
|
+
| `widthType` | `"hug"` \| `"fixed"` \| `"fill"` | `"hug"` | 너비 방식 |
|
|
83
|
+
| `loading` | `boolean` | `false` | 로딩 스피너 표시 |
|
|
84
|
+
| `disabled` | `boolean` | `false` | 비활성화 |
|
|
85
|
+
| `customStyle` | `CSSProperties` | — | 추가 인라인 스타일 |
|
|
86
|
+
|
|
87
|
+
### OutlineButton
|
|
82
88
|
|
|
83
89
|
```tsx
|
|
84
|
-
import {
|
|
85
|
-
BasicIconButton,
|
|
86
|
-
FillIconButton,
|
|
87
|
-
OutlineIconButton,
|
|
88
|
-
PushBadge,
|
|
89
|
-
} from "@idbrnd/design-system";
|
|
90
|
+
import { OutlineButton } from "@idbrnd/design-system";
|
|
90
91
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<BasicIconButton>+</BasicIconButton>
|
|
96
|
-
<PushBadge variant="dot" />
|
|
97
|
-
</div>
|
|
92
|
+
<OutlineButton variant="primary" size="large">확인</OutlineButton>
|
|
93
|
+
<OutlineButton variant="secondary">취소</OutlineButton>
|
|
94
|
+
<OutlineButton variant="assistive" loading>처리 중</OutlineButton>
|
|
95
|
+
```
|
|
98
96
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
| Prop | 타입 | 기본값 | 설명 |
|
|
98
|
+
|------|------|--------|------|
|
|
99
|
+
| `variant` | `"primary"` \| `"secondary"` \| `"assistive"` \| `"error"` | `"assistive"` | 색상 변형 |
|
|
100
|
+
| `size` | `"xsmall"` \| `"small"` \| `"medium"` \| `"large"` | `"medium"` | 크기 |
|
|
101
|
+
| `widthType` | `"hug"` \| `"fixed"` \| `"fill"` | `"hug"` | 너비 방식 |
|
|
102
|
+
| `loading` | `boolean` | `false` | 로딩 스피너 표시 |
|
|
103
|
+
| `disabled` | `boolean` | `false` | 비활성화 |
|
|
104
|
+
| `customStyle` | `CSSProperties` | — | 추가 인라인 스타일 |
|
|
102
105
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
106
|
+
### TextButton
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import { TextButton } from "@idbrnd/design-system";
|
|
110
|
+
|
|
111
|
+
<TextButton variant="primary">텍스트 버튼</TextButton>
|
|
112
|
+
<TextButton variant="assistive" size="small">작은 버튼</TextButton>
|
|
107
113
|
```
|
|
108
114
|
|
|
109
|
-
|
|
115
|
+
| Prop | 타입 | 기본값 | 설명 |
|
|
116
|
+
|------|------|--------|------|
|
|
117
|
+
| `variant` | `"primary"` \| `"assistive"` \| `"error"` | `"assistive"` | 색상 변형 |
|
|
118
|
+
| `size` | `"small"` \| `"medium"` \| `"large"` | `"medium"` | 크기 |
|
|
119
|
+
| `widthType` | `"hug"` \| `"fixed"` \| `"fill"` | `"hug"` | 너비 방식 |
|
|
120
|
+
| `loading` | `boolean` | `false` | 로딩 스피너 표시 |
|
|
121
|
+
| `disabled` | `boolean` | `false` | 비활성화 |
|
|
122
|
+
| `customStyle` | `CSSProperties` | — | 추가 인라인 스타일 |
|
|
123
|
+
|
|
124
|
+
### WeakButton
|
|
110
125
|
|
|
111
126
|
```tsx
|
|
112
|
-
import {
|
|
127
|
+
import { WeakButton } from "@idbrnd/design-system";
|
|
113
128
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
129
|
+
<WeakButton variant="primary">확인</WeakButton>
|
|
130
|
+
<WeakButton variant="error" size="xsmall">삭제</WeakButton>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
| Prop | 타입 | 기본값 | 설명 |
|
|
134
|
+
|------|------|--------|------|
|
|
135
|
+
| `variant` | `"primary"` \| `"assistive"` \| `"error"` | `"assistive"` | 색상 변형 |
|
|
136
|
+
| `size` | `"xsmall"` \| `"small"` \| `"medium"` \| `"large"` | `"medium"` | 크기 |
|
|
137
|
+
| `widthType` | `"hug"` \| `"fixed"` \| `"fill"` | `"hug"` | 너비 방식 |
|
|
138
|
+
| `loading` | `boolean` | `false` | 로딩 스피너 표시 |
|
|
139
|
+
| `disabled` | `boolean` | `false` | 비활성화 |
|
|
140
|
+
| `customStyle` | `CSSProperties` | — | 추가 인라인 스타일 |
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## 아이콘 버튼
|
|
145
|
+
|
|
146
|
+
### BasicIconButton
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
import { BasicIconButton } from "@idbrnd/design-system";
|
|
150
|
+
|
|
151
|
+
<BasicIconButton size="large"><SearchIcon /></BasicIconButton>
|
|
152
|
+
<BasicIconButton size="small" disabled><SearchIcon /></BasicIconButton>
|
|
123
153
|
```
|
|
124
154
|
|
|
125
|
-
|
|
155
|
+
| Prop | 타입 | 기본값 | 설명 |
|
|
156
|
+
|------|------|--------|------|
|
|
157
|
+
| `size` | `"small"` \| `"medium"` \| `"large"` | `"medium"` | 크기 |
|
|
158
|
+
| `disabled` | `boolean` | `false` | 비활성화 |
|
|
159
|
+
| `customStyle` | `CSSProperties` | — | 추가 인라인 스타일 |
|
|
126
160
|
|
|
127
|
-
|
|
161
|
+
### FillIconButton
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
import { FillIconButton } from "@idbrnd/design-system";
|
|
165
|
+
|
|
166
|
+
<FillIconButton variant="primary" size="large"><PlusIcon /></FillIconButton>
|
|
167
|
+
<FillIconButton variant="overlay"><PlusIcon /></FillIconButton>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
| Prop | 타입 | 기본값 | 설명 |
|
|
171
|
+
|------|------|--------|------|
|
|
172
|
+
| `variant` | `"primary"` \| `"basic"` \| `"overlay"` | `"primary"` | 색상 변형 |
|
|
173
|
+
| `size` | `"small"` \| `"medium"` \| `"large"` | `"medium"` | 크기 |
|
|
174
|
+
| `disabled` | `boolean` | `false` | 비활성화 |
|
|
175
|
+
| `customStyle` | `CSSProperties` | — | 추가 인라인 스타일 |
|
|
176
|
+
|
|
177
|
+
### OutlineIconButton
|
|
178
|
+
|
|
179
|
+
```tsx
|
|
180
|
+
import { OutlineIconButton } from "@idbrnd/design-system";
|
|
181
|
+
|
|
182
|
+
<OutlineIconButton size="large"><EditIcon /></OutlineIconButton>
|
|
183
|
+
<OutlineIconButton disabled><EditIcon /></OutlineIconButton>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
| Prop | 타입 | 기본값 | 설명 |
|
|
187
|
+
|------|------|--------|------|
|
|
188
|
+
| `size` | `"small"` \| `"medium"` \| `"large"` | `"medium"` | 크기 |
|
|
189
|
+
| `disabled` | `boolean` | `false` | 비활성화 |
|
|
190
|
+
| `customStyle` | `CSSProperties` | — | 추가 인라인 스타일 |
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## 입력
|
|
195
|
+
|
|
196
|
+
### Input
|
|
197
|
+
|
|
198
|
+
`value` + `onChange`를 받는 controlled 컴포넌트입니다.
|
|
128
199
|
|
|
129
200
|
```tsx
|
|
130
201
|
import { useState } from "react";
|
|
@@ -138,27 +209,37 @@ function InputExample() {
|
|
|
138
209
|
headingContent="이메일"
|
|
139
210
|
placeholder="이메일을 입력하세요"
|
|
140
211
|
value={email}
|
|
141
|
-
onChange={(
|
|
212
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
142
213
|
description="가입 안내 메일을 받을 주소입니다."
|
|
143
214
|
/>
|
|
144
215
|
);
|
|
145
216
|
}
|
|
146
217
|
```
|
|
147
218
|
|
|
148
|
-
|
|
219
|
+
| Prop | 타입 | 기본값 | 설명 |
|
|
220
|
+
|------|------|--------|------|
|
|
221
|
+
| `value` | `string` | — | **(필수)** 입력값 |
|
|
222
|
+
| `onChange` | `ChangeEventHandler` | — | **(필수)** 변경 핸들러 |
|
|
223
|
+
| `variant` | `"error"` \| `"success"` | — | 수동 상태 지정. 미지정 시 값 유무로 자동 결정 |
|
|
224
|
+
| `headingContent` | `ReactNode` | — | 상단 라벨 |
|
|
225
|
+
| `description` | `ReactNode \| boolean` | — | 하단 설명 텍스트 |
|
|
226
|
+
| `errorMessage` | `ReactNode` | — | `variant="error"` 시 표시되는 메시지 |
|
|
227
|
+
| `leadingIcon` | `ReactNode` | — | 입력 필드 좌측 아이콘 |
|
|
228
|
+
| `trailingContent` | `ReactNode` | — | 입력 필드 우측 콘텐츠 |
|
|
229
|
+
| `size` | `"small"` \| `"medium"` \| `"large"` | `"medium"` | 크기 |
|
|
230
|
+
| `width` | `number \| string` | `"100%"` | 너비 |
|
|
231
|
+
| `readOnly` | `boolean` | `false` | 읽기 전용 |
|
|
232
|
+
| `disabled` | `boolean` | `false` | 비활성화 |
|
|
233
|
+
| `customStyle` | `CSSProperties` | — | 추가 인라인 스타일 |
|
|
149
234
|
|
|
150
|
-
|
|
151
|
-
- `description`은 문자열뿐 아니라 JSX도 받을 수 있습니다. `variant="error"`일 때는 `description` 대신 `errorMessage`가 우선 노출됩니다.
|
|
152
|
-
- `errorMessage`도 문자열뿐 아니라 JSX를 받을 수 있습니다.
|
|
153
|
-
- `leadingIcon`, `headingContent`, `trailingContent`는 모두 JSX를 넣을 수 있습니다. 특히 `trailingContent`에는 버튼, 텍스트, 아이콘 조합 등 원하는 형태의 trailing UI를 구성할 수 있습니다.
|
|
154
|
-
- `width`는 `number | string`을 지원하며, 지정하지 않으면 기본값은 `100%`입니다.
|
|
235
|
+
유의사항:
|
|
155
236
|
- `variant`를 지정하지 않으면 값 존재 여부에 따라 내부적으로 `basic` 또는 `typed` 상태가 자동 적용됩니다.
|
|
237
|
+
- `variant="error"`일 때는 `description` 대신 `errorMessage`가 우선 노출됩니다.
|
|
238
|
+
- `defaultValue`는 지원하지 않습니다. 반드시 `value` + `onChange`로 제어해야 합니다.
|
|
156
239
|
|
|
157
|
-
###
|
|
240
|
+
### SearchBar
|
|
158
241
|
|
|
159
|
-
`
|
|
160
|
-
우측 삭제 버튼은 입력값이 있을 때만 표시되며, `onClear`를 전달하면 커스텀 삭제 동작을 사용할 수 있습니다.
|
|
161
|
-
`variant="default"`는 내부 `Input`의 `basic`에 매핑되며, `onTyping`/`typed`/`error`도 각각 대응됩니다.
|
|
242
|
+
`Enter` 입력 또는 우측 검색 버튼 클릭 시 `onSearch`를 호출합니다.
|
|
162
243
|
|
|
163
244
|
```tsx
|
|
164
245
|
import { useState } from "react";
|
|
@@ -170,20 +251,32 @@ function SearchExample() {
|
|
|
170
251
|
return (
|
|
171
252
|
<SearchBar
|
|
172
253
|
value={keyword}
|
|
173
|
-
onChange={(
|
|
174
|
-
onSearch={(value) =>
|
|
175
|
-
console.log("search:", value);
|
|
176
|
-
}}
|
|
254
|
+
onChange={(e) => setKeyword(e.target.value)}
|
|
255
|
+
onSearch={(value) => console.log("search:", value)}
|
|
177
256
|
placeholder="검색어를 입력하세요"
|
|
178
257
|
/>
|
|
179
258
|
);
|
|
180
259
|
}
|
|
181
260
|
```
|
|
182
261
|
|
|
183
|
-
|
|
262
|
+
| Prop | 타입 | 기본값 | 설명 |
|
|
263
|
+
|------|------|--------|------|
|
|
264
|
+
| `value` | `string` | — | **(필수)** 입력값 |
|
|
265
|
+
| `onChange` | `ChangeEventHandler` | — | **(필수)** 변경 핸들러 |
|
|
266
|
+
| `onSearch` | `(value: string) => void` | — | 검색 실행 콜백 |
|
|
267
|
+
| `onClear` | `() => void` | — | 삭제 버튼 클릭 콜백. 미지정 시 기본 동작 사용 |
|
|
268
|
+
| `size` | `"small"` \| `"medium"` \| `"large"` | `"medium"` | 크기 |
|
|
269
|
+
| `variant` | `"default"` \| `"onTyping"` \| `"typed"` \| `"error"` | — | 상태 변형 |
|
|
270
|
+
| `disabled` | `boolean` | `false` | 비활성화 |
|
|
271
|
+
| `customStyle` | `CSSProperties` | — | 추가 인라인 스타일 |
|
|
184
272
|
|
|
185
|
-
|
|
186
|
-
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## 컨트롤
|
|
276
|
+
|
|
277
|
+
### CheckBox
|
|
278
|
+
|
|
279
|
+
`checked` + `onChange`를 받는 controlled 컴포넌트입니다.
|
|
187
280
|
|
|
188
281
|
```tsx
|
|
189
282
|
import { useState } from "react";
|
|
@@ -191,40 +284,41 @@ import { CheckBox } from "@idbrnd/design-system";
|
|
|
191
284
|
|
|
192
285
|
function CheckBoxExample() {
|
|
193
286
|
const [checked, setChecked] = useState(false);
|
|
194
|
-
const [indeterminate, setIndeterminate] = useState(false);
|
|
195
287
|
|
|
196
288
|
return (
|
|
197
289
|
<>
|
|
198
|
-
{/* 기본 */}
|
|
199
290
|
<CheckBox checked={checked} onChange={(value) => setChecked(value)} />
|
|
200
291
|
|
|
201
292
|
{/* indeterminate: checked와 함께 사용 */}
|
|
202
|
-
<CheckBox
|
|
203
|
-
checked={indeterminate}
|
|
204
|
-
indeterminate={indeterminate}
|
|
205
|
-
onChange={(value) => setIndeterminate(value)}
|
|
206
|
-
/>
|
|
293
|
+
<CheckBox checked={true} indeterminate onChange={() => {}} />
|
|
207
294
|
|
|
208
295
|
{/* variant / size / density */}
|
|
209
|
-
<CheckBox variant="assistive" size="small" density="compact" checked />
|
|
296
|
+
<CheckBox variant="assistive" size="small" density="compact" checked onChange={() => {}} />
|
|
210
297
|
|
|
211
|
-
{/* disabled */}
|
|
212
298
|
<CheckBox checked disabled />
|
|
213
299
|
</>
|
|
214
300
|
);
|
|
215
301
|
}
|
|
216
302
|
```
|
|
217
303
|
|
|
218
|
-
|
|
304
|
+
| Prop | 타입 | 기본값 | 설명 |
|
|
305
|
+
|------|------|--------|------|
|
|
306
|
+
| `checked` | `boolean` | — | **(필수)** 체크 상태 |
|
|
307
|
+
| `onChange` | `(checked: boolean) => void` | — | 변경 핸들러 |
|
|
308
|
+
| `indeterminate` | `boolean` | `false` | `checked={true}`와 함께 사용 시 대시(–) 아이콘 표시 |
|
|
309
|
+
| `variant` | `"primary"` \| `"assistive"` | `"primary"` | 색상 변형 |
|
|
310
|
+
| `size` | `"medium"` \| `"small"` | `"medium"` | 크기 |
|
|
311
|
+
| `density` | `"default"` \| `"compact"` | `"default"` | wrapper 밀도 |
|
|
312
|
+
| `disabled` | `boolean` | `false` | 비활성화 |
|
|
313
|
+
| `customStyle` | `CSSProperties` | — | 추가 인라인 스타일 |
|
|
219
314
|
|
|
220
|
-
|
|
221
|
-
- `
|
|
222
|
-
- `density="compact"`은 wrapper 크기만 줄이며, 아이콘은
|
|
315
|
+
유의사항:
|
|
316
|
+
- `indeterminate={true}`는 `checked={true}`일 때만 대시 아이콘을 표시합니다.
|
|
317
|
+
- `density="compact"`은 wrapper 크기만 줄이며, 아이콘은 `size` 기준으로 그대로 표시됩니다.
|
|
223
318
|
|
|
224
|
-
###
|
|
319
|
+
### Radio
|
|
225
320
|
|
|
226
|
-
|
|
227
|
-
브라우저 기본 `name` 그룹 동작에 의존하지 않으며, `checked` prop으로 직접 선택 상태를 제어합니다.
|
|
321
|
+
그룹 내 단일 선택을 위한 controlled 컴포넌트입니다.
|
|
228
322
|
|
|
229
323
|
```tsx
|
|
230
324
|
import { useState } from "react";
|
|
@@ -236,10 +330,7 @@ function RadioGroupExample() {
|
|
|
236
330
|
return (
|
|
237
331
|
<>
|
|
238
332
|
{["A", "B", "C"].map((v) => (
|
|
239
|
-
<label
|
|
240
|
-
key={v}
|
|
241
|
-
style={{ display: "flex", alignItems: "center", gap: 6 }}
|
|
242
|
-
>
|
|
333
|
+
<label key={v} style={{ display: "flex", alignItems: "center", gap: 6 }}>
|
|
243
334
|
<Radio
|
|
244
335
|
name="group"
|
|
245
336
|
value={v}
|
|
@@ -254,15 +345,25 @@ function RadioGroupExample() {
|
|
|
254
345
|
}
|
|
255
346
|
```
|
|
256
347
|
|
|
257
|
-
|
|
348
|
+
| Prop | 타입 | 기본값 | 설명 |
|
|
349
|
+
|------|------|--------|------|
|
|
350
|
+
| `checked` | `boolean` | — | **(필수)** 선택 상태 |
|
|
351
|
+
| `onChange` | `(checked: boolean) => void` | — | 변경 핸들러 |
|
|
352
|
+
| `name` | `string` | — | input name 속성 |
|
|
353
|
+
| `value` | `string` | — | input value 속성 |
|
|
354
|
+
| `variant` | `"primary"` \| `"assistive"` | `"primary"` | 색상 변형 |
|
|
355
|
+
| `size` | `"medium"` \| `"small"` | `"medium"` | 크기 |
|
|
356
|
+
| `density` | `"default"` \| `"compact"` | `"default"` | wrapper 밀도 |
|
|
357
|
+
| `disabled` | `boolean` | `false` | 비활성화 |
|
|
358
|
+
| `customStyle` | `CSSProperties` | — | 추가 인라인 스타일 |
|
|
258
359
|
|
|
360
|
+
유의사항:
|
|
259
361
|
- `name`이 같아도 자동으로 하나만 선택되지 않습니다. `checked={selected === value}` 비교로 직접 제어해야 합니다.
|
|
260
|
-
- `onChange`는
|
|
261
|
-
- `variant`는 `"primary"(기본값)` | `"assistive"`를 지원합니다.
|
|
362
|
+
- `onChange`는 클릭 시 `true`가 전달됩니다. `isChecked && setSelected(v)` 패턴으로 true일 때만 state를 변경합니다.
|
|
262
363
|
|
|
263
|
-
###
|
|
364
|
+
### ToggleSwitch
|
|
264
365
|
|
|
265
|
-
`
|
|
366
|
+
`active` + `onChange`를 받는 controlled 컴포넌트입니다.
|
|
266
367
|
|
|
267
368
|
```tsx
|
|
268
369
|
import { useState } from "react";
|
|
@@ -274,107 +375,185 @@ function ToggleSwitchExample() {
|
|
|
274
375
|
return (
|
|
275
376
|
<>
|
|
276
377
|
<ToggleSwitch active={active} onChange={(value) => setActive(value)} />
|
|
277
|
-
|
|
278
|
-
{/* size */}
|
|
279
378
|
<ToggleSwitch size="small" active={active} onChange={setActive} />
|
|
280
|
-
<ToggleSwitch size="large" active={active} onChange={setActive} />
|
|
281
|
-
|
|
282
|
-
{/* disabled */}
|
|
283
379
|
<ToggleSwitch active disabled />
|
|
284
380
|
</>
|
|
285
381
|
);
|
|
286
382
|
}
|
|
287
383
|
```
|
|
288
384
|
|
|
289
|
-
|
|
385
|
+
| Prop | 타입 | 기본값 | 설명 |
|
|
386
|
+
|------|------|--------|------|
|
|
387
|
+
| `active` | `boolean` | — | **(필수)** 활성 상태 |
|
|
388
|
+
| `onChange` | `(active: boolean) => void` | — | 변경 핸들러 |
|
|
389
|
+
| `size` | `"small"` \| `"medium"` \| `"large"` | `"medium"` | 크기 |
|
|
390
|
+
| `disabled` | `boolean` | `false` | 비활성화 |
|
|
391
|
+
| `customStyle` | `CSSProperties` | — | 추가 인라인 스타일 |
|
|
290
392
|
|
|
393
|
+
유의사항:
|
|
291
394
|
- 체크 상태를 나타내는 prop 이름이 `checked`가 아닌 `active`입니다.
|
|
292
|
-
- `size`는 `"small"` | `"medium"(기본값)` | `"large"`를 지원합니다.
|
|
293
395
|
|
|
294
|
-
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
## 피드백
|
|
399
|
+
|
|
400
|
+
### Toast
|
|
401
|
+
|
|
402
|
+
`showToast` / `dismissToast`는 `document.body`에 포털을 생성하는 명령형 API입니다.
|
|
295
403
|
|
|
296
404
|
```tsx
|
|
297
|
-
import {
|
|
298
|
-
Spinner,
|
|
299
|
-
CustomSpinner,
|
|
300
|
-
Clip,
|
|
301
|
-
FadeSpinner,
|
|
302
|
-
} from "@idbrnd/design-system";
|
|
405
|
+
import { showToast, dismissToast } from "@idbrnd/design-system";
|
|
303
406
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
<Clip size={24} color="var(--semantic-primary-default)" />
|
|
310
|
-
<FadeSpinner width={4} height={12} />
|
|
311
|
-
</div>
|
|
312
|
-
);
|
|
313
|
-
}
|
|
407
|
+
showToast({ variant: "positive", message: "저장되었습니다." });
|
|
408
|
+
showToast({ variant: "negative", message: "오류가 발생했습니다." });
|
|
409
|
+
showToast({ variant: "basic", message: "알림 메시지입니다." });
|
|
410
|
+
|
|
411
|
+
dismissToast();
|
|
314
412
|
```
|
|
315
413
|
|
|
316
|
-
|
|
414
|
+
| 옵션 | 타입 | 설명 |
|
|
415
|
+
|------|------|------|
|
|
416
|
+
| `message` | `string` | **(필수)** 표시할 메시지 |
|
|
417
|
+
| `variant` | `"basic"` \| `"positive"` \| `"negative"` | 색상 변형 |
|
|
418
|
+
| `duration` | `number` | 자동 닫힘 시간(ms) |
|
|
419
|
+
|
|
420
|
+
### Snackbar
|
|
421
|
+
|
|
422
|
+
`showSnackbar` / `dismissSnackbar`는 `document.body`에 포털을 생성하는 명령형 API입니다.
|
|
317
423
|
|
|
318
424
|
```tsx
|
|
319
|
-
import {
|
|
425
|
+
import { showSnackbar, dismissSnackbar } from "@idbrnd/design-system";
|
|
320
426
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
</FillButton>
|
|
334
|
-
|
|
335
|
-
<FillButton variant="assistive" onClick={() => dismissToast()}>
|
|
336
|
-
Toast 닫기
|
|
337
|
-
</FillButton>
|
|
338
|
-
</>
|
|
339
|
-
);
|
|
340
|
-
}
|
|
427
|
+
showSnackbar({
|
|
428
|
+
variant: "basic",
|
|
429
|
+
heading: "Message deleted.",
|
|
430
|
+
description: "You can undo this action.",
|
|
431
|
+
actionLabel: "실행 취소",
|
|
432
|
+
onActionClick: () => console.log("undo"),
|
|
433
|
+
closeButton: true,
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
showSnackbar({ variant: "loading", heading: "처리 중..." });
|
|
437
|
+
|
|
438
|
+
dismissSnackbar();
|
|
341
439
|
```
|
|
342
440
|
|
|
343
|
-
|
|
441
|
+
| 옵션 | 타입 | 설명 |
|
|
442
|
+
|------|------|------|
|
|
443
|
+
| `heading` | `string` | **(필수)** 제목 텍스트 |
|
|
444
|
+
| `variant` | `"basic"` \| `"loading"` | 색상 변형 |
|
|
445
|
+
| `description` | `string` | 본문 텍스트 |
|
|
446
|
+
| `actionLabel` | `string` | 액션 버튼 레이블 |
|
|
447
|
+
| `onActionClick` | `() => void` | 액션 버튼 클릭 콜백 |
|
|
448
|
+
| `closeButton` | `boolean` | 닫기 버튼 표시 여부 |
|
|
449
|
+
|
|
450
|
+
### PushBadge
|
|
451
|
+
|
|
452
|
+
알림 뱃지 컴포넌트입니다.
|
|
344
453
|
|
|
345
454
|
```tsx
|
|
346
|
-
import {
|
|
347
|
-
FillButton,
|
|
348
|
-
showSnackbar,
|
|
349
|
-
dismissSnackbar,
|
|
350
|
-
} from "@idbrnd/design-system";
|
|
455
|
+
import { PushBadge } from "@idbrnd/design-system";
|
|
351
456
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
<FillButton
|
|
356
|
-
onClick={() =>
|
|
357
|
-
showSnackbar({
|
|
358
|
-
variant: "basic",
|
|
359
|
-
heading: "Message deleted.",
|
|
360
|
-
description: "You can undo this action.",
|
|
361
|
-
actionLabel: "실행 취소",
|
|
362
|
-
onActionClick: () => console.log("undo"),
|
|
363
|
-
closeButton: true,
|
|
364
|
-
})
|
|
365
|
-
}
|
|
366
|
-
>
|
|
367
|
-
Snackbar 열기
|
|
368
|
-
</FillButton>
|
|
369
|
-
|
|
370
|
-
<FillButton variant="assistive" onClick={() => dismissSnackbar()}>
|
|
371
|
-
Snackbar 닫기
|
|
372
|
-
</FillButton>
|
|
373
|
-
</>
|
|
374
|
-
);
|
|
375
|
-
}
|
|
457
|
+
<PushBadge variant="dot" />
|
|
458
|
+
<PushBadge variant="number" count={5} />
|
|
459
|
+
<PushBadge variant="info" />
|
|
376
460
|
```
|
|
377
461
|
|
|
462
|
+
| Prop | 타입 | 기본값 | 설명 |
|
|
463
|
+
|------|------|--------|------|
|
|
464
|
+
| `variant` | `"dot"` \| `"number"` \| `"info"` | — | **(필수)** 표시 형태 |
|
|
465
|
+
| `count` | `number` | — | `variant="number"` 시 표시할 숫자 |
|
|
466
|
+
| `customStyle` | `CSSProperties` | — | 추가 인라인 스타일 |
|
|
467
|
+
|
|
468
|
+
---
|
|
469
|
+
|
|
470
|
+
## Content
|
|
471
|
+
|
|
472
|
+
### ContentBadge
|
|
473
|
+
|
|
474
|
+
텍스트에 variant와 size를 적용하는 인라인 배지 컴포넌트입니다.
|
|
475
|
+
|
|
476
|
+
```tsx
|
|
477
|
+
import { ContentBadge } from "@idbrnd/design-system";
|
|
478
|
+
|
|
479
|
+
<ContentBadge variant="basic">기본</ContentBadge>
|
|
480
|
+
<ContentBadge variant="primary">주요</ContentBadge>
|
|
481
|
+
|
|
482
|
+
<ContentBadge size="default">default</ContentBadge>
|
|
483
|
+
<ContentBadge size="compact">compact</ContentBadge>
|
|
484
|
+
<ContentBadge size="compact-small">compact-small</ContentBadge>
|
|
485
|
+
|
|
486
|
+
{/* 커스텀 색상 */}
|
|
487
|
+
<ContentBadge contentColor="#6366f1" borderColor="#6366f1">커스텀</ContentBadge>
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
| Prop | 타입 | 기본값 | 설명 |
|
|
491
|
+
|------|------|--------|------|
|
|
492
|
+
| `variant` | `"basic"` \| `"primary"` | `"basic"` | 색상 변형 |
|
|
493
|
+
| `size` | `"default"` \| `"compact"` \| `"compact-small"` | `"default"` | 크기 |
|
|
494
|
+
| `contentColor` | `string` | — | 텍스트/아이콘 색상 오버라이드 |
|
|
495
|
+
| `backgroundColor` | `string` | — | 배경색 오버라이드 |
|
|
496
|
+
| `borderColor` | `string` | — | 테두리색 오버라이드 |
|
|
497
|
+
| `customStyle` | `CSSProperties` | — | 추가 인라인 스타일 |
|
|
498
|
+
| `className` | `string` | — | 추가 클래스명 |
|
|
499
|
+
| `children` | `ReactNode` | — | 배지 내용 |
|
|
500
|
+
|
|
501
|
+
### StateBadge
|
|
502
|
+
|
|
503
|
+
상태를 표시할 때 사용하는 배지 컴포넌트입니다. `stateIcon` prop으로 variant에 맞는 원형 dot을 표시할 수 있습니다.
|
|
504
|
+
|
|
505
|
+
```tsx
|
|
506
|
+
import { StateBadge } from "@idbrnd/design-system";
|
|
507
|
+
|
|
508
|
+
{/* variant */}
|
|
509
|
+
<StateBadge variant="basic">기본</StateBadge>
|
|
510
|
+
<StateBadge variant="error">오류</StateBadge>
|
|
511
|
+
<StateBadge variant="success">성공</StateBadge>
|
|
512
|
+
<StateBadge variant="info">정보</StateBadge>
|
|
513
|
+
<StateBadge variant="warning">경고</StateBadge>
|
|
514
|
+
|
|
515
|
+
{/* size */}
|
|
516
|
+
<StateBadge size="default">default</StateBadge>
|
|
517
|
+
<StateBadge size="compact">compact</StateBadge>
|
|
518
|
+
|
|
519
|
+
{/* stateIcon */}
|
|
520
|
+
<StateBadge variant="error" stateIcon>오류</StateBadge>
|
|
521
|
+
<StateBadge variant="success" stateIcon>성공</StateBadge>
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
| Prop | 타입 | 기본값 | 설명 |
|
|
525
|
+
|------|------|--------|------|
|
|
526
|
+
| `variant` | `"basic"` \| `"error"` \| `"success"` \| `"info"` \| `"warning"` | `"basic"` | 상태 색상 변형 |
|
|
527
|
+
| `size` | `"default"` \| `"compact"` | `"default"` | 크기 |
|
|
528
|
+
| `stateIcon` | `boolean` | `false` | `true`이면 variant 색상의 원형 dot 표시 |
|
|
529
|
+
| `customStyle` | `CSSProperties` | — | 추가 인라인 스타일 |
|
|
530
|
+
| `className` | `string` | — | 추가 클래스명 |
|
|
531
|
+
| `children` | `ReactNode` | — | 배지 내용 |
|
|
532
|
+
|
|
533
|
+
---
|
|
534
|
+
|
|
535
|
+
## 기타
|
|
536
|
+
|
|
537
|
+
### Spinner
|
|
538
|
+
|
|
539
|
+
```tsx
|
|
540
|
+
import { Spinner, CustomSpinner, Clip, FadeSpinner } from "@idbrnd/design-system";
|
|
541
|
+
|
|
542
|
+
<Spinner />
|
|
543
|
+
<CustomSpinner size={12} />
|
|
544
|
+
<Clip size={24} color="var(--semantic-primary-default)" />
|
|
545
|
+
<FadeSpinner width={4} height={12} />
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
| 컴포넌트 | 주요 Props | 설명 |
|
|
549
|
+
|----------|-----------|------|
|
|
550
|
+
| `Spinner` | — | 기본 스피너 |
|
|
551
|
+
| `CustomSpinner` | `size` | 크기 조정 가능한 스피너 |
|
|
552
|
+
| `Clip` | `size`, `color` | 원형 클립 스피너 |
|
|
553
|
+
| `FadeSpinner` | `width`, `height`, `color` | 페이드 인/아웃 스피너 |
|
|
554
|
+
|
|
555
|
+
---
|
|
556
|
+
|
|
378
557
|
## TypeScript
|
|
379
558
|
|
|
380
559
|
모든 컴포넌트의 Props 타입을 패키지에서 직접 import 할 수 있습니다.
|
|
@@ -394,9 +573,18 @@ import type {
|
|
|
394
573
|
ToggleSwitchProps,
|
|
395
574
|
ToggleSwitchSize,
|
|
396
575
|
ToastShowOptions,
|
|
576
|
+
SnackbarShowOptions,
|
|
577
|
+
ContentBadgeProps,
|
|
578
|
+
ContentBadgeVariant,
|
|
579
|
+
ContentBadgeSize,
|
|
580
|
+
StateBadgeProps,
|
|
581
|
+
StateBadgeVariant,
|
|
582
|
+
StateBadgeSize,
|
|
397
583
|
} from "@idbrnd/design-system";
|
|
398
584
|
```
|
|
399
585
|
|
|
586
|
+
---
|
|
587
|
+
|
|
400
588
|
## 주의사항
|
|
401
589
|
|
|
402
590
|
- `Input`, `SearchBar`, `CheckBox`, `Radio`, `ToggleSwitch`는 controlled 방식으로 사용해야 합니다.
|