@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.
Files changed (55) hide show
  1. package/COMPONENTS.md +71 -15
  2. package/README.md +23 -3
  3. package/dist/index.d.mts +16 -5
  4. package/dist/index.d.ts +16 -5
  5. package/dist/index.js +441 -327
  6. package/dist/index.mjs +442 -328
  7. package/package.json +6 -3
  8. package/src/assets/fonts/Poppins-Black.ttf +0 -0
  9. package/src/assets/fonts/Poppins-BlackItalic.ttf +0 -0
  10. package/src/assets/fonts/Poppins-Bold.ttf +0 -0
  11. package/src/assets/fonts/Poppins-BoldItalic.ttf +0 -0
  12. package/src/assets/fonts/Poppins-ExtraBold.ttf +0 -0
  13. package/src/assets/fonts/Poppins-ExtraBoldItalic.ttf +0 -0
  14. package/src/assets/fonts/Poppins-ExtraLight.ttf +0 -0
  15. package/src/assets/fonts/Poppins-ExtraLightItalic.ttf +0 -0
  16. package/src/assets/fonts/Poppins-Italic.ttf +0 -0
  17. package/src/assets/fonts/Poppins-Light.ttf +0 -0
  18. package/src/assets/fonts/Poppins-LightItalic.ttf +0 -0
  19. package/src/assets/fonts/Poppins-Medium.ttf +0 -0
  20. package/src/assets/fonts/Poppins-MediumItalic.ttf +0 -0
  21. package/src/assets/fonts/Poppins-Regular.ttf +0 -0
  22. package/src/assets/fonts/Poppins-SemiBold.ttf +0 -0
  23. package/src/assets/fonts/Poppins-SemiBoldItalic.ttf +0 -0
  24. package/src/assets/fonts/Poppins-Thin.ttf +0 -0
  25. package/src/assets/fonts/Poppins-ThinItalic.ttf +0 -0
  26. package/src/components/Accordion/Accordion.tsx +16 -9
  27. package/src/components/AlertBanner/AlertBanner.tsx +35 -35
  28. package/src/components/Avatar/Avatar.tsx +1 -1
  29. package/src/components/Badge/Badge.tsx +12 -8
  30. package/src/components/Button/Button.tsx +8 -8
  31. package/src/components/Card/Card.tsx +12 -9
  32. package/src/components/Checkbox/Checkbox.tsx +8 -8
  33. package/src/components/Chip/Chip.tsx +22 -6
  34. package/src/components/ConfirmDialog/ConfirmDialog.tsx +86 -38
  35. package/src/components/CurrencyDisplay/CurrencyDisplay.tsx +1 -1
  36. package/src/components/CurrencyInput/CurrencyInput.tsx +11 -4
  37. package/src/components/EmptyState/EmptyState.tsx +2 -1
  38. package/src/components/Input/Input.tsx +12 -8
  39. package/src/components/LabelValue/LabelValue.tsx +4 -3
  40. package/src/components/ListItem/ListItem.tsx +10 -9
  41. package/src/components/MonthPicker/MonthPicker.tsx +1 -1
  42. package/src/components/RadioGroup/RadioGroup.tsx +36 -36
  43. package/src/components/Select/Select.tsx +17 -19
  44. package/src/components/Sheet/Sheet.tsx +2 -1
  45. package/src/components/Slider/Slider.tsx +3 -3
  46. package/src/components/Spinner/Spinner.tsx +36 -2
  47. package/src/components/Switch/Switch.tsx +4 -4
  48. package/src/components/Tabs/Tabs.tsx +9 -16
  49. package/src/components/Text/Text.tsx +6 -6
  50. package/src/components/Textarea/Textarea.tsx +8 -6
  51. package/src/components/Toast/Toast.tsx +27 -21
  52. package/src/components/Toggle/Toggle.tsx +6 -4
  53. package/src/fonts.ts +30 -0
  54. package/src/theme/colors.ts +22 -14
  55. 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
- <View style={styles.triggerIcon}>
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(12),
195
- paddingHorizontal: s(16),
196
- borderRadius: ms(8),
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(8),
206
- },
207
- triggerIcon: {
208
- marginRight: s(6),
209
- alignItems: 'center',
210
- justifyContent: 'center',
203
+ gap: s(4),
211
204
  },
212
205
  triggerLabel: {
213
- fontSize: ms(15),
214
- fontWeight: '400',
206
+ fontFamily: 'Poppins-Regular',
207
+ fontSize: ms(13),
215
208
  },
