react-native-varia 0.0.1 → 0.2.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 (86) hide show
  1. package/bin/cli.js +35 -18
  2. package/lib/components/Badge.tsx +31 -32
  3. package/lib/components/Button.tsx +20 -20
  4. package/lib/components/Checkbox.tsx +95 -0
  5. package/lib/components/CircleProgress.tsx +56 -66
  6. package/lib/components/Field.tsx +137 -0
  7. package/lib/components/GradientBackground.tsx +17 -18
  8. package/lib/components/GradientText.tsx +25 -64
  9. package/lib/components/IconWrapper.tsx +32 -25
  10. package/lib/components/Input.tsx +66 -68
  11. package/lib/components/Link.tsx +14 -28
  12. package/lib/components/Modal.tsx +197 -97
  13. package/lib/components/NewSelect.tsx +202 -0
  14. package/lib/components/NumberInput.tsx +226 -0
  15. package/lib/components/RadioGroup.tsx +195 -0
  16. package/lib/components/ReText.tsx +53 -87
  17. package/lib/components/Select.tsx +272 -0
  18. package/lib/components/SelectOld.tsx +153 -0
  19. package/lib/components/Slider.tsx +32 -40
  20. package/lib/components/Slideshow.tsx +174 -261
  21. package/lib/components/SlidingDrawer.tsx +216 -265
  22. package/lib/components/Spinner.tsx +21 -12
  23. package/lib/components/Switch.tsx +133 -180
  24. package/lib/components/Switchold.tsx +174 -0
  25. package/lib/components/Text.tsx +36 -83
  26. package/lib/components/layoutTest.tsx +74 -0
  27. package/lib/patterns/index.tsx +143 -202
  28. package/lib/theme/Badge.recipe.tsx +44 -39
  29. package/lib/theme/Button.recipe.tsx +139 -48
  30. package/lib/theme/Checkbox.recipe.tsx +121 -0
  31. package/lib/theme/CircleProgress.recipe.tsx +16 -22
  32. package/lib/theme/Field.recipe.tsx +66 -0
  33. package/lib/theme/GradientBackground.recipe.tsx +7 -20
  34. package/lib/theme/GradientText.recipe.tsx +42 -28
  35. package/lib/theme/IconWrapper.recipe.tsx +10 -85
  36. package/lib/theme/Input.recipe.tsx +76 -83
  37. package/lib/theme/Link.recipe.tsx +16 -43
  38. package/lib/theme/Modal.recipe.tsx +59 -21
  39. package/lib/theme/NumberInput.recipe.tsx +191 -0
  40. package/lib/theme/RadioGroup.recipe.tsx +163 -0
  41. package/lib/theme/ReText.recipe.tsx +4 -7
  42. package/lib/theme/Select.recipe.tsx +121 -0
  43. package/lib/theme/Slider.recipe.tsx +97 -181
  44. package/lib/theme/Slideshow.recipe.tsx +24 -102
  45. package/lib/theme/SlidingDrawer.recipe.tsx +21 -59
  46. package/lib/theme/Spinner.recipe.tsx +28 -3
  47. package/lib/theme/Switch.recipe.tsx +75 -54
  48. package/lib/theme/Text.recipe.tsx +66 -8
  49. package/lib/theme/animations.tsx +13 -0
  50. package/lib/varia/colorPalettes/amber.ts +54 -0
  51. package/lib/varia/colorPalettes/blue.ts +54 -0
  52. package/lib/varia/colorPalettes/bronze.ts +54 -0
  53. package/lib/varia/colorPalettes/brown.ts +54 -0
  54. package/lib/varia/colorPalettes/crimson.ts +55 -0
  55. package/lib/varia/colorPalettes/cyan.ts +54 -0
  56. package/lib/varia/colorPalettes/gold.ts +54 -0
  57. package/lib/varia/colorPalettes/grass.ts +54 -0
  58. package/lib/varia/colorPalettes/green.ts +54 -0
  59. package/lib/varia/colorPalettes/indigo.ts +54 -0
  60. package/lib/varia/colorPalettes/iris.ts +54 -0
  61. package/lib/varia/colorPalettes/jade.ts +54 -0
  62. package/lib/varia/colorPalettes/lime.ts +55 -0
  63. package/lib/varia/colorPalettes/mauve.ts +54 -0
  64. package/lib/varia/colorPalettes/mint.ts +54 -0
  65. package/lib/varia/colorPalettes/neutral.ts +54 -0
  66. package/lib/varia/colorPalettes/olive.ts +54 -0
  67. package/lib/varia/colorPalettes/orange.ts +54 -0
  68. package/lib/varia/colorPalettes/pink.ts +54 -0
  69. package/lib/varia/colorPalettes/plum.ts +54 -0
  70. package/lib/varia/colorPalettes/purple.ts +56 -0
  71. package/lib/varia/colorPalettes/red.ts +55 -0
  72. package/lib/varia/colorPalettes/ruby.ts +56 -0
  73. package/lib/varia/colorPalettes/sage.ts +56 -0
  74. package/lib/varia/colorPalettes/sand.ts +56 -0
  75. package/lib/varia/colorPalettes/sky.ts +56 -0
  76. package/lib/varia/colorPalettes/slate.ts +56 -0
  77. package/lib/varia/colorPalettes/teal.ts +56 -0
  78. package/lib/varia/colorPalettes/tomato.ts +56 -0
  79. package/lib/varia/colorPalettes/violet.ts +56 -0
  80. package/lib/varia/colorPalettes/yellow.ts +56 -0
  81. package/lib/varia/defaultTheme.ts +174 -0
  82. package/lib/varia/mixins.ts +223 -0
  83. package/lib/varia/textStyles.ts +48 -0
  84. package/lib/varia/types.ts +277 -0
  85. package/lib/varia/utils.ts +283 -0
  86. package/package.json +1 -1
