@retray-dev/ui-kit 2.8.0 → 3.0.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/COMPONENTS.md +71 -15
- package/README.md +23 -3
- package/dist/index.d.mts +16 -5
- package/dist/index.d.ts +16 -5
- package/dist/index.js +441 -327
- package/dist/index.mjs +442 -328
- package/package.json +6 -3
- package/src/assets/fonts/Poppins-Black.ttf +0 -0
- package/src/assets/fonts/Poppins-BlackItalic.ttf +0 -0
- package/src/assets/fonts/Poppins-Bold.ttf +0 -0
- package/src/assets/fonts/Poppins-BoldItalic.ttf +0 -0
- package/src/assets/fonts/Poppins-ExtraBold.ttf +0 -0
- package/src/assets/fonts/Poppins-ExtraBoldItalic.ttf +0 -0
- package/src/assets/fonts/Poppins-ExtraLight.ttf +0 -0
- package/src/assets/fonts/Poppins-ExtraLightItalic.ttf +0 -0
- package/src/assets/fonts/Poppins-Italic.ttf +0 -0
- package/src/assets/fonts/Poppins-Light.ttf +0 -0
- package/src/assets/fonts/Poppins-LightItalic.ttf +0 -0
- package/src/assets/fonts/Poppins-Medium.ttf +0 -0
- package/src/assets/fonts/Poppins-MediumItalic.ttf +0 -0
- package/src/assets/fonts/Poppins-Regular.ttf +0 -0
- package/src/assets/fonts/Poppins-SemiBold.ttf +0 -0
- package/src/assets/fonts/Poppins-SemiBoldItalic.ttf +0 -0
- package/src/assets/fonts/Poppins-Thin.ttf +0 -0
- package/src/assets/fonts/Poppins-ThinItalic.ttf +0 -0
- package/src/components/Accordion/Accordion.tsx +16 -9
- package/src/components/AlertBanner/AlertBanner.tsx +35 -35
- package/src/components/Avatar/Avatar.tsx +1 -1
- package/src/components/Badge/Badge.tsx +12 -8
- package/src/components/Button/Button.tsx +8 -8
- package/src/components/Card/Card.tsx +12 -9
- package/src/components/Checkbox/Checkbox.tsx +8 -8
- package/src/components/Chip/Chip.tsx +22 -6
- package/src/components/ConfirmDialog/ConfirmDialog.tsx +86 -38
- package/src/components/CurrencyDisplay/CurrencyDisplay.tsx +1 -1
- package/src/components/CurrencyInput/CurrencyInput.tsx +11 -4
- package/src/components/EmptyState/EmptyState.tsx +2 -1
- package/src/components/Input/Input.tsx +12 -8
- package/src/components/LabelValue/LabelValue.tsx +4 -3
- package/src/components/ListItem/ListItem.tsx +10 -9
- package/src/components/MonthPicker/MonthPicker.tsx +1 -1
- package/src/components/RadioGroup/RadioGroup.tsx +36 -36
- package/src/components/Select/Select.tsx +17 -19
- package/src/components/Sheet/Sheet.tsx +2 -1
- package/src/components/Slider/Slider.tsx +3 -3
- package/src/components/Spinner/Spinner.tsx +36 -2
- package/src/components/Switch/Switch.tsx +4 -4
- package/src/components/Tabs/Tabs.tsx +9 -16
- package/src/components/Text/Text.tsx +6 -6
- package/src/components/Textarea/Textarea.tsx +8 -6
- package/src/components/Toast/Toast.tsx +27 -21
- package/src/components/Toggle/Toggle.tsx +6 -4
- package/src/fonts.ts +30 -0
- package/src/theme/colors.ts +22 -14
- package/src/theme/types.ts +4 -0
|
@@ -9,7 +9,7 @@ import { s, vs, ms } from '../../utils/scaling'
|
|
|
9
9
|
export interface TabItem {
|
|
10
10
|
label: string
|
|
11
11
|
value: string
|
|
12
|
-
icon?: React.ReactNode
|
|
12
|
+
icon?: React.ReactNode | ((active: boolean) => React.ReactNode)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export interface TabsProps {
|
|
@@ -66,9 +66,7 @@ function TabTrigger({
|
|
|
66
66
|
<Animated.View style={{ transform: [{ scale }] }}>
|
|
67
67
|
<View style={styles.triggerInner}>
|
|
68
68
|
{tab.icon ? (
|
|
69
|
-
|
|
70
|
-
{(typeof tab.icon === 'function' ? (tab.icon as any)(isActive) : tab.icon) as React.ReactNode}
|
|
71
|
-
</View>
|
|
69
|
+
(typeof tab.icon === 'function' ? (tab.icon as any)(isActive) : tab.icon) as React.ReactNode
|
|
72
70
|
) : null}
|
|
73
71
|
<Text
|
|
74
72
|
style={[
|
|
@@ -191,9 +189,9 @@ const styles = StyleSheet.create({
|
|
|
191
189
|
pill: {},
|
|
192
190
|
trigger: {
|
|
193
191
|
flex: 1,
|
|
194
|
-
paddingVertical: vs(
|
|
195
|
-
paddingHorizontal: s(
|
|
196
|
-
borderRadius: ms(
|
|
192
|
+
paddingVertical: vs(7),
|
|
193
|
+
paddingHorizontal: s(10),
|
|
194
|
+
borderRadius: ms(6),
|
|
197
195
|
alignItems: 'center',
|
|
198
196
|
justifyContent: 'center',
|
|
199
197
|
zIndex: 1,
|
|
@@ -202,18 +200,13 @@ const styles = StyleSheet.create({
|
|
|
202
200
|
flexDirection: 'row',
|
|
203
201
|
alignItems: 'center',
|
|
204
202
|
justifyContent: 'center',
|
|
205
|
-
gap: s(
|
|
206
|
-
},
|
|
207
|
-
triggerIcon: {
|
|
208
|
-
marginRight: s(6),
|
|
209
|
-
alignItems: 'center',
|
|
210
|
-
justifyContent: 'center',
|
|
203
|
+
gap: s(4),
|
|
211
204
|
},
|
|
212
205
|
triggerLabel: {
|
|
213
|
-
|
|
214
|
-
|
|
206
|
+
fontFamily: 'Poppins-Regular',
|
|
207
|
+
fontSize: ms(13),
|
|
215
208
|
},
|
|
216
209
|
activeTriggerLabel: {
|
|
217
|
-
|
|
210
|
+
fontFamily: 'Poppins-Medium',
|
|
218
211
|
},
|
|
219
212
|
})
|
|
@@ -11,12 +11,12 @@ export interface TextProps extends RNTextProps {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const variantStyles: Record<TextVariant, TextStyle> = {
|
|
14
|
-
h1:
|
|
15
|
-
h2:
|
|
16
|
-
h3:
|
|
17
|
-
body:
|
|
18
|
-
caption: { fontSize: ms(13),
|
|
19
|
-
label:
|
|
14
|
+
h1: { fontFamily: 'Poppins-Bold', fontSize: ms(40), lineHeight: mvs(52) },
|
|
15
|
+
h2: { fontFamily: 'Poppins-Bold', fontSize: ms(28), lineHeight: mvs(36) },
|
|
16
|
+
h3: { fontFamily: 'Poppins-SemiBold', fontSize: ms(22), lineHeight: mvs(30) },
|
|
17
|
+
body: { fontFamily: 'Poppins-Regular', fontSize: ms(17), lineHeight: mvs(26) },
|
|
18
|
+
caption: { fontFamily: 'Poppins-Regular', fontSize: ms(13), lineHeight: mvs(20) },
|
|
19
|
+
label: { fontFamily: 'Poppins-Medium', fontSize: ms(15), lineHeight: mvs(22) },
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export function Text({ variant = 'body', color, style, children, ...props }: TextProps) {
|
|
@@ -83,17 +83,19 @@ const styles = StyleSheet.create({
|
|
|
83
83
|
gap: vs(8),
|
|
84
84
|
},
|
|
85
85
|
label: {
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
fontFamily: 'Poppins-Medium',
|
|
87
|
+
fontSize: ms(13),
|
|
88
88
|
},
|
|
89
89
|
input: {
|
|
90
|
-
|
|
90
|
+
fontFamily: 'Poppins-Regular',
|
|
91
|
+
borderWidth: 1,
|
|
91
92
|
borderRadius: ms(8),
|
|
92
|
-
paddingHorizontal: s(
|
|
93
|
-
paddingVertical: vs(
|
|
94
|
-
fontSize: ms(
|
|
93
|
+
paddingHorizontal: s(14),
|
|
94
|
+
paddingVertical: vs(11),
|
|
95
|
+
fontSize: ms(15),
|
|
95
96
|
},
|
|
96
97
|
helperText: {
|
|
98
|
+
fontFamily: 'Poppins-Regular',
|
|
97
99
|
fontSize: ms(13),
|
|
98
100
|
},
|
|
99
101
|
})
|
|
@@ -96,25 +96,29 @@ function ToastNotification({ item, onDismiss }: { item: ToastItem; onDismiss: ()
|
|
|
96
96
|
transform: [{ translateY: translateY.value }, { translateX: translateX.value }],
|
|
97
97
|
}))
|
|
98
98
|
|
|
99
|
+
const variant = item.variant ?? 'default'
|
|
100
|
+
|
|
99
101
|
const bgColor = {
|
|
100
102
|
default: colors.foreground,
|
|
101
|
-
destructive: colors.
|
|
102
|
-
success: colors.
|
|
103
|
-
}[
|
|
103
|
+
destructive: colors.destructiveBorder,
|
|
104
|
+
success: colors.successBorder,
|
|
105
|
+
}[variant]
|
|
104
106
|
|
|
105
107
|
const textColor = {
|
|
106
108
|
default: colors.background,
|
|
107
|
-
destructive:
|
|
108
|
-
success:
|
|
109
|
-
}[
|
|
109
|
+
destructive: '#991b1b',
|
|
110
|
+
success: '#166534',
|
|
111
|
+
}[variant]
|
|
112
|
+
|
|
113
|
+
const borderColor = textColor
|
|
110
114
|
|
|
111
115
|
const defaultIcon =
|
|
112
|
-
|
|
113
|
-
<FontAwesome5 name="check-circle" size={
|
|
114
|
-
) :
|
|
115
|
-
<
|
|
116
|
+
variant === 'success' ? (
|
|
117
|
+
<FontAwesome5 name="check-circle" size={18} color={textColor} />
|
|
118
|
+
) : variant === 'destructive' ? (
|
|
119
|
+
<AntDesign name="exclamation-circle" size={18} color={textColor} />
|
|
116
120
|
) : (
|
|
117
|
-
<Entypo name="info-with-circle" size={
|
|
121
|
+
<Entypo name="info-with-circle" size={18} color={textColor} />
|
|
118
122
|
)
|
|
119
123
|
|
|
120
124
|
const leftIcon: React.ReactNode = item.iconName
|
|
@@ -123,7 +127,7 @@ function ToastNotification({ item, onDismiss }: { item: ToastItem; onDismiss: ()
|
|
|
123
127
|
|
|
124
128
|
return (
|
|
125
129
|
<GestureDetector gesture={panGesture}>
|
|
126
|
-
<Animated.View style={[styles.toast, { backgroundColor: bgColor }, animatedStyle]}>
|
|
130
|
+
<Animated.View style={[styles.toast, { backgroundColor: bgColor, borderColor }, animatedStyle]}>
|
|
127
131
|
<View style={styles.leftIconContainer}>{leftIcon}</View>
|
|
128
132
|
<View style={styles.toastContent}>
|
|
129
133
|
{item.title ? (
|
|
@@ -201,30 +205,32 @@ const styles = StyleSheet.create({
|
|
|
201
205
|
toast: {
|
|
202
206
|
flexDirection: 'row',
|
|
203
207
|
alignItems: 'center',
|
|
204
|
-
borderRadius: ms(
|
|
205
|
-
|
|
206
|
-
|
|
208
|
+
borderRadius: ms(12),
|
|
209
|
+
borderWidth: 1,
|
|
210
|
+
paddingHorizontal: s(14),
|
|
211
|
+
paddingVertical: vs(12),
|
|
207
212
|
shadowColor: '#000',
|
|
208
|
-
shadowOffset: { width: 0, height:
|
|
209
|
-
shadowOpacity: 0.
|
|
213
|
+
shadowOffset: { width: 0, height: 3 },
|
|
214
|
+
shadowOpacity: 0.10,
|
|
210
215
|
shadowRadius: 8,
|
|
211
|
-
elevation:
|
|
216
|
+
elevation: 5,
|
|
212
217
|
},
|
|
213
218
|
toastContent: {
|
|
214
219
|
flex: 1,
|
|
215
220
|
gap: vs(4),
|
|
216
221
|
},
|
|
217
222
|
leftIconContainer: {
|
|
218
|
-
width: s(
|
|
223
|
+
width: s(28),
|
|
219
224
|
alignItems: 'center',
|
|
220
225
|
justifyContent: 'center',
|
|
221
|
-
marginRight: s(
|
|
226
|
+
marginRight: s(10),
|
|
222
227
|
},
|
|
223
228
|
toastTitle: {
|
|
229
|
+
fontFamily: 'Poppins-SemiBold',
|
|
224
230
|
fontSize: ms(15),
|
|
225
|
-
fontWeight: '600',
|
|
226
231
|
},
|
|
227
232
|
toastDescription: {
|
|
233
|
+
fontFamily: 'Poppins-Regular',
|
|
228
234
|
fontSize: ms(14),
|
|
229
235
|
},
|
|
230
236
|
dismissButton: {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { useRef, useEffect } from 'react'
|
|
2
|
-
import { TouchableOpacity, Animated, StyleSheet, TouchableOpacityProps, ViewStyle, View, Easing } from 'react-native'
|
|
2
|
+
import { TouchableOpacity, Animated, StyleSheet, TouchableOpacityProps, ViewStyle, View, Easing, Platform } from 'react-native'
|
|
3
|
+
|
|
4
|
+
const nativeDriver = Platform.OS !== 'web'
|
|
3
5
|
import { FontAwesome5 } from '@expo/vector-icons'
|
|
4
6
|
import { selectionAsync as hapticSelection } from '../../utils/haptics'
|
|
5
7
|
import { useTheme } from '../../theme'
|
|
@@ -75,11 +77,11 @@ export function Toggle({
|
|
|
75
77
|
|
|
76
78
|
const handlePressIn = () => {
|
|
77
79
|
if (disabled) return
|
|
78
|
-
Animated.spring(scale, { toValue: 0.95, useNativeDriver:
|
|
80
|
+
Animated.spring(scale, { toValue: 0.95, useNativeDriver: nativeDriver, speed: 40, bounciness: 0 }).start()
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
const handlePressOut = () => {
|
|
82
|
-
Animated.spring(scale, { toValue: 1, useNativeDriver:
|
|
84
|
+
Animated.spring(scale, { toValue: 1, useNativeDriver: nativeDriver, speed: 40, bounciness: 4 }).start()
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
// Keep borderWidth constant at 2 to prevent layout jumps when pressing.
|
|
@@ -168,7 +170,7 @@ const styles = StyleSheet.create({
|
|
|
168
170
|
opacity: 0.45,
|
|
169
171
|
},
|
|
170
172
|
label: {
|
|
173
|
+
fontFamily: 'Poppins-Medium',
|
|
171
174
|
fontSize: ms(14),
|
|
172
|
-
fontWeight: '500',
|
|
173
175
|
},
|
|
174
176
|
})
|
package/src/fonts.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Poppins font family required by @retray-dev/ui-kit components.
|
|
3
|
+
*
|
|
4
|
+
* Consumer apps must load these fonts at app root using expo-font:
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* import { useFonts } from 'expo-font'
|
|
8
|
+
* import { PoppinsFonts } from '@retray-dev/ui-kit'
|
|
9
|
+
*
|
|
10
|
+
* function App() {
|
|
11
|
+
* const [fontsLoaded] = useFonts(PoppinsFonts)
|
|
12
|
+
* if (!fontsLoaded) return null
|
|
13
|
+
* // render app
|
|
14
|
+
* }
|
|
15
|
+
*/
|
|
16
|
+
export const PoppinsFonts = {
|
|
17
|
+
'Poppins-Thin': require('./assets/fonts/Poppins-Thin.ttf'),
|
|
18
|
+
'Poppins-ExtraLight': require('./assets/fonts/Poppins-ExtraLight.ttf'),
|
|
19
|
+
'Poppins-Light': require('./assets/fonts/Poppins-Light.ttf'),
|
|
20
|
+
'Poppins-Regular': require('./assets/fonts/Poppins-Regular.ttf'),
|
|
21
|
+
'Poppins-Medium': require('./assets/fonts/Poppins-Medium.ttf'),
|
|
22
|
+
'Poppins-SemiBold': require('./assets/fonts/Poppins-SemiBold.ttf'),
|
|
23
|
+
'Poppins-Bold': require('./assets/fonts/Poppins-Bold.ttf'),
|
|
24
|
+
'Poppins-ExtraBold': require('./assets/fonts/Poppins-ExtraBold.ttf'),
|
|
25
|
+
'Poppins-Black': require('./assets/fonts/Poppins-Black.ttf'),
|
|
26
|
+
'Poppins-Italic': require('./assets/fonts/Poppins-Italic.ttf'),
|
|
27
|
+
'Poppins-MediumItalic': require('./assets/fonts/Poppins-MediumItalic.ttf'),
|
|
28
|
+
'Poppins-SemiBoldItalic': require('./assets/fonts/Poppins-SemiBoldItalic.ttf'),
|
|
29
|
+
'Poppins-BoldItalic': require('./assets/fonts/Poppins-BoldItalic.ttf'),
|
|
30
|
+
} as const
|
package/src/theme/colors.ts
CHANGED
|
@@ -15,32 +15,40 @@ export const defaultLight: ThemeColors = {
|
|
|
15
15
|
accent: '#e4e4e4',
|
|
16
16
|
accentForeground: '#171717',
|
|
17
17
|
destructive: '#ef4444',
|
|
18
|
-
destructiveForeground: '#
|
|
18
|
+
destructiveForeground: '#ffffff',
|
|
19
19
|
border: '#e5e5e5',
|
|
20
20
|
input: '#e5e5e5',
|
|
21
21
|
ring: '#1a1a1a',
|
|
22
|
-
success: '#
|
|
23
|
-
successForeground: '#
|
|
22
|
+
success: '#1a7a45',
|
|
23
|
+
successForeground: '#ffffff',
|
|
24
|
+
destructiveTint: '#fff5f5',
|
|
25
|
+
destructiveBorder: '#fecaca',
|
|
26
|
+
successTint: '#f0fdf4',
|
|
27
|
+
successBorder: '#bbf7d0',
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
export const defaultDark: ThemeColors = {
|
|
27
|
-
background: '#
|
|
31
|
+
background: '#0f0f0f',
|
|
28
32
|
foreground: '#fafafa',
|
|
29
|
-
card: '#
|
|
33
|
+
card: '#1c1c1c',
|
|
30
34
|
cardForeground: '#fafafa',
|
|
31
35
|
primary: '#fafafa',
|
|
32
|
-
primaryForeground: '#
|
|
33
|
-
secondary: '#
|
|
36
|
+
primaryForeground: '#0f0f0f',
|
|
37
|
+
secondary: '#272727',
|
|
34
38
|
secondaryForeground: '#fafafa',
|
|
35
|
-
muted: '#
|
|
36
|
-
mutedForeground: '#
|
|
37
|
-
accent: '#
|
|
39
|
+
muted: '#272727',
|
|
40
|
+
mutedForeground: '#9a9a9a',
|
|
41
|
+
accent: '#2e2e2e',
|
|
38
42
|
accentForeground: '#fafafa',
|
|
39
43
|
destructive: '#dc2626',
|
|
40
|
-
destructiveForeground: '#
|
|
41
|
-
border: '#
|
|
44
|
+
destructiveForeground: '#ffffff',
|
|
45
|
+
border: '#303030',
|
|
42
46
|
input: '#2a2a2a',
|
|
43
47
|
ring: '#fafafa',
|
|
44
|
-
success: '#
|
|
45
|
-
successForeground: '#
|
|
48
|
+
success: '#166534',
|
|
49
|
+
successForeground: '#ffffff',
|
|
50
|
+
destructiveTint: '#3b0a0a',
|
|
51
|
+
destructiveBorder: '#7f1d1d',
|
|
52
|
+
successTint: '#052e16',
|
|
53
|
+
successBorder: '#166534',
|
|
46
54
|
}
|
package/src/theme/types.ts
CHANGED
|
@@ -18,6 +18,10 @@ export type ThemeColors = {
|
|
|
18
18
|
ring: string
|
|
19
19
|
success: string
|
|
20
20
|
successForeground: string
|
|
21
|
+
destructiveTint: string
|
|
22
|
+
destructiveBorder: string
|
|
23
|
+
successTint: string
|
|
24
|
+
successBorder: string
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
// Theme overrides: consumers may supply partial or full `ThemeColors` objects
|