@designbasekorea/ui-native 0.1.0
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 +152 -0
- package/dist/components/Alert/Alert.d.ts +29 -0
- package/dist/components/Alert/Alert.d.ts.map +1 -0
- package/dist/components/Alert/Alert.js +44 -0
- package/dist/components/Alert/Alert.js.map +1 -0
- package/dist/components/Alert/index.d.ts +3 -0
- package/dist/components/Alert/index.d.ts.map +1 -0
- package/dist/components/Alert/index.js +2 -0
- package/dist/components/Alert/index.js.map +1 -0
- package/dist/components/Avatar/Avatar.d.ts +28 -0
- package/dist/components/Avatar/Avatar.d.ts.map +1 -0
- package/dist/components/Avatar/Avatar.js +73 -0
- package/dist/components/Avatar/Avatar.js.map +1 -0
- package/dist/components/Avatar/index.d.ts +3 -0
- package/dist/components/Avatar/index.d.ts.map +1 -0
- package/dist/components/Avatar/index.js +2 -0
- package/dist/components/Avatar/index.js.map +1 -0
- package/dist/components/Badge/Badge.d.ts +28 -0
- package/dist/components/Badge/Badge.d.ts.map +1 -0
- package/dist/components/Badge/Badge.js +52 -0
- package/dist/components/Badge/Badge.js.map +1 -0
- package/dist/components/Badge/index.d.ts +3 -0
- package/dist/components/Badge/index.d.ts.map +1 -0
- package/dist/components/Badge/index.js +2 -0
- package/dist/components/Badge/index.js.map +1 -0
- package/dist/components/BottomNavigation/BottomNavigation.d.ts +30 -0
- package/dist/components/BottomNavigation/BottomNavigation.d.ts.map +1 -0
- package/dist/components/BottomNavigation/BottomNavigation.js +48 -0
- package/dist/components/BottomNavigation/BottomNavigation.js.map +1 -0
- package/dist/components/BottomNavigation/index.d.ts +3 -0
- package/dist/components/BottomNavigation/index.d.ts.map +1 -0
- package/dist/components/BottomNavigation/index.js +2 -0
- package/dist/components/BottomNavigation/index.js.map +1 -0
- package/dist/components/BottomSheet/BottomSheet.d.ts +26 -0
- package/dist/components/BottomSheet/BottomSheet.d.ts.map +1 -0
- package/dist/components/BottomSheet/BottomSheet.js +75 -0
- package/dist/components/BottomSheet/BottomSheet.js.map +1 -0
- package/dist/components/BottomSheet/index.d.ts +3 -0
- package/dist/components/BottomSheet/index.d.ts.map +1 -0
- package/dist/components/BottomSheet/index.js +2 -0
- package/dist/components/BottomSheet/index.js.map +1 -0
- package/dist/components/Button/Button.d.ts +53 -0
- package/dist/components/Button/Button.d.ts.map +1 -0
- package/dist/components/Button/Button.js +129 -0
- package/dist/components/Button/Button.js.map +1 -0
- package/dist/components/Button/index.d.ts +3 -0
- package/dist/components/Button/index.d.ts.map +1 -0
- package/dist/components/Button/index.js +2 -0
- package/dist/components/Button/index.js.map +1 -0
- package/dist/components/Card/Card.d.ts +36 -0
- package/dist/components/Card/Card.d.ts.map +1 -0
- package/dist/components/Card/Card.js +61 -0
- package/dist/components/Card/Card.js.map +1 -0
- package/dist/components/Card/index.d.ts +3 -0
- package/dist/components/Card/index.d.ts.map +1 -0
- package/dist/components/Card/index.js +2 -0
- package/dist/components/Card/index.js.map +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +26 -0
- package/dist/components/Checkbox/Checkbox.d.ts.map +1 -0
- package/dist/components/Checkbox/Checkbox.js +57 -0
- package/dist/components/Checkbox/Checkbox.js.map +1 -0
- package/dist/components/Checkbox/index.d.ts +3 -0
- package/dist/components/Checkbox/index.d.ts.map +1 -0
- package/dist/components/Checkbox/index.js +2 -0
- package/dist/components/Checkbox/index.js.map +1 -0
- package/dist/components/Chip/Chip.d.ts +29 -0
- package/dist/components/Chip/Chip.d.ts.map +1 -0
- package/dist/components/Chip/Chip.js +54 -0
- package/dist/components/Chip/Chip.js.map +1 -0
- package/dist/components/Chip/index.d.ts +3 -0
- package/dist/components/Chip/index.d.ts.map +1 -0
- package/dist/components/Chip/index.js +2 -0
- package/dist/components/Chip/index.js.map +1 -0
- package/dist/components/Divider/Divider.d.ts +22 -0
- package/dist/components/Divider/Divider.d.ts.map +1 -0
- package/dist/components/Divider/Divider.js +16 -0
- package/dist/components/Divider/Divider.js.map +1 -0
- package/dist/components/Divider/index.d.ts +3 -0
- package/dist/components/Divider/index.d.ts.map +1 -0
- package/dist/components/Divider/index.js +2 -0
- package/dist/components/Divider/index.js.map +1 -0
- package/dist/components/Input/Input.d.ts +33 -0
- package/dist/components/Input/Input.d.ts.map +1 -0
- package/dist/components/Input/Input.js +98 -0
- package/dist/components/Input/Input.js.map +1 -0
- package/dist/components/Input/index.d.ts +3 -0
- package/dist/components/Input/index.d.ts.map +1 -0
- package/dist/components/Input/index.js +2 -0
- package/dist/components/Input/index.js.map +1 -0
- package/dist/components/Modal/Modal.d.ts +28 -0
- package/dist/components/Modal/Modal.d.ts.map +1 -0
- package/dist/components/Modal/Modal.js +46 -0
- package/dist/components/Modal/Modal.js.map +1 -0
- package/dist/components/Modal/index.d.ts +3 -0
- package/dist/components/Modal/index.d.ts.map +1 -0
- package/dist/components/Modal/index.js +2 -0
- package/dist/components/Modal/index.js.map +1 -0
- package/dist/components/Navbar/Navbar.d.ts +50 -0
- package/dist/components/Navbar/Navbar.d.ts.map +1 -0
- package/dist/components/Navbar/Navbar.js +125 -0
- package/dist/components/Navbar/Navbar.js.map +1 -0
- package/dist/components/Navbar/index.d.ts +3 -0
- package/dist/components/Navbar/index.d.ts.map +1 -0
- package/dist/components/Navbar/index.js +2 -0
- package/dist/components/Navbar/index.js.map +1 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +27 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts.map +1 -0
- package/dist/components/ProgressBar/ProgressBar.js +55 -0
- package/dist/components/ProgressBar/ProgressBar.js.map +1 -0
- package/dist/components/ProgressBar/index.d.ts +3 -0
- package/dist/components/ProgressBar/index.d.ts.map +1 -0
- package/dist/components/ProgressBar/index.js +2 -0
- package/dist/components/ProgressBar/index.js.map +1 -0
- package/dist/components/Radio/Radio.d.ts +30 -0
- package/dist/components/Radio/Radio.d.ts.map +1 -0
- package/dist/components/Radio/Radio.js +56 -0
- package/dist/components/Radio/Radio.js.map +1 -0
- package/dist/components/Radio/index.d.ts +3 -0
- package/dist/components/Radio/index.d.ts.map +1 -0
- package/dist/components/Radio/index.js +2 -0
- package/dist/components/Radio/index.js.map +1 -0
- package/dist/components/SearchBar/SearchBar.d.ts +29 -0
- package/dist/components/SearchBar/SearchBar.d.ts.map +1 -0
- package/dist/components/SearchBar/SearchBar.js +64 -0
- package/dist/components/SearchBar/SearchBar.js.map +1 -0
- package/dist/components/SearchBar/index.d.ts +3 -0
- package/dist/components/SearchBar/index.d.ts.map +1 -0
- package/dist/components/SearchBar/index.js +2 -0
- package/dist/components/SearchBar/index.js.map +1 -0
- package/dist/components/Skeleton/Skeleton.d.ts +22 -0
- package/dist/components/Skeleton/Skeleton.d.ts.map +1 -0
- package/dist/components/Skeleton/Skeleton.js +46 -0
- package/dist/components/Skeleton/Skeleton.js.map +1 -0
- package/dist/components/Skeleton/index.d.ts +3 -0
- package/dist/components/Skeleton/index.d.ts.map +1 -0
- package/dist/components/Skeleton/index.js +2 -0
- package/dist/components/Skeleton/index.js.map +1 -0
- package/dist/components/Spinner/Spinner.d.ts +23 -0
- package/dist/components/Spinner/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner/Spinner.js +19 -0
- package/dist/components/Spinner/Spinner.js.map +1 -0
- package/dist/components/Spinner/index.d.ts +3 -0
- package/dist/components/Spinner/index.d.ts.map +1 -0
- package/dist/components/Spinner/index.js +2 -0
- package/dist/components/Spinner/index.js.map +1 -0
- package/dist/components/Tabs/Tabs.d.ts +30 -0
- package/dist/components/Tabs/Tabs.d.ts.map +1 -0
- package/dist/components/Tabs/Tabs.js +73 -0
- package/dist/components/Tabs/Tabs.js.map +1 -0
- package/dist/components/Tabs/index.d.ts +3 -0
- package/dist/components/Tabs/index.d.ts.map +1 -0
- package/dist/components/Tabs/index.js +2 -0
- package/dist/components/Tabs/index.js.map +1 -0
- package/dist/components/Toast/Toast.d.ts +30 -0
- package/dist/components/Toast/Toast.d.ts.map +1 -0
- package/dist/components/Toast/Toast.js +84 -0
- package/dist/components/Toast/Toast.js.map +1 -0
- package/dist/components/Toast/index.d.ts +3 -0
- package/dist/components/Toast/index.d.ts.map +1 -0
- package/dist/components/Toast/index.js +2 -0
- package/dist/components/Toast/index.js.map +1 -0
- package/dist/components/Toggle/Toggle.d.ts +26 -0
- package/dist/components/Toggle/Toggle.d.ts.map +1 -0
- package/dist/components/Toggle/Toggle.js +75 -0
- package/dist/components/Toggle/Toggle.js.map +1 -0
- package/dist/components/Toggle/index.d.ts +3 -0
- package/dist/components/Toggle/index.d.ts.map +1 -0
- package/dist/components/Toggle/index.js +2 -0
- package/dist/components/Toggle/index.js.map +1 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/theme/ThemeProvider.d.ts +35 -0
- package/dist/theme/ThemeProvider.d.ts.map +1 -0
- package/dist/theme/ThemeProvider.js +45 -0
- package/dist/theme/ThemeProvider.js.map +1 -0
- package/dist/theme/index.d.ts +6 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +4 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/tokens.d.ts +55 -0
- package/dist/theme/tokens.d.ts.map +1 -0
- package/dist/theme/tokens.js +172 -0
- package/dist/theme/tokens.js.map +1 -0
- package/dist/theme/useTheme.d.ts +25 -0
- package/dist/theme/useTheme.d.ts.map +1 -0
- package/dist/theme/useTheme.js +33 -0
- package/dist/theme/useTheme.js.map +1 -0
- package/package.json +58 -0
- package/src/components/Alert/Alert.tsx +105 -0
- package/src/components/Alert/index.ts +2 -0
- package/src/components/Avatar/Avatar.tsx +122 -0
- package/src/components/Avatar/index.ts +2 -0
- package/src/components/Badge/Badge.tsx +100 -0
- package/src/components/Badge/index.ts +2 -0
- package/src/components/BottomNavigation/BottomNavigation.tsx +104 -0
- package/src/components/BottomNavigation/index.ts +2 -0
- package/src/components/BottomSheet/BottomSheet.tsx +127 -0
- package/src/components/BottomSheet/index.ts +2 -0
- package/src/components/Button/Button.tsx +255 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/Card/Card.tsx +147 -0
- package/src/components/Card/index.ts +2 -0
- package/src/components/Checkbox/Checkbox.tsx +95 -0
- package/src/components/Checkbox/index.ts +2 -0
- package/src/components/Chip/Chip.tsx +108 -0
- package/src/components/Chip/index.ts +2 -0
- package/src/components/Divider/Divider.tsx +41 -0
- package/src/components/Divider/index.ts +2 -0
- package/src/components/Input/Input.tsx +199 -0
- package/src/components/Input/index.ts +2 -0
- package/src/components/Modal/Modal.tsx +117 -0
- package/src/components/Modal/index.ts +2 -0
- package/src/components/Navbar/Navbar.tsx +278 -0
- package/src/components/Navbar/index.ts +2 -0
- package/src/components/ProgressBar/ProgressBar.tsx +99 -0
- package/src/components/ProgressBar/index.ts +2 -0
- package/src/components/Radio/Radio.tsx +103 -0
- package/src/components/Radio/index.ts +2 -0
- package/src/components/SearchBar/SearchBar.tsx +115 -0
- package/src/components/SearchBar/index.ts +2 -0
- package/src/components/Skeleton/Skeleton.tsx +74 -0
- package/src/components/Skeleton/index.ts +2 -0
- package/src/components/Spinner/Spinner.tsx +58 -0
- package/src/components/Spinner/index.ts +2 -0
- package/src/components/Tabs/Tabs.tsx +124 -0
- package/src/components/Tabs/index.ts +2 -0
- package/src/components/Toast/Toast.tsx +128 -0
- package/src/components/Toast/index.ts +2 -0
- package/src/components/Toggle/Toggle.tsx +109 -0
- package/src/components/Toggle/index.ts +2 -0
- package/src/index.ts +87 -0
- package/src/theme/ThemeProvider.tsx +96 -0
- package/src/theme/index.ts +5 -0
- package/src/theme/tokens.ts +225 -0
- package/src/theme/useTheme.ts +37 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button 컴포넌트 (React Native)
|
|
3
|
+
*
|
|
4
|
+
* 목적: 일관된 스타일과 접근성을 가진 버튼 컴포넌트
|
|
5
|
+
* 기능: 다양한 variant, size 지원, 아이콘 버튼, 로딩 상태
|
|
6
|
+
*
|
|
7
|
+
* 스타일링: 모든 색상·사이즈·간격·radius는 토큰에서 자동으로 가져옴
|
|
8
|
+
* - 색상: theme.color.semantic.button.{variant}.{속성}
|
|
9
|
+
* - 사이즈: theme.size.semantic.button.{s|m|l}
|
|
10
|
+
* - 간격: theme.spacing.aliases.padding.{xs|s|m}
|
|
11
|
+
* - 라운드: theme.border.semantic.radius.button.{s|m|l|pill}
|
|
12
|
+
* - 폰트: theme.typography.foundation.fontSize.{s|base|l}
|
|
13
|
+
*
|
|
14
|
+
* 원본: packages/ui/src/components/Button/Button.tsx
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import {
|
|
19
|
+
Pressable,
|
|
20
|
+
Text,
|
|
21
|
+
ActivityIndicator,
|
|
22
|
+
StyleSheet,
|
|
23
|
+
View,
|
|
24
|
+
type ViewStyle,
|
|
25
|
+
type TextStyle,
|
|
26
|
+
type PressableProps,
|
|
27
|
+
} from 'react-native';
|
|
28
|
+
import { useTheme } from '../../theme/useTheme';
|
|
29
|
+
import type { DesignbaseThemeTokens } from '../../theme/tokens';
|
|
30
|
+
|
|
31
|
+
export type ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'danger' | 'ghost';
|
|
32
|
+
export type ButtonSize = 's' | 'm' | 'l';
|
|
33
|
+
export type ButtonRadius = 's' | 'm' | 'l' | 'pill';
|
|
34
|
+
|
|
35
|
+
export interface ButtonProps extends Omit<PressableProps, 'style'> {
|
|
36
|
+
/** 버튼 variant */
|
|
37
|
+
variant?: ButtonVariant;
|
|
38
|
+
/** 버튼 크기 */
|
|
39
|
+
size?: ButtonSize;
|
|
40
|
+
/** 둥글기 */
|
|
41
|
+
radius?: ButtonRadius;
|
|
42
|
+
/** 전체 너비 여부 */
|
|
43
|
+
fullWidth?: boolean;
|
|
44
|
+
/** 비활성화 여부 */
|
|
45
|
+
disabled?: boolean;
|
|
46
|
+
/** 로딩 상태 */
|
|
47
|
+
loading?: boolean;
|
|
48
|
+
/** 로딩 중 표시할 텍스트 */
|
|
49
|
+
loadingText?: string;
|
|
50
|
+
/** 아이콘 전용 버튼 여부 */
|
|
51
|
+
iconOnly?: boolean;
|
|
52
|
+
/** 시작 아이콘 */
|
|
53
|
+
startIcon?: React.ReactNode;
|
|
54
|
+
/** 끝 아이콘 */
|
|
55
|
+
endIcon?: React.ReactNode;
|
|
56
|
+
/** 버튼 내용 */
|
|
57
|
+
children?: React.ReactNode;
|
|
58
|
+
/** 클릭 핸들러 */
|
|
59
|
+
onPress?: () => void;
|
|
60
|
+
/** 추가 스타일 */
|
|
61
|
+
style?: ViewStyle;
|
|
62
|
+
/** 텍스트 스타일 오버라이드 */
|
|
63
|
+
textStyle?: TextStyle;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** semantic 토큰에서 variant별 색상 가져오기 */
|
|
67
|
+
function getVariantColors(variant: ButtonVariant, theme: DesignbaseThemeTokens) {
|
|
68
|
+
const btnTokens = theme.color.semantic?.button;
|
|
69
|
+
const aliases = theme.color.aliases;
|
|
70
|
+
|
|
71
|
+
switch (variant) {
|
|
72
|
+
case 'primary':
|
|
73
|
+
return {
|
|
74
|
+
bg: btnTokens?.primary?.['bg-default'] ?? aliases?.brand?.primary ?? '#006FFF',
|
|
75
|
+
bgPressed: btnTokens?.primary?.['bg-active'] ?? '#0D4B9B',
|
|
76
|
+
text: btnTokens?.primary?.['text-default'] ?? '#FFFFFF',
|
|
77
|
+
border: btnTokens?.primary?.['border-default'] ?? 'transparent',
|
|
78
|
+
};
|
|
79
|
+
case 'secondary':
|
|
80
|
+
return {
|
|
81
|
+
bg: btnTokens?.secondary?.['bg-default'] ?? aliases?.surface?.['layer-1'] ?? '#F2F8FC',
|
|
82
|
+
bgPressed: btnTokens?.secondary?.['bg-hover'] ?? '#E8EEF2',
|
|
83
|
+
text: btnTokens?.secondary?.['text-default'] ?? aliases?.text?.link ?? '#006FFF',
|
|
84
|
+
border: btnTokens?.secondary?.['border-default'] ?? aliases?.border?.base ?? '#E8EEF2',
|
|
85
|
+
};
|
|
86
|
+
case 'tertiary':
|
|
87
|
+
return {
|
|
88
|
+
bg: btnTokens?.tertiary?.['bg-default'] ?? aliases?.surface?.base ?? '#FFFFFF',
|
|
89
|
+
bgPressed: btnTokens?.tertiary?.['bg-hover'] ?? '#F2F8FC',
|
|
90
|
+
text: btnTokens?.tertiary?.['text-default'] ?? aliases?.text?.primary ?? '#17191A',
|
|
91
|
+
border: btnTokens?.tertiary?.['border-default'] ?? aliases?.border?.base ?? '#E8EEF2',
|
|
92
|
+
};
|
|
93
|
+
case 'danger':
|
|
94
|
+
return {
|
|
95
|
+
bg: aliases?.feedback?.error?.fg ?? '#DC2626',
|
|
96
|
+
bgPressed: '#B91C1C',
|
|
97
|
+
text: aliases?.text?.['inverse-primary'] ?? '#FFFFFF',
|
|
98
|
+
border: 'transparent',
|
|
99
|
+
};
|
|
100
|
+
case 'ghost':
|
|
101
|
+
default:
|
|
102
|
+
return {
|
|
103
|
+
bg: 'transparent',
|
|
104
|
+
bgPressed: aliases?.surface?.['layer-1'] ?? '#F2F8FC',
|
|
105
|
+
text: aliases?.text?.primary ?? '#17191A',
|
|
106
|
+
border: 'transparent',
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** semantic 토큰에서 size별 높이·패딩·폰트 가져오기 */
|
|
112
|
+
function getSizeValues(size: ButtonSize, theme: DesignbaseThemeTokens) {
|
|
113
|
+
const btnSize = theme.size.semantic?.button;
|
|
114
|
+
const padding = theme.spacing.aliases?.padding ?? theme.spacing.aliases?.scale;
|
|
115
|
+
const fontSize = theme.typography.foundation?.fontSize;
|
|
116
|
+
|
|
117
|
+
switch (size) {
|
|
118
|
+
case 's':
|
|
119
|
+
return {
|
|
120
|
+
height: btnSize?.s ?? 24,
|
|
121
|
+
paddingH: padding?.xs ?? 4,
|
|
122
|
+
fontSize: fontSize?.xs ?? 12,
|
|
123
|
+
gap: padding?.xxs ?? 2,
|
|
124
|
+
};
|
|
125
|
+
case 'l':
|
|
126
|
+
return {
|
|
127
|
+
height: btnSize?.l ?? 40,
|
|
128
|
+
paddingH: padding?.m ?? 12,
|
|
129
|
+
fontSize: fontSize?.l ?? 18,
|
|
130
|
+
gap: padding?.xs ?? 4,
|
|
131
|
+
};
|
|
132
|
+
case 'm':
|
|
133
|
+
default:
|
|
134
|
+
return {
|
|
135
|
+
height: btnSize?.m ?? 32,
|
|
136
|
+
paddingH: padding?.s ?? 8,
|
|
137
|
+
fontSize: fontSize?.s ?? 14,
|
|
138
|
+
gap: padding?.xxs ?? 2,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export const Button: React.FC<ButtonProps> = ({
|
|
144
|
+
variant = 'primary',
|
|
145
|
+
size = 'm',
|
|
146
|
+
radius,
|
|
147
|
+
fullWidth = false,
|
|
148
|
+
disabled = false,
|
|
149
|
+
loading = false,
|
|
150
|
+
loadingText,
|
|
151
|
+
iconOnly = false,
|
|
152
|
+
startIcon,
|
|
153
|
+
endIcon,
|
|
154
|
+
children,
|
|
155
|
+
onPress,
|
|
156
|
+
style,
|
|
157
|
+
textStyle,
|
|
158
|
+
...props
|
|
159
|
+
}) => {
|
|
160
|
+
const { theme } = useTheme();
|
|
161
|
+
const colors = getVariantColors(variant, theme);
|
|
162
|
+
const sizeValues = getSizeValues(size, theme);
|
|
163
|
+
|
|
164
|
+
// radius 토큰에서 가져오기
|
|
165
|
+
const radiusTokens = theme.border.semantic?.radius?.button;
|
|
166
|
+
const resolvedRadius = radius || (size === 's' ? 's' : size === 'l' ? 'l' : 'm');
|
|
167
|
+
const borderRadiusValue = radiusTokens?.[resolvedRadius] ?? 8;
|
|
168
|
+
|
|
169
|
+
const isDisabled = disabled || loading;
|
|
170
|
+
const disabledOpacity = theme.opacity.foundation?.[40] ?? 0.4;
|
|
171
|
+
|
|
172
|
+
const renderContent = (pressed: boolean) => {
|
|
173
|
+
if (loading) {
|
|
174
|
+
return (
|
|
175
|
+
<>
|
|
176
|
+
<ActivityIndicator size="small" color={colors.text} />
|
|
177
|
+
{loadingText ? (
|
|
178
|
+
<Text style={[styles.text, { fontSize: sizeValues.fontSize, color: colors.text }, textStyle]}>
|
|
179
|
+
{loadingText}
|
|
180
|
+
</Text>
|
|
181
|
+
) : (!iconOnly && children && typeof children === 'string') ? (
|
|
182
|
+
<Text style={[styles.text, { fontSize: sizeValues.fontSize, color: colors.text }, textStyle]}>
|
|
183
|
+
{children}
|
|
184
|
+
</Text>
|
|
185
|
+
) : null}
|
|
186
|
+
</>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return (
|
|
191
|
+
<>
|
|
192
|
+
{startIcon && <View style={styles.iconWrapper}>{startIcon}</View>}
|
|
193
|
+
{children && !iconOnly && (
|
|
194
|
+
typeof children === 'string' ? (
|
|
195
|
+
<Text style={[styles.text, { fontSize: sizeValues.fontSize, color: colors.text }, textStyle]}>
|
|
196
|
+
{children}
|
|
197
|
+
</Text>
|
|
198
|
+
) : children
|
|
199
|
+
)}
|
|
200
|
+
{iconOnly && children}
|
|
201
|
+
{endIcon && <View style={styles.iconWrapper}>{endIcon}</View>}
|
|
202
|
+
</>
|
|
203
|
+
);
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
return (
|
|
207
|
+
<Pressable
|
|
208
|
+
{...props}
|
|
209
|
+
onPress={onPress}
|
|
210
|
+
disabled={isDisabled}
|
|
211
|
+
accessibilityRole="button"
|
|
212
|
+
accessibilityState={{ disabled: isDisabled, busy: loading }}
|
|
213
|
+
style={({ pressed }) => [
|
|
214
|
+
styles.base,
|
|
215
|
+
{
|
|
216
|
+
height: sizeValues.height,
|
|
217
|
+
paddingHorizontal: sizeValues.paddingH,
|
|
218
|
+
gap: sizeValues.gap,
|
|
219
|
+
borderRadius: borderRadiusValue,
|
|
220
|
+
backgroundColor: pressed && !isDisabled ? colors.bgPressed : colors.bg,
|
|
221
|
+
borderColor: colors.border,
|
|
222
|
+
borderWidth: variant === 'secondary' || variant === 'tertiary' ? 1 : 0,
|
|
223
|
+
},
|
|
224
|
+
fullWidth && styles.fullWidth,
|
|
225
|
+
iconOnly && { width: sizeValues.height, paddingHorizontal: 0 },
|
|
226
|
+
isDisabled && { opacity: disabledOpacity },
|
|
227
|
+
style,
|
|
228
|
+
]}
|
|
229
|
+
>
|
|
230
|
+
{({ pressed }) => renderContent(pressed)}
|
|
231
|
+
</Pressable>
|
|
232
|
+
);
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
Button.displayName = 'Button';
|
|
236
|
+
|
|
237
|
+
const styles = StyleSheet.create({
|
|
238
|
+
base: {
|
|
239
|
+
flexDirection: 'row',
|
|
240
|
+
alignItems: 'center',
|
|
241
|
+
justifyContent: 'center',
|
|
242
|
+
},
|
|
243
|
+
fullWidth: {
|
|
244
|
+
width: '100%',
|
|
245
|
+
},
|
|
246
|
+
text: {
|
|
247
|
+
fontWeight: '500',
|
|
248
|
+
},
|
|
249
|
+
iconWrapper: {
|
|
250
|
+
alignItems: 'center',
|
|
251
|
+
justifyContent: 'center',
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
export default Button;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Card 컴포넌트 (React Native)
|
|
3
|
+
*
|
|
4
|
+
* 스타일링 토큰 경로:
|
|
5
|
+
* - 색상: theme.color.aliases.surface.{base|layer-1|layer-2}, border.{base}
|
|
6
|
+
* - radius: theme.border.semantic.radius.card.{s|m|l}
|
|
7
|
+
* - 패딩: theme.spacing.aliases.padding.{s|m|l}
|
|
8
|
+
* - 그림자: theme.shadow.foundation.{s|m|l}
|
|
9
|
+
* - 폰트: theme.typography.foundation.fontSize.{s|base|l|xl}
|
|
10
|
+
*
|
|
11
|
+
* 원본: packages/ui/src/components/Card/Card.tsx
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import {
|
|
16
|
+
View,
|
|
17
|
+
Text,
|
|
18
|
+
Image,
|
|
19
|
+
Pressable,
|
|
20
|
+
StyleSheet,
|
|
21
|
+
type ViewStyle,
|
|
22
|
+
type ImageSourcePropType,
|
|
23
|
+
} from 'react-native';
|
|
24
|
+
import { useTheme } from '../../theme/useTheme';
|
|
25
|
+
|
|
26
|
+
export type CardVariant = 'default' | 'elevated' | 'outlined' | 'filled';
|
|
27
|
+
export type CardSize = 's' | 'm' | 'l';
|
|
28
|
+
|
|
29
|
+
export interface CardProps {
|
|
30
|
+
title?: string;
|
|
31
|
+
subtitle?: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
children?: React.ReactNode;
|
|
34
|
+
image?: ImageSourcePropType;
|
|
35
|
+
imageHeight?: number;
|
|
36
|
+
variant?: CardVariant;
|
|
37
|
+
size?: CardSize;
|
|
38
|
+
fullWidth?: boolean;
|
|
39
|
+
clickable?: boolean;
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
headerRight?: React.ReactNode;
|
|
42
|
+
footer?: React.ReactNode;
|
|
43
|
+
onPress?: () => void;
|
|
44
|
+
style?: ViewStyle;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const Card: React.FC<CardProps> = ({
|
|
48
|
+
title, subtitle, description, children, image, imageHeight = 180,
|
|
49
|
+
variant = 'default', size = 'm', fullWidth = false, clickable = false,
|
|
50
|
+
disabled = false, headerRight, footer, onPress, style,
|
|
51
|
+
}) => {
|
|
52
|
+
const { theme } = useTheme();
|
|
53
|
+
|
|
54
|
+
// ─── 토큰에서 가져오기 ───
|
|
55
|
+
const surface = theme.color.aliases?.surface ?? {};
|
|
56
|
+
const borders = theme.color.aliases?.border ?? {};
|
|
57
|
+
const text = theme.color.aliases?.text ?? {};
|
|
58
|
+
const padding = theme.spacing.aliases?.padding ?? {};
|
|
59
|
+
const fontSize = theme.typography.foundation?.fontSize ?? {};
|
|
60
|
+
const shadow = theme.shadow.foundation ?? {};
|
|
61
|
+
const cardRadius = theme.border.semantic?.radius?.card ?? {};
|
|
62
|
+
const disabledOpacity = theme.opacity.foundation?.[40] ?? 0.4;
|
|
63
|
+
|
|
64
|
+
const paddingValue = { s: padding.s ?? 8, m: padding.m ?? 12, l: padding.l ?? 20 }[size];
|
|
65
|
+
const titleSize = { s: fontSize.s ?? 14, m: fontSize.l ?? 18, l: fontSize.xl ?? 20 }[size];
|
|
66
|
+
const borderRadius = cardRadius[size] ?? 8;
|
|
67
|
+
|
|
68
|
+
// RN shadow 객체 변환
|
|
69
|
+
const toShadowStyle = (s: any) => s ? {
|
|
70
|
+
shadowColor: s.shadowColor ?? '#000',
|
|
71
|
+
shadowOffset: { width: s.shadowOffsetX ?? 0, height: s.shadowOffsetY ?? 0 },
|
|
72
|
+
shadowOpacity: s.shadowOpacity ?? 0.1,
|
|
73
|
+
shadowRadius: s.shadowRadius ?? 4,
|
|
74
|
+
elevation: s.elevation ?? 3,
|
|
75
|
+
} : {};
|
|
76
|
+
|
|
77
|
+
const variantStyles: ViewStyle = (() => {
|
|
78
|
+
switch (variant) {
|
|
79
|
+
case 'elevated':
|
|
80
|
+
return { backgroundColor: surface.base ?? '#FFFFFF', ...toShadowStyle(shadow.m) };
|
|
81
|
+
case 'outlined':
|
|
82
|
+
return { backgroundColor: surface.base ?? '#FFFFFF', borderWidth: 1, borderColor: borders.base ?? '#E8EEF2' };
|
|
83
|
+
case 'filled':
|
|
84
|
+
return { backgroundColor: surface['layer-1'] ?? '#F2F8FC' };
|
|
85
|
+
default:
|
|
86
|
+
return { backgroundColor: surface.base ?? '#FFFFFF', ...toShadowStyle(shadow.s) };
|
|
87
|
+
}
|
|
88
|
+
})();
|
|
89
|
+
|
|
90
|
+
const content = (
|
|
91
|
+
<View style={[
|
|
92
|
+
styles.container, variantStyles, { borderRadius },
|
|
93
|
+
fullWidth && styles.fullWidth,
|
|
94
|
+
disabled && { opacity: disabledOpacity },
|
|
95
|
+
style,
|
|
96
|
+
]}>
|
|
97
|
+
{image && (
|
|
98
|
+
<Image source={image} style={[styles.image, { height: imageHeight, borderTopLeftRadius: borderRadius, borderTopRightRadius: borderRadius }]} resizeMode="cover" />
|
|
99
|
+
)}
|
|
100
|
+
|
|
101
|
+
<View style={[styles.content, { padding: paddingValue }]}>
|
|
102
|
+
{(title || subtitle || headerRight) && (
|
|
103
|
+
<View style={styles.header}>
|
|
104
|
+
<View style={styles.headerText}>
|
|
105
|
+
{title && <Text style={[styles.title, { fontSize: titleSize, color: text.primary ?? '#17191A' }]}>{title}</Text>}
|
|
106
|
+
{subtitle && <Text style={{ fontSize: fontSize.xs ?? 12, color: text.secondary ?? '#464A4D' }}>{subtitle}</Text>}
|
|
107
|
+
</View>
|
|
108
|
+
{headerRight}
|
|
109
|
+
</View>
|
|
110
|
+
)}
|
|
111
|
+
{description && <Text style={{ fontSize: fontSize.s ?? 14, color: text.secondary ?? '#464A4D', lineHeight: 20 }}>{description}</Text>}
|
|
112
|
+
{children}
|
|
113
|
+
</View>
|
|
114
|
+
|
|
115
|
+
{footer && (
|
|
116
|
+
<View style={[styles.footer, { padding: paddingValue, borderTopColor: borders.base ?? '#E8EEF2' }]}>
|
|
117
|
+
{footer}
|
|
118
|
+
</View>
|
|
119
|
+
)}
|
|
120
|
+
</View>
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
if (clickable && onPress) {
|
|
124
|
+
return (
|
|
125
|
+
<Pressable onPress={onPress} disabled={disabled} accessibilityRole="button"
|
|
126
|
+
style={({ pressed }) => pressed ? { opacity: 0.8 } : undefined}>
|
|
127
|
+
{content}
|
|
128
|
+
</Pressable>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
return content;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
Card.displayName = 'Card';
|
|
135
|
+
|
|
136
|
+
const styles = StyleSheet.create({
|
|
137
|
+
container: { overflow: 'hidden' },
|
|
138
|
+
fullWidth: { width: '100%' },
|
|
139
|
+
image: { width: '100%' },
|
|
140
|
+
content: { gap: 8 },
|
|
141
|
+
header: { flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'space-between' },
|
|
142
|
+
headerText: { flex: 1, gap: 2 },
|
|
143
|
+
title: { fontWeight: '600' },
|
|
144
|
+
footer: { borderTopWidth: 1 },
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
export default Card;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkbox 컴포넌트 (React Native)
|
|
3
|
+
*
|
|
4
|
+
* 스타일링 토큰 경로:
|
|
5
|
+
* - 사이즈: theme.size.semantic.checkbox.{s|m|l}
|
|
6
|
+
* - 색상: theme.color.aliases.{brand.primary|border.base|surface.base}
|
|
7
|
+
* - 라운드: theme.border.semantic.radius.checkbox.{s|m|l}
|
|
8
|
+
* - 폰트: theme.typography.foundation.fontSize.*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { View, Text, Pressable, StyleSheet, type ViewStyle } from 'react-native';
|
|
13
|
+
import { useTheme } from '../../theme/useTheme';
|
|
14
|
+
|
|
15
|
+
export type CheckboxSize = 's' | 'm' | 'l';
|
|
16
|
+
|
|
17
|
+
export interface CheckboxProps {
|
|
18
|
+
checked?: boolean;
|
|
19
|
+
defaultChecked?: boolean;
|
|
20
|
+
onChange?: (checked: boolean) => void;
|
|
21
|
+
label?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
size?: CheckboxSize;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
indeterminate?: boolean;
|
|
26
|
+
style?: ViewStyle;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const Checkbox: React.FC<CheckboxProps> = ({
|
|
30
|
+
checked: controlledChecked, defaultChecked = false, onChange,
|
|
31
|
+
label, description, size = 'm', disabled = false, indeterminate = false, style,
|
|
32
|
+
}) => {
|
|
33
|
+
const { theme } = useTheme();
|
|
34
|
+
const [internalChecked, setInternalChecked] = React.useState(controlledChecked ?? defaultChecked);
|
|
35
|
+
const isChecked = controlledChecked ?? internalChecked;
|
|
36
|
+
|
|
37
|
+
const brand = theme.color.aliases?.brand ?? {};
|
|
38
|
+
const borders = theme.color.aliases?.border ?? {};
|
|
39
|
+
const surface = theme.color.aliases?.surface ?? {};
|
|
40
|
+
const textColors = theme.color.aliases?.text ?? {};
|
|
41
|
+
const checkboxSize = theme.size.semantic?.checkbox ?? {};
|
|
42
|
+
const checkboxRadius = theme.border.semantic?.radius?.checkbox ?? {};
|
|
43
|
+
const fontSize = theme.typography.foundation?.fontSize ?? {};
|
|
44
|
+
const disabledOpacity = theme.opacity.foundation?.[40] ?? 0.4;
|
|
45
|
+
const gap = theme.spacing.aliases?.gap ?? {};
|
|
46
|
+
|
|
47
|
+
const boxSize = checkboxSize[size] ?? { s: 16, m: 20, l: 24 }[size];
|
|
48
|
+
const borderRadius = checkboxRadius[size] ?? { s: 3, m: 4, l: 6 }[size];
|
|
49
|
+
const labelFontSize = { s: fontSize.xs ?? 12, m: fontSize.s ?? 14, l: fontSize.base ?? 16 }[size];
|
|
50
|
+
const checkMarkSize = { s: 10, m: 12, l: 16 }[size];
|
|
51
|
+
|
|
52
|
+
const handlePress = () => {
|
|
53
|
+
if (disabled) return;
|
|
54
|
+
const newValue = !isChecked;
|
|
55
|
+
setInternalChecked(newValue);
|
|
56
|
+
onChange?.(newValue);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Pressable onPress={handlePress} disabled={disabled}
|
|
61
|
+
accessibilityRole="checkbox" accessibilityState={{ checked: isChecked, disabled }}
|
|
62
|
+
style={[styles.container, { gap: gap.s ?? 8 }, disabled && { opacity: disabledOpacity }, style]}>
|
|
63
|
+
<View style={[
|
|
64
|
+
styles.box,
|
|
65
|
+
{
|
|
66
|
+
width: boxSize, height: boxSize, borderRadius,
|
|
67
|
+
backgroundColor: isChecked || indeterminate ? (brand.primary ?? '#006FFF') : (surface.base ?? '#FFFFFF'),
|
|
68
|
+
borderColor: isChecked || indeterminate ? (brand.primary ?? '#006FFF') : (borders.base ?? '#E8EEF2'),
|
|
69
|
+
borderWidth: isChecked || indeterminate ? 0 : 2,
|
|
70
|
+
},
|
|
71
|
+
]}>
|
|
72
|
+
{isChecked && <Text style={[styles.checkMark, { fontSize: checkMarkSize, color: '#FFFFFF' }]}>✓</Text>}
|
|
73
|
+
{indeterminate && !isChecked && <View style={[styles.indeterminate, { width: boxSize * 0.5, backgroundColor: '#FFFFFF' }]} />}
|
|
74
|
+
</View>
|
|
75
|
+
{(label || description) && (
|
|
76
|
+
<View style={styles.labelContainer}>
|
|
77
|
+
{label && <Text style={{ fontSize: labelFontSize, color: textColors.primary ?? '#17191A' }}>{label}</Text>}
|
|
78
|
+
{description && <Text style={{ fontSize: fontSize.xs ?? 12, color: textColors.tertiary ?? '#757B80' }}>{description}</Text>}
|
|
79
|
+
</View>
|
|
80
|
+
)}
|
|
81
|
+
</Pressable>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
Checkbox.displayName = 'Checkbox';
|
|
86
|
+
|
|
87
|
+
const styles = StyleSheet.create({
|
|
88
|
+
container: { flexDirection: 'row', alignItems: 'flex-start' },
|
|
89
|
+
box: { alignItems: 'center', justifyContent: 'center' },
|
|
90
|
+
checkMark: { fontWeight: '700' },
|
|
91
|
+
indeterminate: { height: 2, borderRadius: 1 },
|
|
92
|
+
labelContainer: { flex: 1, gap: 2, paddingTop: 1 },
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
export default Checkbox;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chip 컴포넌트 (React Native)
|
|
3
|
+
*
|
|
4
|
+
* 스타일링 토큰 경로:
|
|
5
|
+
* - 색상: theme.color.aliases.{brand|surface|text|feedback}.*
|
|
6
|
+
* - 폰트: theme.typography.foundation.fontSize.{xs|s|base}
|
|
7
|
+
* - 간격: theme.spacing.aliases.padding.{xs|s|m}
|
|
8
|
+
*
|
|
9
|
+
* 원본: packages/ui/src/components/Chip/Chip.tsx
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { View, Text, Pressable, StyleSheet, type ViewStyle } from 'react-native';
|
|
14
|
+
import { useTheme } from '../../theme/useTheme';
|
|
15
|
+
|
|
16
|
+
export type ChipSize = 's' | 'm' | 'l';
|
|
17
|
+
export type ChipVariant = 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'outlined';
|
|
18
|
+
|
|
19
|
+
export interface ChipProps {
|
|
20
|
+
label: string;
|
|
21
|
+
size?: ChipSize;
|
|
22
|
+
variant?: ChipVariant;
|
|
23
|
+
deletable?: boolean;
|
|
24
|
+
onDelete?: () => void;
|
|
25
|
+
onPress?: () => void;
|
|
26
|
+
startIcon?: React.ReactNode;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
selected?: boolean;
|
|
29
|
+
style?: ViewStyle;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const Chip: React.FC<ChipProps> = ({
|
|
33
|
+
label, size = 'm', variant = 'default', deletable = false,
|
|
34
|
+
onDelete, onPress, startIcon, disabled = false, selected = false, style,
|
|
35
|
+
}) => {
|
|
36
|
+
const { theme } = useTheme();
|
|
37
|
+
|
|
38
|
+
const aliases = theme.color.aliases ?? {};
|
|
39
|
+
const feedback = aliases.feedback ?? {};
|
|
40
|
+
const padding = theme.spacing.aliases?.padding ?? {};
|
|
41
|
+
const fontSize = theme.typography.foundation?.fontSize ?? {};
|
|
42
|
+
const disabledOpacity = theme.opacity.foundation?.[40] ?? 0.4;
|
|
43
|
+
|
|
44
|
+
const sizeConfig = {
|
|
45
|
+
s: { height: 24, fontSize: fontSize.xs ?? 12 - 1, paddingH: padding.s ?? 8, gap: padding.xxs ?? 2 },
|
|
46
|
+
m: { height: 32, fontSize: fontSize.xs ?? 12, paddingH: padding.m ?? 12, gap: padding.xs ?? 4 },
|
|
47
|
+
l: { height: 40, fontSize: fontSize.s ?? 14, paddingH: padding.l ?? 20, gap: padding.s ?? 8 },
|
|
48
|
+
}[size];
|
|
49
|
+
|
|
50
|
+
const variantStyles = (() => {
|
|
51
|
+
const colors: Record<string, { bg: string; text: string; border: string }> = {
|
|
52
|
+
default: { bg: aliases.surface?.['layer-2'] ?? '#E8EEF2', text: aliases.text?.primary ?? '#17191A', border: 'transparent' },
|
|
53
|
+
primary: { bg: (aliases.brand?.primary ?? '#006FFF') + '15', text: aliases.brand?.primary ?? '#006FFF', border: 'transparent' },
|
|
54
|
+
success: { bg: feedback.success?.bg ?? '#F0FDF5', text: feedback.success?.fg ?? '#16A34A', border: 'transparent' },
|
|
55
|
+
warning: { bg: feedback.warning?.bg ?? '#FFFFE7', text: feedback.warning?.fg ?? '#D1B400', border: 'transparent' },
|
|
56
|
+
danger: { bg: feedback.error?.bg ?? '#FEF2F2', text: feedback.error?.fg ?? '#DC2626', border: 'transparent' },
|
|
57
|
+
info: { bg: feedback.info?.bg ?? '#EDF9FF', text: feedback.info?.fg ?? '#0683FF', border: 'transparent' },
|
|
58
|
+
outlined: { bg: 'transparent', text: aliases.text?.primary ?? '#17191A', border: aliases.border?.base ?? '#E8EEF2' },
|
|
59
|
+
};
|
|
60
|
+
return colors[variant] || colors.default;
|
|
61
|
+
})();
|
|
62
|
+
|
|
63
|
+
const chipContent = (
|
|
64
|
+
<View style={[
|
|
65
|
+
styles.container,
|
|
66
|
+
{
|
|
67
|
+
height: sizeConfig.height, paddingHorizontal: sizeConfig.paddingH, gap: sizeConfig.gap,
|
|
68
|
+
borderRadius: sizeConfig.height / 2,
|
|
69
|
+
backgroundColor: selected ? (aliases.brand?.primary ?? '#006FFF') + '20' : variantStyles.bg,
|
|
70
|
+
borderWidth: 1,
|
|
71
|
+
borderColor: selected ? (aliases.brand?.primary ?? '#006FFF') : variantStyles.border,
|
|
72
|
+
},
|
|
73
|
+
disabled && { opacity: disabledOpacity }, style,
|
|
74
|
+
]}>
|
|
75
|
+
{startIcon && <View>{startIcon}</View>}
|
|
76
|
+
<Text style={[styles.label, {
|
|
77
|
+
fontSize: sizeConfig.fontSize,
|
|
78
|
+
color: selected ? (aliases.brand?.primary ?? '#006FFF') : variantStyles.text,
|
|
79
|
+
}]}>{label}</Text>
|
|
80
|
+
{deletable && (
|
|
81
|
+
<Pressable onPress={() => !disabled && onDelete?.()} hitSlop={8}
|
|
82
|
+
accessibilityRole="button" accessibilityLabel={`${label} 삭제`}>
|
|
83
|
+
<Text style={[styles.deleteButton, { fontSize: sizeConfig.fontSize, color: variantStyles.text }]}>✕</Text>
|
|
84
|
+
</Pressable>
|
|
85
|
+
)}
|
|
86
|
+
</View>
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
if (onPress) {
|
|
90
|
+
return (
|
|
91
|
+
<Pressable onPress={onPress} disabled={disabled} accessibilityRole="button"
|
|
92
|
+
style={({ pressed }) => pressed ? { opacity: 0.7 } : undefined}>
|
|
93
|
+
{chipContent}
|
|
94
|
+
</Pressable>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
return chipContent;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
Chip.displayName = 'Chip';
|
|
101
|
+
|
|
102
|
+
const styles = StyleSheet.create({
|
|
103
|
+
container: { flexDirection: 'row', alignItems: 'center', alignSelf: 'flex-start' },
|
|
104
|
+
label: { fontWeight: '500' },
|
|
105
|
+
deleteButton: { fontWeight: '600', opacity: 0.6 },
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
export default Chip;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Divider 컴포넌트 (React Native)
|
|
3
|
+
*
|
|
4
|
+
* 스타일링 토큰 경로:
|
|
5
|
+
* - 색상: theme.color.aliases.border.{base|muted}
|
|
6
|
+
* - 간격: theme.spacing.aliases.margin.*
|
|
7
|
+
*
|
|
8
|
+
* 원본: packages/ui/src/components/Divider/Divider.tsx
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { View, type ViewStyle } from 'react-native';
|
|
13
|
+
import { useTheme } from '../../theme/useTheme';
|
|
14
|
+
|
|
15
|
+
export interface DividerProps {
|
|
16
|
+
orientation?: 'horizontal' | 'vertical';
|
|
17
|
+
thickness?: number;
|
|
18
|
+
color?: string;
|
|
19
|
+
length?: number;
|
|
20
|
+
margin?: number;
|
|
21
|
+
style?: ViewStyle;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const Divider: React.FC<DividerProps> = ({
|
|
25
|
+
orientation = 'horizontal', thickness, color, length, margin, style,
|
|
26
|
+
}) => {
|
|
27
|
+
const { theme } = useTheme();
|
|
28
|
+
|
|
29
|
+
const borderWidth = theme.border.foundation?.width ?? {};
|
|
30
|
+
const dividerColor = color ?? theme.color.aliases?.border?.base ?? '#E8EEF2';
|
|
31
|
+
const dividerThickness = thickness ?? borderWidth[2] ?? 1;
|
|
32
|
+
|
|
33
|
+
const dividerStyle: ViewStyle = orientation === 'horizontal'
|
|
34
|
+
? { height: dividerThickness, backgroundColor: dividerColor, width: '100%', marginVertical: margin }
|
|
35
|
+
: { width: dividerThickness, backgroundColor: dividerColor, height: length || '100%', marginHorizontal: margin };
|
|
36
|
+
|
|
37
|
+
return <View style={[dividerStyle, style]} accessibilityRole="none" />;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
Divider.displayName = 'Divider';
|
|
41
|
+
export default Divider;
|