@@ -1,286 +1,243 @@
1
- import type { StyleProp, ViewStyle } from 'react-native';
2
- import { Gesture, GestureDetector } from 'react-native-gesture-handler';
3
- import React, { forwardRef, useImperativeHandle } from 'react';
4
- import { StyleSheet, UnistylesVariants } from 'react-native-unistyles';
1
+ import {Gesture, GestureDetector} from 'react-native-gesture-handler'
2
+ import React, {useImperativeHandle} from 'react'
3
+ import {StyleSheet, UnistylesVariants} from 'react-native-unistyles'
5
4
  import Animated, {
6
5
  useAnimatedStyle,
7
6
  useSharedValue,
8
7
  withSpring,
9
8
  withTiming,
10
9
  type SharedValue,
11
- } from 'react-native-reanimated';
12
- import {runOnJS} from 'react-native-worklets';
13
- // import type { SpringConfig } from 'react-native-reanimated/lib/typescript/animation/springUtils';
14
-
15
- // import type {
16
- // SlidingDrawerAnimationVariants,
17
- // SlidingDrawerColorSchemeVariants,
18
- // } from '../style/styles/types';
19
- // import { useTokens } from '../style/useTokens';
20
- import {SlidingDrawerTokens, SlidingDrawerStyles} from '../theme/SlidingDrawer.recipe';
10
+ } from 'react-native-reanimated'
11
+ import {runOnJS} from 'react-native-worklets'
12
+ import {
13
+ SlidingDrawerTokens,
14
+ SlidingDrawerStyles,
15
+ } from '../theme/SlidingDrawer.recipe'
16
+ import {PalettesWithNestedKeys} from '../style/varia/types'
21
17
 
22
18
  export type SlidingDrawerRef = {
23
- snapTo: (point: number) => void | null;
24
- expand: () => void | null;
25
- collapse: () => void | null;
26
- };
19
+ snapTo: (point: number) => void | null
20
+ expand: () => void | null
21
+ collapse: () => void | null
22
+ }
27
23
 
