@idbrnd/design-system 1.7.0 → 1.7.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 +188 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,6 +63,11 @@ export default function App() {
|
|
|
63
63
|
- [AvatarStack](#avatarstack)
|
|
64
64
|
- [ContentBadge](#contentbadge)
|
|
65
65
|
- [StateBadge](#statebadge)
|
|
66
|
+
- [Chip](#chip)
|
|
67
|
+
- [Chip](#chip-1)
|
|
68
|
+
- [ChipGroup](#chipgroup)
|
|
69
|
+
- [FilterChip](#filterchip)
|
|
70
|
+
- [FilterBar](#filterbar)
|
|
66
71
|
- [기타](#기타)
|
|
67
72
|
- [Spinner](#spinner)
|
|
68
73
|
|
|
@@ -918,6 +923,189 @@ import { StateBadge } from "@idbrnd/design-system";
|
|
|
918
923
|
|
|
919
924
|
---
|
|
920
925
|
|
|
926
|
+
## Chip
|
|
927
|
+
|
|
928
|
+
`Chip`, `ChipGroup`, `FilterChip`, `FilterBar` 4개의 컴포넌트로 구성됩니다.
|
|
929
|
+
|
|
930
|
+
### Chip
|
|
931
|
+
|
|
932
|
+
기본 칩 버튼 컴포넌트입니다.
|
|
933
|
+
|
|
934
|
+
```tsx
|
|
935
|
+
import { Chip } from "@idbrnd/design-system";
|
|
936
|
+
|
|
937
|
+
// 기본
|
|
938
|
+
<Chip>텍스트</Chip>
|
|
939
|
+
|
|
940
|
+
// variant + selected
|
|
941
|
+
<Chip variant="fill" selected>선택됨</Chip>
|
|
942
|
+
|
|
943
|
+
// 아이콘 포함
|
|
944
|
+
<Chip
|
|
945
|
+
leadingSlot={<img src="/icon.svg" width={16} height={16} alt="" />}
|
|
946
|
+
trailingSlot={<img src="/close.svg" width={16} height={16} alt="" />}
|
|
947
|
+
>
|
|
948
|
+
검색어
|
|
949
|
+
</Chip>
|
|
950
|
+
|
|
951
|
+
// 클릭 핸들러
|
|
952
|
+
<Chip variant="outline" selected={isSelected} onClick={() => setIsSelected(p => !p)}>
|
|
953
|
+
토글
|
|
954
|
+
</Chip>
|
|
955
|
+
```
|
|
956
|
+
|
|
957
|
+
| Prop | Type | Default | Description |
|
|
958
|
+
|------|------|---------|-------------|
|
|
959
|
+
| `variant` | `"fillWeak" \| "fill" \| "outline" \| "outlineSurface"` | `"outline"` | 칩 스타일 |
|
|
960
|
+
| `size` | `"large" \| "medium" \| "small" \| "xsmall"` | `"medium"` | 칩 크기 |
|
|
961
|
+
| `selected` | `boolean` | `false` | 선택 상태 |
|
|
962
|
+
| `disabled` | `boolean` | `false` | 비활성화 |
|
|
963
|
+
| `leadingSlot` | `ReactNode` | — | 텍스트 왼쪽 콘텐츠 |
|
|
964
|
+
| `trailingSlot` | `ReactNode` | — | 텍스트 오른쪽 콘텐츠 |
|
|
965
|
+
| `onClick` | `MouseEventHandler` | — | 클릭 핸들러 |
|
|
966
|
+
| `customStyle` | `CSSProperties` | — | 루트 엘리먼트 인라인 스타일 |
|
|
967
|
+
|
|
968
|
+
---
|
|
969
|
+
|
|
970
|
+
### ChipGroup
|
|
971
|
+
|
|
972
|
+
여러 `Chip`을 묶어서 표시하는 컨테이너입니다.
|
|
973
|
+
|
|
974
|
+
```tsx
|
|
975
|
+
import { Chip, ChipGroup } from "@idbrnd/design-system";
|
|
976
|
+
|
|
977
|
+
// selection — 줄바꿈 다중 선택
|
|
978
|
+
const [selected, setSelected] = useState<DropdownOption[]>([]);
|
|
979
|
+
|
|
980
|
+
function toggle(prev: DropdownOption[], item: DropdownOption) {
|
|
981
|
+
return prev.some(o => o.value === item.value)
|
|
982
|
+
? prev.filter(o => o.value !== item.value)
|
|
983
|
+
: [...prev, item];
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
<ChipGroup type="selection" leadingSlot={<span>카테고리</span>}>
|
|
987
|
+
{categories.map(({ label, value }) => (
|
|
988
|
+
<Chip
|
|
989
|
+
key={value}
|
|
990
|
+
variant="outline"
|
|
991
|
+
selected={selected.some(o => o.value === value)}
|
|
992
|
+
onClick={() => setSelected(prev => toggle(prev, { label, value }))}
|
|
993
|
+
>
|
|
994
|
+
{label}
|
|
995
|
+
</Chip>
|
|
996
|
+
))}
|
|
997
|
+
</ChipGroup>
|
|
998
|
+
|
|
999
|
+
// suggestion — 가로 드래그 캐러셀 + 그라데이션
|
|
1000
|
+
<ChipGroup type="suggestion" gradient>
|
|
1001
|
+
{suggestions.map(({ label, value }) => (
|
|
1002
|
+
<Chip key={value} variant="fillWeak">{label}</Chip>
|
|
1003
|
+
))}
|
|
1004
|
+
</ChipGroup>
|
|
1005
|
+
```
|
|
1006
|
+
|
|
1007
|
+
| Prop | Type | Default | Description |
|
|
1008
|
+
|------|------|---------|-------------|
|
|
1009
|
+
| `type` | `"selection" \| "suggestion"` | `"selection"` | `selection`: 줄바꿈, `suggestion`: 가로 드래그 캐러셀 |
|
|
1010
|
+
| `size` | `"large" \| "medium" \| "small" \| "xsmall"` | `"medium"` | 칩 간격 크기 |
|
|
1011
|
+
| `gradient` | `boolean` | `false` | `suggestion` 타입에서 스크롤 시 양끝 그라데이션 표시 |
|
|
1012
|
+
| `leadingSlot` | `ReactNode` | — | 칩 목록 앞 텍스트/라벨 |
|
|
1013
|
+
| `leadingElementSlot` | `ReactNode` | — | 칩 목록 앞 구분선 포함 엘리먼트 |
|
|
1014
|
+
| `customStyle` | `CSSProperties` | — | 루트 엘리먼트 인라인 스타일 |
|
|
1015
|
+
|
|
1016
|
+
---
|
|
1017
|
+
|
|
1018
|
+
### FilterChip
|
|
1019
|
+
|
|
1020
|
+
드롭다운 옵션 선택 기능이 내장된 칩입니다. `trailingSlot`을 제외한 `Chip`의 모든 props를 지원합니다.
|
|
1021
|
+
|
|
1022
|
+
```tsx
|
|
1023
|
+
import { FilterChip } from "@idbrnd/design-system";
|
|
1024
|
+
import type { DropdownOption } from "@idbrnd/design-system";
|
|
1025
|
+
|
|
1026
|
+
const [sort, setSort] = useState<DropdownOption | undefined>();
|
|
1027
|
+
|
|
1028
|
+
// 기본
|
|
1029
|
+
<FilterChip
|
|
1030
|
+
variant="outline"
|
|
1031
|
+
options={sortOptions}
|
|
1032
|
+
selectedValue={sort?.value}
|
|
1033
|
+
onSelect={setSort}
|
|
1034
|
+
>
|
|
1035
|
+
{sort?.label ?? "정렬"}
|
|
1036
|
+
</FilterChip>
|
|
1037
|
+
|
|
1038
|
+
// showSelectedLabel — "소속 하의" 형태로 표시, 재클릭 시 선택 해제
|
|
1039
|
+
<FilterChip
|
|
1040
|
+
variant="outline"
|
|
1041
|
+
options={categoryOptions}
|
|
1042
|
+
selectedValue={category?.value}
|
|
1043
|
+
onSelect={setCategory}
|
|
1044
|
+
showSelectedLabel
|
|
1045
|
+
>
|
|
1046
|
+
소속
|
|
1047
|
+
</FilterChip>
|
|
1048
|
+
|
|
1049
|
+
// 검색형 드롭다운 + 너비 고정
|
|
1050
|
+
<FilterChip
|
|
1051
|
+
variant="outline"
|
|
1052
|
+
options={brandOptions}
|
|
1053
|
+
selectedValue={brand?.value}
|
|
1054
|
+
onSelect={setBrand}
|
|
1055
|
+
dropdownType="search"
|
|
1056
|
+
dropdownWidth={280}
|
|
1057
|
+
>
|
|
1058
|
+
{brand?.label ?? "브랜드"}
|
|
1059
|
+
</FilterChip>
|
|
1060
|
+
```
|
|
1061
|
+
|
|
1062
|
+
| Prop | Type | Default | Description |
|
|
1063
|
+
|------|------|---------|-------------|
|
|
1064
|
+
| `options` | `DropdownOption[]` | (필수) | 드롭다운 옵션 목록 |
|
|
1065
|
+
| `onSelect` | `(option: DropdownOption \| undefined) => void` | (필수) | 선택/해제 콜백. 이미 선택된 옵션 재클릭 시 `undefined` 전달 |
|
|
1066
|
+
| `selectedValue` | `string` | — | 현재 선택된 옵션의 `value` |
|
|
1067
|
+
| `dropdownType` | `"basic" \| "search"` | `"basic"` | `search`: 검색 입력란 포함 |
|
|
1068
|
+
| `dropdownAlign` | `"left" \| "center"` | `"left"` | 드롭다운 정렬 방향 |
|
|
1069
|
+
| `dropdownWidth` | `number` | — | 드롭다운 너비 (px) |
|
|
1070
|
+
| `showSelectedLabel` | `boolean` | `false` | `children`을 prefix로, 선택값 label을 옆에 함께 표시 |
|
|
1071
|
+
|
|
1072
|
+
---
|
|
1073
|
+
|
|
1074
|
+
### FilterBar
|
|
1075
|
+
|
|
1076
|
+
`FilterChip`들을 가로 드래그 캐러셀로 배치하는 컨테이너입니다.
|
|
1077
|
+
|
|
1078
|
+
```tsx
|
|
1079
|
+
import { FilterBar, FilterChip } from "@idbrnd/design-system";
|
|
1080
|
+
|
|
1081
|
+
<FilterBar
|
|
1082
|
+
leadingElementSlot={<img src="/filter-icon.svg" width={24} height={24} alt="" />}
|
|
1083
|
+
trailingElementSlot={<button onClick={handleReset}>초기화</button>}
|
|
1084
|
+
>
|
|
1085
|
+
<FilterChip options={sortOptions} selectedValue={sort?.value} onSelect={setSort} showSelectedLabel>
|
|
1086
|
+
정렬
|
|
1087
|
+
</FilterChip>
|
|
1088
|
+
<FilterChip options={categoryOptions} selectedValue={category?.value} onSelect={setCategory} showSelectedLabel>
|
|
1089
|
+
소속
|
|
1090
|
+
</FilterChip>
|
|
1091
|
+
</FilterBar>
|
|
1092
|
+
|
|
1093
|
+
// verticalPadding — 패딩 O, 그라데이션 X
|
|
1094
|
+
<FilterBar verticalPadding>
|
|
1095
|
+
<FilterChip ...>정렬</FilterChip>
|
|
1096
|
+
</FilterBar>
|
|
1097
|
+
```
|
|
1098
|
+
|
|
1099
|
+
| Prop | Type | Default | Description |
|
|
1100
|
+
|------|------|---------|-------------|
|
|
1101
|
+
| `size` | `"large" \| "medium" \| "small" \| "xsmall"` | `"medium"` | 칩 간격 및 슬롯 폰트 크기 |
|
|
1102
|
+
| `verticalPadding` | `boolean` | `false` | `true`: 위아래 8px 패딩, 그라데이션 없음. `false`: 그라데이션 사용 |
|
|
1103
|
+
| `leadingElementSlot` | `ReactNode` | — | 칩 목록 앞 구분선 포함 엘리먼트 |
|
|
1104
|
+
| `trailingElementSlot` | `ReactNode` | — | 칩 목록 뒤 엘리먼트 (초기화 버튼 등) |
|
|
1105
|
+
| `customStyle` | `CSSProperties` | — | 루트 엘리먼트 인라인 스타일 |
|
|
1106
|
+
|
|
1107
|
+
---
|
|
1108
|
+
|
|
921
1109
|
## 기타
|
|
922
1110
|
|
|
923
1111
|
### Spinner
|