216
209
  activeTriggerLabel: {
217
- fontWeight: '500',
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: { fontSize: ms(40), fontWeight: '700', lineHeight: mvs(52) },
15
- h2: { fontSize: ms(28), fontWeight: '700', lineHeight: mvs(36) },
16
- h3: { fontSize: ms(22), fontWeight: '600', lineHeight: mvs(30) },
17
- body: { fontSize: ms(17), fontWeight: '400', lineHeight: mvs(26) },
18
- caption: { fontSize: ms(13), fontWeight: '400', lineHeight: mvs(20) },
19
- label: { fontSize: ms(15), fontWeight: '500', lineHeight: mvs(22) },
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
- fontSize: ms(15),
87
- fontWeight: '500',
86
+ fontFamily: 'Poppins-Medium',
87
+ fontSize: ms(13),
88
88
  },
89
89
  input: {
90
- borderWidth: 1.5,
90
+ fontFamily: 'Poppins-Regular',
91
+ borderWidth: 1,
91
92
  borderRadius: ms(8),
92
- paddingHorizontal: s(16),
93
- paddingVertical: vs(14),
94
- fontSize: ms(17),
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.destructive,
102
- success: colors.success,
103
- }[item.variant ?? 'default']
103
+ destructive: colors.destructiveBorder,
104
+ success: colors.successBorder,
105
+ }[variant]
104
106
 
105
107
  const textColor = {
106
108
  default: colors.background,
107
- destructive: colors.destructiveForeground,
108
- success: colors.successForeground,
109
- }[item.variant ?? 'default']
109
+ destructive: '#991b1b',
110
+ success: '#166534',
111
+ }[variant]
112
+
113
+ const borderColor = textColor
110
114
 
111
115
  const defaultIcon =
112
- item.variant === 'success' ? (
113
- <FontAwesome5 name="check-circle" size={22} color={textColor} />
114
- ) : item.variant === 'destructive' ? (
115
- <MaterialIcons name="error-outline" size={24} color={textColor} />
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={22} color={textColor} />
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(16),
205
- paddingHorizontal: s(20),
206
- paddingVertical: vs(14),
208
+ borderRadius: ms(12),
209
+ borderWidth: 1,
210
+ paddingHorizontal: s(14),
211
+ paddingVertical: vs(12),
207
212
  shadowColor: '#000',
208
- shadowOffset: { width: 0, height: 4 },
209
- shadowOpacity: 0.15,
213
+ shadowOffset: { width: 0, height: 3 },
214
+ shadowOpacity: 0.10,
210
215
  shadowRadius: 8,
211
- elevation: 6,
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(40),
223
+ width: s(28),
219
224
  alignItems: 'center',
220
225
  justifyContent: 'center',
221
- marginRight: s(8),
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: true, speed: 40, bounciness: 0 }).start()
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: true, speed: 40, bounciness: 4 }).start()
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
@@ -15,32 +15,40 @@ export const defaultLight: ThemeColors = {
15
15
  accent: '#e4e4e4',
16
16
  accentForeground: '#171717',
17
17
  destructive: '#ef4444',
18
- destructiveForeground: '#1a1a1a',
18
+ destructiveForeground: '#ffffff',
19
19
  border: '#e5e5e5',
20
20
  input: '#e5e5e5',
21
21
  ring: '#1a1a1a',
22
- success: '#16a34a',
23
- successForeground: '#1a1a1a',
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: '#171717',
31
+ background: '#0f0f0f',
28
32
  foreground: '#fafafa',
29
- card: '#222222',
33
+ card: '#1c1c1c',
30
34
  cardForeground: '#fafafa',
31
35
  primary: '#fafafa',
32
- primaryForeground: '#1a1a1a',
33
- secondary: '#323232',
36
+ primaryForeground: '#0f0f0f',
37
+ secondary: '#272727',
34
38
  secondaryForeground: '#fafafa',
35
- muted: '#323232',
36
- mutedForeground: '#888888',
37
- accent: '#323232',
39
+ muted: '#272727',
40
+ mutedForeground: '#9a9a9a',
41
+ accent: '#2e2e2e',
38
42
  accentForeground: '#fafafa',
39
43
  destructive: '#dc2626',
40
- destructiveForeground: '#1a1a1a',
41
- border: '#2a2a2a',
44
+ destructiveForeground: '#ffffff',
45
+ border: '#303030',
42
46
  input: '#2a2a2a',
43
47
  ring: '#fafafa',
44
- success: '#22c55e',
45
- successForeground: '#1a1a1a',
48
+ success: '#166534',
49
+ successForeground: '#ffffff',
50
+ destructiveTint: '#3b0a0a',
51
+ destructiveBorder: '#7f1d1d',
52
+ successTint: '#052e16',
53
+ successBorder: '#166534',
46
54
  }
@@ -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