28
- type SlidingDrawerVariants = UnistylesVariants<typeof SlidingDrawerStyles>;
24
+ type SlidingDrawerVariants = UnistylesVariants<typeof SlidingDrawerStyles>
29
25
 
30
26
  type SlidingDrawerProps = SlidingDrawerVariants & {
31
- // colorScheme?: keyof typeof SlidingDrawerTokens.variants.colorPalette;
32
- animation?: keyof typeof SlidingDrawerTokens.variants.animation;
33
- flex?: number;
34
- direction?: 1 | -1;
35
- onCollapse?: () => void;
36
- onExpand?: () => void;
37
- onSnap?: (point: number) => void;
38
- snapPoints: number[];
39
- axis: 'y' | 'x';
40
- allowGestures?: boolean;
41
- overlay?: boolean;
42
- children?: React.ReactNode;
43
- // style?: StyleProp<ViewStyle>;
44
- // mixins?: StyleProp<ViewStyle> | StyleProp<ViewStyle>[];
45
- ref?: React.RefObject<SlidingDrawerRef>;
27
+ colorPalette?: PalettesWithNestedKeys
28
+ animation?: keyof typeof SlidingDrawerTokens.variants.animation
29
+ flex?: number
30
+ direction?: 1 | -1
31
+ onCollapse?: () => void
32
+ onExpand?: () => void
33
+ onSnap?: (point: number) => void
34
+ snapPoints: number[]
35
+ axis: 'y' | 'x'
36
+ allowGestures?: boolean
37
+ overlay?: boolean
38
+ children?: React.ReactNode
39
+ ref?: React.RefObject<SlidingDrawerRef>
46
40
  }
47
41
 
48
42
  const SlidingDrawer = ({
49
- colorPalette,
50
- animation = SlidingDrawerTokens.defaultProps.animation,
51
- flex = 0,
52
- direction = 1,
53
- onCollapse,
54
- onExpand,
55
- onSnap,
56
- snapPoints,
57
- axis,
58
- allowGestures = true,
59
- overlay = false,
60
- children,
61
- // style,
62
- // mixins,
63
- ref
64
- }: SlidingDrawerProps
65
- ) => {
66
- console.log("🚀 ~ ref:", ref)
67
- // const slidingDrawerTokens = useTokens('slidingDrawer')();
68
-
69
- // const resolvedColorScheme =
70
- // colorScheme ??
71
- // (slidingDrawerTokens.defaultProps
72
- // .colorScheme as keyof SlidingDrawerColorSchemeVariants);
73
-
74
- // const resolvedAnimation =
75
- // animation ??
76
- // (slidingDrawerTokens.defaultProps
77
- // .animation as keyof SlidingDrawerAnimationVariants);
78
-
79
- SlidingDrawerStyles.useVariants({
80
- colorPalette,
81
- // animation,
82
- });
83
-
84
- // Adjust points based on direction and axis
85
- const points = snapPoints.map((point) => point * direction);
86
-
87
- const translate = useSharedValue(points[0]);
88
-
89
- const context: SharedValue<{
90
- position: any;
91
- snapPoint: number;
92
- }> = useSharedValue({
93
- position: points[0], // Default position
94
- snapPoint: 0, // Default snapPoint
95
- });
43
+ colorPalette = 'accent',
44
+ variant = SlidingDrawerTokens.defaultProps.variant,
45
+ animation = SlidingDrawerTokens.defaultProps.animation,
46
+ flex = 0,
47
+ direction = 1,
48
+ onCollapse,
49
+ onExpand,
50
+ onSnap,
51
+ snapPoints,
52
+ axis,
53
+ allowGestures = true,
54
+ overlay = false,
55
+ children,
56
+ ref,
57
+ }: SlidingDrawerProps) => {
58
+ SlidingDrawerStyles.useVariants({
59
+ variant,
60
+ })
61
+
62
+ const points = snapPoints.map(point => point * direction)
63
+
64
+ const translate = useSharedValue(points[0])
65
+
66
+ const context: SharedValue<{
67
+ position: any
68
+ snapPoint: number
69
+ }> = useSharedValue({
70
+ position: points[0],
71
+ snapPoint: 0,
72
+ })
73
+
74
+ const changeDisplay = useSharedValue('none')
75
+ const opacity = useSharedValue(0)
76
+
77
+ const VELOCITY_THRESHOLD = 2000
78
+
79
+ const updateCurrentSnapPoint = (snapPoint: number) => {
80
+ 'worklet'
81
+ context.value = {position: context.value.position, snapPoint}
82
+ }
96
83
 
97
- const changeDisplay = useSharedValue('none');
98
- const opacity = useSharedValue(0);
84
+ const animations = {
85
+ withSpring,
86
+ withTiming,
87
+ }
99
88
 
100
- const VELOCITY_THRESHOLD = 2000;
89
+ const animationVariant = SlidingDrawerTokens.variants.animation[animation]
101
90
 
102
- const updateCurrentSnapPoint = (snapPoint: number) => {
103
- 'worklet';
104
- context.value = { position: context.value.position, snapPoint };
105
- };
91
+ const snapTo = (destination: number) => {
92
+ 'worklet'
106
93
 
107
- const animations = {
108
- withSpring,
109
- withTiming,
110
- };
94
+ if (animationVariant && animationVariant.type) {
95
+ translate.value = animations[animationVariant.type](
96
+ points[destination],
97
+ animationVariant.props,
98
+ )
99
+ updateCurrentSnapPoint(destination)
100
+ onSnap && runOnJS(onSnap)(destination)
101
+ }
102
+ }
111
103
 
112
- const animationVariant =
113
- SlidingDrawerTokens.variants.animation[animation];
114
- // const animationVariant = variants.animation[animation];
104
+ const expand = () => {
105
+ snapTo(points.length - 1)
106
+ if (overlay) {
107
+ showOverlay()
108
+ }
109
+ onExpand && runOnJS(onExpand)()
110
+ }
115
111
 
116
- console.log("🚀 ~ animationVariant:", animationVariant)
112
+ const isCollapsed = () => {
113
+ 'worklet'
114
+ return context.value.snapPoint === 0
115
+ }
117
116
 
118
- const snapTo = (destination: number) => {
119
- 'worklet';
117
+ const collapse = () => {
118
+ snapTo(0)
119
+ if (overlay) {
120
+ hideOverlay()
121
+ }
122
+ onCollapse && runOnJS(onCollapse)()
123
+ }
120
124
 
121
- // Type guard to ensure animationVariant is not undefined
122
- if (animationVariant && animationVariant.type) {
123
- translate.value = animations[animationVariant.type](
124
- points[destination],
125
- animationVariant.props
126
- );
127
- updateCurrentSnapPoint(destination);
128
- onSnap && runOnJS(onSnap)(destination);
129
- }
130
- };
125
+ const hideOverlay = () => {
126
+ 'worklet'
127
+ changeDisplay.value = 'none'
128
+ opacity.value = withTiming(0, {duration: 200})
129
+ }
130
+ const showOverlay = () => {
131
+ 'worklet'
132
+ changeDisplay.value = 'flex'
133
+ opacity.value = withTiming(1, {duration: 200})
134
+ }
131
135
 
132
- const expand = () => {
133
- snapTo(points.length - 1);
134
- if (overlay) {
135
- showOverlay();
136
+ useImperativeHandle(ref, () => ({
137
+ expand,
138
+ collapse,
139
+ snapTo,
140
+ isCollapsed,
141
+ }))
142
+
143
+ const slideGesture = Gesture.Pan()
144
+ .enabled(allowGestures)
145
+ .onBegin(() => {
146
+ context.value.position = translate.value
147
+ })
148
+ .onUpdate(event => {
149
+ const delta = axis === 'y' ? event.translationY : event.translationX
150
+ translate.value = delta + (context.value.position ?? 0)
151
+ })
152
+ .onEnd(({velocityX, velocityY, translationX, translationY}) => {
153
+ const velocity = axis === 'y' ? velocityY : velocityX
154
+ const translation = axis === 'y' ? translationY : translationX
155
+
156
+ const forwardsThreshold =
157
+ (points[context.value.snapPoint] +
158
+ points[context.value.snapPoint + 1]) /
159
+ 2
160
+ const backwardsThreshold =
161
+ (points[context.value.snapPoint] +
162
+ points[context.value.snapPoint - 1]) /
163
+ 2
164
+
165
+ if (translation * direction < 0) {
166
+ if (
167
+ ((direction === 1 && translate.value < forwardsThreshold) ||
168
+ (direction === -1 && translate.value > forwardsThreshold) ||
169
+ velocity * direction < -VELOCITY_THRESHOLD) &&
170
+ context.value.snapPoint < points.length - 1
171
+ ) {
172
+ snapTo(context.value.snapPoint + 1)
173
+ } else {
174
+ snapTo(context.value.snapPoint)
175
+ }
176
+ } else {
177
+ if (
178
+ ((direction === 1 && translate.value > backwardsThreshold) ||
179
+ (direction === -1 && translate.value < backwardsThreshold) ||
180
+ velocity * direction > VELOCITY_THRESHOLD) &&
181
+ context.value.snapPoint > 0
182
+ ) {
183
+ snapTo(context.value.snapPoint - 1)
184
+ } else {
185
+ snapTo(context.value.snapPoint)
186
+ }
136
187
  }
137
- onExpand && runOnJS(onExpand)();
138
- };
139
-
140
- const isCollapsed = () => {
141
- 'worklet';
142
- return context.value.snapPoint === 0;
143
- };
144
-
145
- const collapse = () => {
146
- snapTo(0);
188
+ })
189
+ .onFinalize(() => {
147
190
  if (overlay) {
148
- hideOverlay();
149
- }
150
- onCollapse && runOnJS(onCollapse)();
151
- };
152
-
153
- const hideOverlay = () => {
154
- 'worklet';
155
- changeDisplay.value = 'none';
156
- opacity.value = withTiming(0, { duration: 200 });
157
- };
158
- const showOverlay = () => {
159
- 'worklet';
160
- changeDisplay.value = 'flex';
161
- opacity.value = withTiming(1, { duration: 200 });
162
- };
163
-
164
- useImperativeHandle(ref, () => ({
165
- expand,
166
- collapse,
167
- snapTo,
168
- isCollapsed,
169
- }));
170
-
171
- // const endLimit = direction === 1 ? points[0] : points[points.length - 1];
172
-
173
- const slideGesture = Gesture.Pan()
174
- .enabled(allowGestures)
175
- .onBegin(() => {
176
- context.value.position = translate.value;
177
- })
178
- .onUpdate((event) => {
179
- const delta = axis === 'y' ? event.translationY : event.translationX;
180
- translate.value = delta + (context.value.position ?? 0);
181
- })
182
- .onEnd(({ velocityX, velocityY, translationX, translationY }) => {
183
- const velocity = axis === 'y' ? velocityY : velocityX;
184
- const translation = axis === 'y' ? translationY : translationX;
185
-
186
- const forwardsThreshold =
187
- // @ts-ignore
188
- (points[context.value.snapPoint] +
189
- // @ts-ignore
190
- points[context.value.snapPoint + 1]) /
191
- 2;
192
- const backwardsThreshold =
193
- // @ts-ignore
194
- (points[context.value.snapPoint] +
195
- // @ts-ignore
196
- points[context.value.snapPoint - 1]) /
197
- 2;
198
-
199
- if (translation * direction < 0) {
200
- if (
201
- // @ts-ignore
202
- ((direction === 1 && translate.value < forwardsThreshold) ||
203
- // @ts-ignore
204
- (direction === -1 && translate.value > forwardsThreshold) ||
205
- velocity * direction < -VELOCITY_THRESHOLD) &&
206
- context.value.snapPoint < points.length - 1
207
- ) {
208
- snapTo(context.value.snapPoint + 1);
209
- } else {
210
- snapTo(context.value.snapPoint);
211
- }
191
+ if (isCollapsed()) {
192
+ hideOverlay()
212
193
  } else {
213
- if (
214
- // @ts-ignore
215
- ((direction === 1 && translate.value > backwardsThreshold) ||
216
- // @ts-ignore
217
- (direction === -1 && translate.value < backwardsThreshold) ||
218
- velocity * direction > VELOCITY_THRESHOLD) &&
219
- context.value.snapPoint > 0
220
- ) {
221
- snapTo(context.value.snapPoint - 1);
222
- } else {
223
- snapTo(context.value.snapPoint);
224
- }
225
- }
226
- })
227
- .onFinalize(() => {
228
- if (overlay) {
229
- if (isCollapsed()) {
230
- hideOverlay();
231
- } else {
232
- showOverlay();
233
- }
194
+ showOverlay()
234
195
  }
235
- });
236
-
237
- const blockAnimatedStyle = useAnimatedStyle(() => {
238
- return {
239
- transform: [
240
- { [axis === 'y' ? 'translateY' : 'translateX']: translate.value },
241
- ],
242
- } as any;
243
- });
244
-
245
- const displayOverlayStyle = useAnimatedStyle(() => {
246
- return {
247
- display: changeDisplay.value,
248
- opacity: opacity.value,
249
- } as any;
250
- });
251
-
252
- return (
253
- <>
254
- {overlay && (
255
- <Animated.View
256
- style={[
257
- {
258
- ...StyleSheet.absoluteFillObject,
259
- backgroundColor: 'rgba(0, 0, 0, 0.5)',
260
- },
261
- displayOverlayStyle,
262
- ]}
263
- />
264
- )}
265
- <GestureDetector gesture={slideGesture}>
266
- <Animated.View
267
- style={[
268
- styles.container(flex, direction, axis, SlidingDrawerTokens),
269
- blockAnimatedStyle,
270
- SlidingDrawerStyles.container,
271
- // style && styles.customStyle(style),
272
- // mixins && mixins,
273
- ]}
274
- >
275
- {children}
276
- </Animated.View>
277
- </GestureDetector>
278
- </>
279
- );
280
- }
281
- ;
282
-
283
- export default SlidingDrawer;
196
+ }
197
+ })
198
+
199
+ const blockAnimatedStyle = useAnimatedStyle(() => {
200
+ return {
201
+ transform: [
202
+ {[axis === 'y' ? 'translateY' : 'translateX']: translate.value},
203
+ ],
204
+ } as any
205
+ })
206
+
207
+ const displayOverlayStyle = useAnimatedStyle(() => {
208
+ return {
209
+ display: changeDisplay.value,
210
+ opacity: opacity.value,
211
+ } as any
212
+ })
213
+
214
+ return (
215
+ <>
216
+ {overlay && (
217
+ <Animated.View
218
+ style={[
219
+ {
220
+ ...StyleSheet.absoluteFillObject,
221
+ },
222
+ displayOverlayStyle,
223
+ SlidingDrawerStyles.backdrop(colorPalette),
224
+ ]}
225
+ />
226
+ )}
227
+ <GestureDetector gesture={slideGesture}>
228
+ <Animated.View
229
+ style={[
230
+ styles.container(flex, direction, axis, SlidingDrawerTokens),
231
+ blockAnimatedStyle,
232
+ SlidingDrawerStyles.container(colorPalette),
233
+ ]}>
234
+ {children}
235
+ </Animated.View>
236
+ </GestureDetector>
237
+ </>
238
+ )
239
+ }
240
+ export default SlidingDrawer
284
241
 
285
242
  const styles = StyleSheet.create({
286
243
  container: (flex, direction, axis, slidingDrawerTokens): any => ({
@@ -291,17 +248,11 @@ const styles = StyleSheet.create({
291
248
  flex: flex === 0 ? 1 : flex,
292
249
  height: '100%',
293
250
  width: '100%',
294
- backgroundColor: slidingDrawerTokens.defaultProps.backgroundColor,
295
- borderRadius: slidingDrawerTokens.defaultProps.borderRadius,
296
251
  alignItems: 'center',
297
252
  justifyContent: 'flex-start',
298
- boxShadow: slidingDrawerTokens.defaultProps.boxShadow,
299
- zIndex: 5,
300
- // variants: {
301
- // colorScheme: slidingDrawerTokens.variants.colorScheme,
302
- // },
253
+ zIndex: 100,
303
254
  }),
304
- customStyle: (style) => ({
255
+ customStyle: style => ({
305
256
  ...style,
306
257
  }),
307
- });
258
+ })
@@ -1,36 +1,45 @@
1
1
  import {
2
2
  ActivityIndicator,
3
- ColorValue,
4
3
  type ActivityIndicatorProps,
5
4
  type StyleProp,
6
5
  type ViewStyle,
7
6
  } from 'react-native'
8
7
  import {withUnistyles} from 'react-native-unistyles'
9
- import {ThemeColors} from '../style/types'
8
+ import {PalettesWithNestedKeys, ThemeColors} from '../style/varia/types'
10
9
  import {SpinnerTokens} from '../theme/Spinner.recipe'
10
+ import {resolveColor} from '../style/varia/utils'
11
+ import {SpinnerStyles} from '../theme/Spinner.recipe'
12
+ import {UnistylesVariants} from 'react-native-unistyles'
11
13
 
12
- interface SpinnerProps extends ActivityIndicatorProps {
13
- color?: ThemeColors
14
- size?: number
15
- style?: StyleProp<ViewStyle>
16
- mixins?: StyleProp<ViewStyle> | StyleProp<ViewStyle>[]
17
- colors: Record<string, ColorValue>
18
- }
14
+ type SpinnerVariants = UnistylesVariants<typeof SpinnerStyles>
15
+ type SpinnerProps = SpinnerVariants &
16
+ Omit<ActivityIndicatorProps, 'size'> & {
17
+ color?: ThemeColors
18
+ style?: StyleProp<ViewStyle>
19
+ mixins?: StyleProp<ViewStyle> | StyleProp<ViewStyle>[]
20
+ colors: any
21
+ colorPalette?: PalettesWithNestedKeys
22
+ }
19
23
 
20
24
  const BaseSpinner = ({
21
- size = SpinnerTokens.defaultProps.size,
25
+ size = SpinnerTokens.defaultProps.size as SpinnerProps['size'],
22
26
  color = SpinnerTokens.defaultProps.color,
23
27
  style,
24
28
  mixins,
25
29
  colors,
30
+ colorPalette = 'accent',
26
31
  ...props
27
32
  }: SpinnerProps) => {
28
- const resolvedColor = color && color in colors ? colors[color] : color
33
+ const resolvedColor = resolveColor(color, colors, colorPalette)
34
+
35
+ SpinnerStyles.useVariants({
36
+ size,
37
+ })
29
38
 
30
39
  return (
31
40
  <ActivityIndicator
32
41
  color={resolvedColor}
33
- size={size}
42
+ size={SpinnerStyles.base.width}
34
43
  {...props}
35
44
  style={[style && style, mixins && mixins]}
36
45
  />