rnnovaui 0.1.4 → 0.1.6
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/package.json +1 -1
- package/src/components/Button/UIButton.js +290 -142
- package/src/theme/UIProvider.js +85 -24
- package/src/theme/colors.js +310 -4
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
import { useUITheme } from "../../theme";
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const BUTTON_VARIANTS = {
|
|
14
14
|
solid: "solid",
|
|
15
15
|
outline: "outline",
|
|
16
16
|
ghost: "ghost",
|
|
@@ -19,65 +19,116 @@ const VARIANTS = {
|
|
|
19
19
|
success: "success",
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const BUTTON_SIZES = {
|
|
23
23
|
sm: "sm",
|
|
24
24
|
md: "md",
|
|
25
25
|
lg: "lg",
|
|
26
26
|
xl: "xl",
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
const DEFAULT_COLORS = {
|
|
30
|
+
buttonPrimaryBackground: "#FF5A1F",
|
|
31
|
+
|
|
32
|
+
buttonPrimaryPressed: "#E94D17",
|
|
33
|
+
|
|
34
|
+
buttonPrimaryText: "#FFFFFF",
|
|
35
|
+
|
|
36
|
+
buttonOutlineBackground: "transparent",
|
|
37
|
+
|
|
38
|
+
buttonOutlineBorder: "#FF5A1F",
|
|
39
|
+
|
|
40
|
+
buttonOutlineText: "#FF5A1F",
|
|
41
|
+
|
|
42
|
+
buttonGhostBackground: "transparent",
|
|
43
|
+
|
|
44
|
+
buttonGhostText: "#FF5A1F",
|
|
45
|
+
|
|
46
|
+
buttonSoftBackground: "#FFF0EA",
|
|
47
|
+
|
|
48
|
+
buttonSoftText: "#FF5A1F",
|
|
49
|
+
|
|
50
|
+
buttonDangerBackground: "#DC2626",
|
|
51
|
+
|
|
52
|
+
buttonDangerPressed: "#B91C1C",
|
|
53
|
+
|
|
54
|
+
buttonDangerText: "#FFFFFF",
|
|
55
|
+
|
|
56
|
+
buttonSuccessBackground: "#16A34A",
|
|
57
|
+
|
|
58
|
+
buttonSuccessPressed: "#128238",
|
|
59
|
+
|
|
60
|
+
buttonSuccessText: "#FFFFFF",
|
|
61
|
+
|
|
62
|
+
buttonDisabledBackground: "#E5E5E5",
|
|
63
|
+
|
|
64
|
+
buttonDisabledText: "#A3A3A3",
|
|
65
|
+
|
|
66
|
+
buttonDisabledBorder: "#E5E5E5",
|
|
67
|
+
|
|
68
|
+
buttonRipple: "rgba(255,255,255,0.20)",
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const UIButtonComponent = ({
|
|
30
72
|
title,
|
|
73
|
+
|
|
31
74
|
children,
|
|
32
75
|
|
|
33
76
|
variant = "solid",
|
|
77
|
+
|
|
34
78
|
size = "md",
|
|
35
79
|
|
|
36
80
|
disabled = false,
|
|
81
|
+
|
|
37
82
|
loading = false,
|
|
83
|
+
|
|
38
84
|
fullWidth = false,
|
|
39
85
|
|
|
40
|
-
leftIcon,
|
|
41
|
-
|
|
86
|
+
leftIcon = null,
|
|
87
|
+
|
|
88
|
+
rightIcon = null,
|
|
42
89
|
|
|
43
90
|
onPress,
|
|
91
|
+
|
|
44
92
|
onLongPress,
|
|
93
|
+
|
|
45
94
|
onPressIn,
|
|
95
|
+
|
|
46
96
|
onPressOut,
|
|
47
97
|
|
|
48
98
|
style,
|
|
99
|
+
|
|
49
100
|
contentStyle,
|
|
101
|
+
|
|
50
102
|
textStyle,
|
|
51
103
|
|
|
52
104
|
activeOpacity = 0.82,
|
|
53
105
|
|
|
54
106
|
testID,
|
|
107
|
+
|
|
55
108
|
accessibilityLabel,
|
|
109
|
+
|
|
56
110
|
accessibilityHint,
|
|
57
111
|
|
|
58
112
|
...props
|
|
59
|
-
}) {
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
/*
|
|
63
|
-
* Support both possible provider shapes:
|
|
64
|
-
*
|
|
65
|
-
* themeResult.theme.colors
|
|
66
|
-
* themeResult.colors
|
|
67
|
-
*/
|
|
68
|
-
const theme = themeResult?.theme || themeResult || {};
|
|
113
|
+
}) => {
|
|
114
|
+
const { theme } = useUITheme();
|
|
69
115
|
|
|
70
|
-
const colors =
|
|
116
|
+
const colors = {
|
|
117
|
+
...DEFAULT_COLORS,
|
|
118
|
+
...(theme?.colors || {}),
|
|
119
|
+
};
|
|
71
120
|
|
|
72
|
-
const safeVariant =
|
|
121
|
+
const safeVariant = BUTTON_VARIANTS[variant]
|
|
122
|
+
? variant
|
|
123
|
+
: BUTTON_VARIANTS.solid;
|
|
73
124
|
|
|
74
|
-
const safeSize =
|
|
125
|
+
const safeSize = BUTTON_SIZES[size] ? size : BUTTON_SIZES.md;
|
|
75
126
|
|
|
76
|
-
const
|
|
127
|
+
const isDisabled = disabled || loading;
|
|
77
128
|
|
|
78
|
-
const
|
|
129
|
+
const variantStyle = getVariantStyle(safeVariant, colors, isDisabled);
|
|
79
130
|
|
|
80
|
-
const
|
|
131
|
+
const sizeStyle = getSizeStyle(safeSize, theme);
|
|
81
132
|
|
|
82
133
|
const handlePress = useCallback(
|
|
83
134
|
(event) => {
|
|
@@ -85,7 +136,9 @@ function UIButtonComponent({
|
|
|
85
136
|
return;
|
|
86
137
|
}
|
|
87
138
|
|
|
88
|
-
onPress
|
|
139
|
+
if (typeof onPress === "function") {
|
|
140
|
+
onPress(event);
|
|
141
|
+
}
|
|
89
142
|
},
|
|
90
143
|
[isDisabled, onPress],
|
|
91
144
|
);
|
|
@@ -96,7 +149,9 @@ function UIButtonComponent({
|
|
|
96
149
|
return;
|
|
97
150
|
}
|
|
98
151
|
|
|
99
|
-
onLongPress
|
|
152
|
+
if (typeof onLongPress === "function") {
|
|
153
|
+
onLongPress(event);
|
|
154
|
+
}
|
|
100
155
|
},
|
|
101
156
|
[isDisabled, onLongPress],
|
|
102
157
|
);
|
|
@@ -107,7 +162,9 @@ function UIButtonComponent({
|
|
|
107
162
|
return;
|
|
108
163
|
}
|
|
109
164
|
|
|
110
|
-
onPressIn
|
|
165
|
+
if (typeof onPressIn === "function") {
|
|
166
|
+
onPressIn(event);
|
|
167
|
+
}
|
|
111
168
|
},
|
|
112
169
|
[isDisabled, onPressIn],
|
|
113
170
|
);
|
|
@@ -118,7 +175,9 @@ function UIButtonComponent({
|
|
|
118
175
|
return;
|
|
119
176
|
}
|
|
120
177
|
|
|
121
|
-
onPressOut
|
|
178
|
+
if (typeof onPressOut === "function") {
|
|
179
|
+
onPressOut(event);
|
|
180
|
+
}
|
|
122
181
|
},
|
|
123
182
|
[isDisabled, onPressOut],
|
|
124
183
|
);
|
|
@@ -141,197 +200,275 @@ function UIButtonComponent({
|
|
|
141
200
|
accessibilityHint={accessibilityHint}
|
|
142
201
|
accessibilityState={{
|
|
143
202
|
disabled: isDisabled,
|
|
203
|
+
|
|
144
204
|
busy: loading,
|
|
145
205
|
}}
|
|
146
|
-
style={({ pressed }) =>
|
|
147
|
-
|
|
206
|
+
style={({ pressed }) => {
|
|
207
|
+
const backgroundColor = isDisabled
|
|
208
|
+
? colors.buttonDisabledBackground
|
|
209
|
+
: pressed
|
|
210
|
+
? variantStyle.pressedBackground
|
|
211
|
+
: variantStyle.backgroundColor;
|
|
148
212
|
|
|
149
|
-
|
|
150
|
-
|
|
213
|
+
const borderColor = isDisabled
|
|
214
|
+
? colors.buttonDisabledBorder
|
|
215
|
+
: variantStyle.borderColor;
|
|
151
216
|
|
|
152
|
-
|
|
217
|
+
const textColor = isDisabled
|
|
218
|
+
? colors.buttonDisabledText
|
|
219
|
+
: variantStyle.textColor;
|
|
153
220
|
|
|
154
|
-
|
|
221
|
+
return [
|
|
222
|
+
styles.button,
|
|
155
223
|
|
|
156
|
-
|
|
224
|
+
{
|
|
225
|
+
height: sizeStyle.height,
|
|
157
226
|
|
|
158
|
-
|
|
227
|
+
minHeight: sizeStyle.height,
|
|
159
228
|
|
|
160
|
-
|
|
229
|
+
paddingHorizontal: sizeStyle.paddingHorizontal,
|
|
161
230
|
|
|
162
|
-
|
|
231
|
+
borderRadius: sizeStyle.borderRadius,
|
|
163
232
|
|
|
164
|
-
|
|
233
|
+
backgroundColor,
|
|
165
234
|
|
|
166
|
-
|
|
167
|
-
},
|
|
235
|
+
borderColor,
|
|
168
236
|
|
|
169
|
-
|
|
170
|
-
|
|
237
|
+
borderWidth: variantStyle.borderWidth,
|
|
238
|
+
|
|
239
|
+
width: fullWidth ? "100%" : undefined,
|
|
240
|
+
|
|
241
|
+
opacity: isDisabled ? 0.55 : 1,
|
|
242
|
+
},
|
|
243
|
+
|
|
244
|
+
style,
|
|
245
|
+
];
|
|
246
|
+
}}
|
|
171
247
|
>
|
|
172
248
|
<View
|
|
173
249
|
style={[
|
|
174
250
|
styles.content,
|
|
175
251
|
|
|
176
252
|
{
|
|
177
|
-
gap:
|
|
253
|
+
gap: sizeStyle.gap,
|
|
178
254
|
},
|
|
179
255
|
|
|
180
256
|
contentStyle,
|
|
181
257
|
]}
|
|
182
258
|
>
|
|
183
259
|
{loading ? (
|
|
184
|
-
<ActivityIndicator size="small" color={
|
|
185
|
-
) :
|
|
186
|
-
<View style={styles.icon}>{leftIcon}</View>
|
|
187
|
-
)
|
|
260
|
+
<ActivityIndicator size="small" color={variantStyle.textColor} />
|
|
261
|
+
) : (
|
|
262
|
+
leftIcon && <View style={styles.icon}>{leftIcon}</View>
|
|
263
|
+
)}
|
|
188
264
|
|
|
189
265
|
{hasChildren ? (
|
|
190
266
|
<View style={styles.children}>{children}</View>
|
|
191
|
-
) :
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
267
|
+
) : (
|
|
268
|
+
title !== undefined &&
|
|
269
|
+
title !== null && (
|
|
270
|
+
<Text
|
|
271
|
+
numberOfLines={1}
|
|
272
|
+
style={[
|
|
273
|
+
styles.text,
|
|
274
|
+
|
|
275
|
+
{
|
|
276
|
+
color: isDisabled
|
|
277
|
+
? colors.buttonDisabledText
|
|
278
|
+
: variantStyle.textColor,
|
|
279
|
+
|
|
280
|
+
fontSize: sizeStyle.fontSize,
|
|
281
|
+
|
|
282
|
+
lineHeight: sizeStyle.lineHeight,
|
|
283
|
+
},
|
|
284
|
+
|
|
285
|
+
textStyle,
|
|
286
|
+
]}
|
|
287
|
+
>
|
|
288
|
+
{title}
|
|
289
|
+
</Text>
|
|
290
|
+
)
|
|
291
|
+
)}
|
|
292
|
+
|
|
293
|
+
{!loading && rightIcon && <View style={styles.icon}>{rightIcon}</View>}
|
|
215
294
|
</View>
|
|
216
295
|
</Pressable>
|
|
217
296
|
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* IMPORTANT:
|
|
222
|
-
*
|
|
223
|
-
* Variant resolution is completely independent
|
|
224
|
-
* from spacing/radius/typography.
|
|
225
|
-
*
|
|
226
|
-
* Therefore even if the theme is incomplete,
|
|
227
|
-
* variants still work.
|
|
228
|
-
*/
|
|
229
|
-
function getButtonColors(variant, colors) {
|
|
230
|
-
const primary = colors.primary || "#FF5A1F";
|
|
231
|
-
|
|
232
|
-
const primarySoft = colors.primarySoft || "#FFF0EA";
|
|
297
|
+
};
|
|
233
298
|
|
|
234
|
-
|
|
299
|
+
function getVariantStyle(variant, colors, disabled) {
|
|
300
|
+
if (disabled) {
|
|
301
|
+
return {
|
|
302
|
+
backgroundColor: colors.buttonDisabledBackground,
|
|
235
303
|
|
|
236
|
-
|
|
304
|
+
pressedBackground: colors.buttonDisabledBackground,
|
|
237
305
|
|
|
238
|
-
|
|
306
|
+
borderColor: colors.buttonDisabledBorder,
|
|
239
307
|
|
|
240
|
-
|
|
308
|
+
borderWidth: 1,
|
|
241
309
|
|
|
242
|
-
|
|
310
|
+
textColor: colors.buttonDisabledText,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
243
313
|
|
|
244
314
|
switch (variant) {
|
|
245
|
-
case
|
|
315
|
+
case BUTTON_VARIANTS.outline:
|
|
246
316
|
return {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
317
|
+
backgroundColor: colors.buttonOutlineBackground,
|
|
318
|
+
|
|
319
|
+
pressedBackground: colors.buttonSoftBackground,
|
|
320
|
+
|
|
321
|
+
borderColor: colors.buttonOutlineBorder,
|
|
322
|
+
|
|
323
|
+
borderWidth: 1,
|
|
324
|
+
|
|
325
|
+
textColor: colors.buttonOutlineText,
|
|
250
326
|
};
|
|
251
327
|
|
|
252
|
-
case
|
|
328
|
+
case BUTTON_VARIANTS.ghost:
|
|
253
329
|
return {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
330
|
+
backgroundColor: colors.buttonGhostBackground,
|
|
331
|
+
|
|
332
|
+
pressedBackground: colors.buttonSoftBackground,
|
|
333
|
+
|
|
334
|
+
borderColor: colors.transparent,
|
|
335
|
+
|
|
336
|
+
borderWidth: 0,
|
|
337
|
+
|
|
338
|
+
textColor: colors.buttonGhostText,
|
|
257
339
|
};
|
|
258
340
|
|
|
259
|
-
case
|
|
341
|
+
case BUTTON_VARIANTS.soft:
|
|
260
342
|
return {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
343
|
+
backgroundColor: colors.buttonSoftBackground,
|
|
344
|
+
|
|
345
|
+
pressedBackground: colors.primaryMuted || colors.buttonSoftBackground,
|
|
346
|
+
|
|
347
|
+
borderColor: colors.buttonSoftBackground,
|
|
348
|
+
|
|
349
|
+
borderWidth: 1,
|
|
350
|
+
|
|
351
|
+
textColor: colors.buttonSoftText,
|
|
264
352
|
};
|
|
265
353
|
|
|
266
|
-
case
|
|
354
|
+
case BUTTON_VARIANTS.danger:
|
|
267
355
|
return {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
356
|
+
backgroundColor: colors.buttonDangerBackground,
|
|
357
|
+
|
|
358
|
+
pressedBackground: colors.buttonDangerPressed,
|
|
359
|
+
|
|
360
|
+
borderColor: colors.buttonDangerBackground,
|
|
361
|
+
|
|
362
|
+
borderWidth: 1,
|
|
363
|
+
|
|
364
|
+
textColor: colors.buttonDangerText,
|
|
271
365
|
};
|
|
272
366
|
|
|
273
|
-
case
|
|
367
|
+
case BUTTON_VARIANTS.success:
|
|
274
368
|
return {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
369
|
+
backgroundColor: colors.buttonSuccessBackground,
|
|
370
|
+
|
|
371
|
+
pressedBackground: colors.buttonSuccessPressed,
|
|
372
|
+
|
|
373
|
+
borderColor: colors.buttonSuccessBackground,
|
|
374
|
+
|
|
375
|
+
borderWidth: 1,
|
|
376
|
+
|
|
377
|
+
textColor: colors.buttonSuccessText,
|
|
278
378
|
};
|
|
279
379
|
|
|
280
|
-
case
|
|
380
|
+
case BUTTON_VARIANTS.solid:
|
|
281
381
|
default:
|
|
282
382
|
return {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
383
|
+
backgroundColor: colors.buttonPrimaryBackground,
|
|
384
|
+
|
|
385
|
+
pressedBackground: colors.buttonPrimaryPressed,
|
|
386
|
+
|
|
387
|
+
borderColor: colors.buttonPrimaryBackground,
|
|
388
|
+
|
|
389
|
+
borderWidth: 1,
|
|
390
|
+
|
|
391
|
+
textColor: colors.buttonPrimaryText,
|
|
286
392
|
};
|
|
287
393
|
}
|
|
288
394
|
}
|
|
289
395
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
396
|
+
function getSizeStyle(size, theme) {
|
|
397
|
+
const buttonSizes = theme?.sizes?.button || {};
|
|
398
|
+
|
|
399
|
+
const themeRadius = theme?.radius?.button;
|
|
400
|
+
|
|
401
|
+
const buttonRadius = typeof themeRadius === "number" ? themeRadius : 12;
|
|
402
|
+
|
|
403
|
+
const spacing = theme?.spacing || {};
|
|
404
|
+
|
|
405
|
+
const spacingSM = typeof spacing.sm === "number" ? spacing.sm : 8;
|
|
406
|
+
|
|
407
|
+
const spacingMD = typeof spacing.md === "number" ? spacing.md : 16;
|
|
408
|
+
|
|
409
|
+
const spacingLG = typeof spacing.lg === "number" ? spacing.lg : 20;
|
|
410
|
+
|
|
411
|
+
const spacingXL = typeof spacing.xl === "number" ? spacing.xl : 24;
|
|
412
|
+
|
|
296
413
|
switch (size) {
|
|
297
|
-
case
|
|
414
|
+
case BUTTON_SIZES.sm:
|
|
298
415
|
return {
|
|
299
|
-
height: 36,
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
416
|
+
height: buttonSizes.sm ?? 36,
|
|
417
|
+
|
|
418
|
+
paddingHorizontal: spacingMD,
|
|
419
|
+
|
|
420
|
+
gap: spacingSM,
|
|
421
|
+
|
|
422
|
+
borderRadius: buttonRadius,
|
|
423
|
+
|
|
303
424
|
fontSize: 13,
|
|
425
|
+
|
|
304
426
|
lineHeight: 18,
|
|
305
427
|
};
|
|
306
428
|
|
|
307
|
-
case
|
|
429
|
+
case BUTTON_SIZES.lg:
|
|
308
430
|
return {
|
|
309
|
-
height: 52,
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
431
|
+
height: buttonSizes.lg ?? 52,
|
|
432
|
+
|
|
433
|
+
paddingHorizontal: spacingLG,
|
|
434
|
+
|
|
435
|
+
gap: spacingSM,
|
|
436
|
+
|
|
437
|
+
borderRadius: buttonRadius,
|
|
438
|
+
|
|
313
439
|
fontSize: 16,
|
|
440
|
+
|
|
314
441
|
lineHeight: 22,
|
|
315
442
|
};
|
|
316
443
|
|
|
317
|
-
case
|
|
444
|
+
case BUTTON_SIZES.xl:
|
|
318
445
|
return {
|
|
319
|
-
height: 60,
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
446
|
+
height: buttonSizes.xl ?? 60,
|
|
447
|
+
|
|
448
|
+
paddingHorizontal: spacingXL,
|
|
449
|
+
|
|
450
|
+
gap: spacingSM,
|
|
451
|
+
|
|
452
|
+
borderRadius: buttonRadius,
|
|
453
|
+
|
|
323
454
|
fontSize: 17,
|
|
455
|
+
|
|
324
456
|
lineHeight: 24,
|
|
325
457
|
};
|
|
326
458
|
|
|
327
|
-
case
|
|
459
|
+
case BUTTON_SIZES.md:
|
|
328
460
|
default:
|
|
329
461
|
return {
|
|
330
|
-
height: 44,
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
462
|
+
height: buttonSizes.md ?? 44,
|
|
463
|
+
|
|
464
|
+
paddingHorizontal: spacingLG,
|
|
465
|
+
|
|
466
|
+
gap: spacingSM,
|
|
467
|
+
|
|
468
|
+
borderRadius: buttonRadius,
|
|
469
|
+
|
|
334
470
|
fontSize: 14,
|
|
471
|
+
|
|
335
472
|
lineHeight: 20,
|
|
336
473
|
};
|
|
337
474
|
}
|
|
@@ -340,34 +477,47 @@ function getButtonDimensions(size) {
|
|
|
340
477
|
const styles = StyleSheet.create({
|
|
341
478
|
button: {
|
|
342
479
|
flexShrink: 0,
|
|
480
|
+
|
|
343
481
|
alignItems: "center",
|
|
482
|
+
|
|
344
483
|
justifyContent: "center",
|
|
484
|
+
|
|
345
485
|
overflow: "hidden",
|
|
346
486
|
},
|
|
347
487
|
|
|
348
488
|
content: {
|
|
349
489
|
flexDirection: "row",
|
|
490
|
+
|
|
350
491
|
alignItems: "center",
|
|
492
|
+
|
|
351
493
|
justifyContent: "center",
|
|
494
|
+
|
|
352
495
|
flexShrink: 1,
|
|
353
496
|
},
|
|
354
497
|
|
|
355
498
|
children: {
|
|
356
499
|
flexShrink: 1,
|
|
500
|
+
|
|
357
501
|
alignItems: "center",
|
|
502
|
+
|
|
358
503
|
justifyContent: "center",
|
|
359
504
|
},
|
|
360
505
|
|
|
361
506
|
icon: {
|
|
362
507
|
alignItems: "center",
|
|
508
|
+
|
|
363
509
|
justifyContent: "center",
|
|
510
|
+
|
|
364
511
|
flexShrink: 0,
|
|
365
512
|
},
|
|
366
513
|
|
|
367
514
|
text: {
|
|
368
515
|
flexShrink: 1,
|
|
516
|
+
|
|
369
517
|
fontWeight: "600",
|
|
518
|
+
|
|
370
519
|
textAlign: "center",
|
|
520
|
+
|
|
371
521
|
includeFontPadding: false,
|
|
372
522
|
},
|
|
373
523
|
});
|
|
@@ -376,6 +526,4 @@ export const UIButton = memo(UIButtonComponent);
|
|
|
376
526
|
|
|
377
527
|
UIButton.displayName = "UIButton";
|
|
378
528
|
|
|
379
|
-
export
|
|
380
|
-
|
|
381
|
-
export const UIButtonSizes = SIZES;
|
|
529
|
+
export { BUTTON_VARIANTS as UIButtonVariants, BUTTON_SIZES as UIButtonSizes };
|
package/src/theme/UIProvider.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { createContext, useContext, useMemo } from "react";
|
|
1
|
+
import React, { createContext, useCallback, useContext, useMemo } from "react";
|
|
2
2
|
|
|
3
3
|
import { useColorScheme } from "react-native";
|
|
4
4
|
|
|
@@ -21,45 +21,106 @@ import { breakpoints } from "./breakpoints";
|
|
|
21
21
|
const UIContext = createContext(null);
|
|
22
22
|
|
|
23
23
|
function createTheme(mode, overrides) {
|
|
24
|
-
const
|
|
24
|
+
const baseColors = mode === "dark" ? darkColors : lightColors;
|
|
25
25
|
|
|
26
26
|
return {
|
|
27
27
|
mode,
|
|
28
28
|
|
|
29
29
|
colors: {
|
|
30
|
-
...
|
|
31
|
-
|
|
30
|
+
...baseColors,
|
|
31
|
+
|
|
32
|
+
...(overrides?.colors || {}),
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
spacing: {
|
|
36
|
+
...spacing,
|
|
37
|
+
|
|
38
|
+
...(overrides?.spacing || {}),
|
|
32
39
|
},
|
|
33
40
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
radius: {
|
|
42
|
+
...radius,
|
|
43
|
+
|
|
44
|
+
...(overrides?.radius || {}),
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
typography: {
|
|
48
|
+
...typography,
|
|
49
|
+
|
|
50
|
+
...(overrides?.typography || {}),
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
sizes: {
|
|
54
|
+
...sizes,
|
|
55
|
+
|
|
56
|
+
...(overrides?.sizes || {}),
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
shadows: {
|
|
60
|
+
...shadows,
|
|
61
|
+
|
|
62
|
+
...(overrides?.shadows || {}),
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
animation: {
|
|
66
|
+
...animation,
|
|
67
|
+
|
|
68
|
+
...(overrides?.animation || {}),
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
breakpoints: {
|
|
72
|
+
...breakpoints,
|
|
73
|
+
|
|
74
|
+
...(overrides?.breakpoints || {}),
|
|
75
|
+
},
|
|
41
76
|
};
|
|
42
77
|
}
|
|
43
78
|
|
|
44
|
-
export function UIProvider({
|
|
79
|
+
export function UIProvider({
|
|
80
|
+
children,
|
|
81
|
+
|
|
82
|
+
mode = "system",
|
|
83
|
+
|
|
84
|
+
onModeChange,
|
|
85
|
+
|
|
86
|
+
theme,
|
|
87
|
+
}) {
|
|
45
88
|
const systemScheme = useColorScheme();
|
|
46
89
|
|
|
47
90
|
const resolvedMode =
|
|
48
|
-
mode === "system"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
91
|
+
mode === "system"
|
|
92
|
+
? systemScheme === "dark"
|
|
93
|
+
? "dark"
|
|
94
|
+
: "light"
|
|
95
|
+
: mode === "dark"
|
|
96
|
+
? "dark"
|
|
97
|
+
: "light";
|
|
98
|
+
|
|
99
|
+
const setMode = useCallback(
|
|
100
|
+
(nextMode) => {
|
|
101
|
+
if (
|
|
102
|
+
nextMode !== "light" &&
|
|
103
|
+
nextMode !== "dark" &&
|
|
104
|
+
nextMode !== "system"
|
|
105
|
+
) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (typeof onModeChange === "function") {
|
|
110
|
+
onModeChange(nextMode);
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
[onModeChange],
|
|
114
|
+
);
|
|
54
115
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
116
|
+
const resolvedTheme = useMemo(
|
|
117
|
+
() => createTheme(resolvedMode, theme),
|
|
118
|
+
[resolvedMode, theme],
|
|
119
|
+
);
|
|
59
120
|
|
|
60
121
|
const contextValue = useMemo(
|
|
61
122
|
() => ({
|
|
62
|
-
theme:
|
|
123
|
+
theme: resolvedTheme,
|
|
63
124
|
|
|
64
125
|
mode: resolvedMode,
|
|
65
126
|
|
|
@@ -67,7 +128,7 @@ export function UIProvider({ children, mode = "system", onModeChange, theme }) {
|
|
|
67
128
|
|
|
68
129
|
setMode,
|
|
69
130
|
}),
|
|
70
|
-
[resolvedMode, mode,
|
|
131
|
+
[resolvedTheme, resolvedMode, mode, setMode],
|
|
71
132
|
);
|
|
72
133
|
|
|
73
134
|
return (
|
package/src/theme/colors.js
CHANGED
|
@@ -1,99 +1,405 @@
|
|
|
1
1
|
export const lightColors = {
|
|
2
|
+
// --------------------------------------------------
|
|
3
|
+
// BASE
|
|
4
|
+
// --------------------------------------------------
|
|
5
|
+
|
|
2
6
|
transparent: "transparent",
|
|
3
7
|
|
|
8
|
+
// --------------------------------------------------
|
|
9
|
+
// BRAND
|
|
10
|
+
// --------------------------------------------------
|
|
11
|
+
|
|
4
12
|
primary: "#FF5A1F",
|
|
5
13
|
primaryPressed: "#E94D17",
|
|
14
|
+
primaryHover: "#F4511E",
|
|
6
15
|
primarySoft: "#FFF0EA",
|
|
16
|
+
primaryMuted: "#FFE1D5",
|
|
17
|
+
|
|
7
18
|
onPrimary: "#FFFFFF",
|
|
8
19
|
|
|
20
|
+
// --------------------------------------------------
|
|
21
|
+
// SECONDARY
|
|
22
|
+
// --------------------------------------------------
|
|
23
|
+
|
|
9
24
|
secondary: "#7CFF32",
|
|
25
|
+
secondaryPressed: "#68E51F",
|
|
10
26
|
secondarySoft: "#F0FFE7",
|
|
27
|
+
secondaryMuted: "#DFFFCC",
|
|
28
|
+
|
|
11
29
|
onSecondary: "#111111",
|
|
12
30
|
|
|
31
|
+
// --------------------------------------------------
|
|
32
|
+
// BACKGROUNDS
|
|
33
|
+
// --------------------------------------------------
|
|
34
|
+
|
|
13
35
|
background: "#FFFFFF",
|
|
36
|
+
|
|
14
37
|
surface: "#F8F8F8",
|
|
38
|
+
|
|
15
39
|
surfaceSecondary: "#F1F1F1",
|
|
40
|
+
|
|
41
|
+
surfaceTertiary: "#EAEAEA",
|
|
42
|
+
|
|
16
43
|
card: "#FFFFFF",
|
|
17
44
|
|
|
45
|
+
cardElevated: "#FFFFFF",
|
|
46
|
+
|
|
47
|
+
// --------------------------------------------------
|
|
48
|
+
// TEXT
|
|
49
|
+
// --------------------------------------------------
|
|
50
|
+
|
|
18
51
|
text: "#111111",
|
|
52
|
+
|
|
19
53
|
textSecondary: "#525252",
|
|
54
|
+
|
|
20
55
|
textMuted: "#737373",
|
|
56
|
+
|
|
21
57
|
textDisabled: "#A3A3A3",
|
|
58
|
+
|
|
22
59
|
textInverse: "#FFFFFF",
|
|
23
60
|
|
|
61
|
+
// --------------------------------------------------
|
|
62
|
+
// BORDER
|
|
63
|
+
// --------------------------------------------------
|
|
64
|
+
|
|
24
65
|
border: "#E5E5E5",
|
|
66
|
+
|
|
25
67
|
borderStrong: "#D4D4D4",
|
|
68
|
+
|
|
69
|
+
borderSubtle: "#F0F0F0",
|
|
70
|
+
|
|
26
71
|
divider: "#EEEEEE",
|
|
27
72
|
|
|
73
|
+
// --------------------------------------------------
|
|
74
|
+
// INPUT
|
|
75
|
+
// --------------------------------------------------
|
|
76
|
+
|
|
28
77
|
input: "#F7F7F7",
|
|
78
|
+
|
|
29
79
|
inputFocused: "#FFFFFF",
|
|
80
|
+
|
|
30
81
|
inputDisabled: "#EEEEEE",
|
|
31
82
|
|
|
83
|
+
inputBorder: "#E1E1E1",
|
|
84
|
+
|
|
85
|
+
inputBorderFocused: "#FF5A1F",
|
|
86
|
+
|
|
87
|
+
// --------------------------------------------------
|
|
88
|
+
// SUCCESS
|
|
89
|
+
// --------------------------------------------------
|
|
90
|
+
|
|
32
91
|
success: "#16A34A",
|
|
92
|
+
|
|
93
|
+
successPressed: "#128238",
|
|
94
|
+
|
|
33
95
|
successSoft: "#EAF8EF",
|
|
34
96
|
|
|
97
|
+
successMuted: "#D1F2DC",
|
|
98
|
+
|
|
99
|
+
onSuccess: "#FFFFFF",
|
|
100
|
+
|
|
101
|
+
// --------------------------------------------------
|
|
102
|
+
// WARNING
|
|
103
|
+
// --------------------------------------------------
|
|
104
|
+
|
|
35
105
|
warning: "#D97706",
|
|
106
|
+
|
|
107
|
+
warningPressed: "#B85F00",
|
|
108
|
+
|
|
36
109
|
warningSoft: "#FFF7E6",
|
|
37
110
|
|
|
111
|
+
warningMuted: "#FDECC8",
|
|
112
|
+
|
|
113
|
+
onWarning: "#FFFFFF",
|
|
114
|
+
|
|
115
|
+
// --------------------------------------------------
|
|
116
|
+
// DANGER
|
|
117
|
+
// --------------------------------------------------
|
|
118
|
+
|
|
38
119
|
danger: "#DC2626",
|
|
120
|
+
|
|
121
|
+
dangerPressed: "#B91C1C",
|
|
122
|
+
|
|
39
123
|
dangerSoft: "#FDECEC",
|
|
40
124
|
|
|
125
|
+
dangerMuted: "#F8CACA",
|
|
126
|
+
|
|
127
|
+
onDanger: "#FFFFFF",
|
|
128
|
+
|
|
129
|
+
// --------------------------------------------------
|
|
130
|
+
// INFO
|
|
131
|
+
// --------------------------------------------------
|
|
132
|
+
|
|
41
133
|
info: "#2563EB",
|
|
134
|
+
|
|
135
|
+
infoPressed: "#1D4ED8",
|
|
136
|
+
|
|
42
137
|
infoSoft: "#EBF2FF",
|
|
43
138
|
|
|
44
|
-
|
|
45
|
-
|
|
139
|
+
infoMuted: "#D9E6FF",
|
|
140
|
+
|
|
141
|
+
onInfo: "#FFFFFF",
|
|
142
|
+
|
|
143
|
+
// --------------------------------------------------
|
|
144
|
+
// OVERLAYS
|
|
145
|
+
// --------------------------------------------------
|
|
146
|
+
|
|
147
|
+
overlay: "rgba(0, 0, 0, 0.45)",
|
|
148
|
+
|
|
149
|
+
backdrop: "rgba(0, 0, 0, 0.55)",
|
|
150
|
+
|
|
151
|
+
// --------------------------------------------------
|
|
152
|
+
// SKELETON
|
|
153
|
+
// --------------------------------------------------
|
|
46
154
|
|
|
47
155
|
skeleton: "#E5E5E5",
|
|
156
|
+
|
|
48
157
|
skeletonHighlight: "#F5F5F5",
|
|
158
|
+
|
|
159
|
+
// --------------------------------------------------
|
|
160
|
+
// BUTTON
|
|
161
|
+
// --------------------------------------------------
|
|
162
|
+
|
|
163
|
+
buttonPrimaryBackground: "#FF5A1F",
|
|
164
|
+
|
|
165
|
+
buttonPrimaryPressed: "#E94D17",
|
|
166
|
+
|
|
167
|
+
buttonPrimaryText: "#FFFFFF",
|
|
168
|
+
|
|
169
|
+
buttonOutlineBackground: "transparent",
|
|
170
|
+
|
|
171
|
+
buttonOutlineBorder: "#FF5A1F",
|
|
172
|
+
|
|
173
|
+
buttonOutlineText: "#FF5A1F",
|
|
174
|
+
|
|
175
|
+
buttonGhostBackground: "transparent",
|
|
176
|
+
|
|
177
|
+
buttonGhostText: "#FF5A1F",
|
|
178
|
+
|
|
179
|
+
buttonSoftBackground: "#FFF0EA",
|
|
180
|
+
|
|
181
|
+
buttonSoftText: "#FF5A1F",
|
|
182
|
+
|
|
183
|
+
buttonDangerBackground: "#DC2626",
|
|
184
|
+
|
|
185
|
+
buttonDangerPressed: "#B91C1C",
|
|
186
|
+
|
|
187
|
+
buttonDangerText: "#FFFFFF",
|
|
188
|
+
|
|
189
|
+
buttonSuccessBackground: "#16A34A",
|
|
190
|
+
|
|
191
|
+
buttonSuccessPressed: "#128238",
|
|
192
|
+
|
|
193
|
+
buttonSuccessText: "#FFFFFF",
|
|
194
|
+
|
|
195
|
+
buttonDisabledBackground: "#E5E5E5",
|
|
196
|
+
|
|
197
|
+
buttonDisabledText: "#A3A3A3",
|
|
198
|
+
|
|
199
|
+
buttonDisabledBorder: "#E5E5E5",
|
|
200
|
+
|
|
201
|
+
buttonRipple: "rgba(255, 255, 255, 0.20)",
|
|
49
202
|
};
|
|
50
203
|
|
|
51
204
|
export const darkColors = {
|
|
205
|
+
// --------------------------------------------------
|
|
206
|
+
// BASE
|
|
207
|
+
// --------------------------------------------------
|
|
208
|
+
|
|
52
209
|
transparent: "transparent",
|
|
53
210
|
|
|
211
|
+
// --------------------------------------------------
|
|
212
|
+
// BRAND
|
|
213
|
+
// --------------------------------------------------
|
|
214
|
+
|
|
54
215
|
primary: "#FF7040",
|
|
55
216
|
primaryPressed: "#FF5A1F",
|
|
217
|
+
primaryHover: "#FF8158",
|
|
56
218
|
primarySoft: "#3A1C11",
|
|
219
|
+
primaryMuted: "#542719",
|
|
220
|
+
|
|
57
221
|
onPrimary: "#FFFFFF",
|
|
58
222
|
|
|
223
|
+
// --------------------------------------------------
|
|
224
|
+
// SECONDARY
|
|
225
|
+
// --------------------------------------------------
|
|
226
|
+
|
|
59
227
|
secondary: "#7CFF32",
|
|
228
|
+
secondaryPressed: "#68E51F",
|
|
60
229
|
secondarySoft: "#1B3010",
|
|
230
|
+
secondaryMuted: "#29451B",
|
|
231
|
+
|
|
61
232
|
onSecondary: "#111111",
|
|
62
233
|
|
|
234
|
+
// --------------------------------------------------
|
|
235
|
+
// BACKGROUNDS
|
|
236
|
+
// --------------------------------------------------
|
|
237
|
+
|
|
63
238
|
background: "#0B0B0B",
|
|
239
|
+
|
|
64
240
|
surface: "#151515",
|
|
241
|
+
|
|
65
242
|
surfaceSecondary: "#1D1D1D",
|
|
243
|
+
|
|
244
|
+
surfaceTertiary: "#252525",
|
|
245
|
+
|
|
66
246
|
card: "#181818",
|
|
67
247
|
|
|
248
|
+
cardElevated: "#202020",
|
|
249
|
+
|
|
250
|
+
// --------------------------------------------------
|
|
251
|
+
// TEXT
|
|
252
|
+
// --------------------------------------------------
|
|
253
|
+
|
|
68
254
|
text: "#F5F5F5",
|
|
255
|
+
|
|
69
256
|
textSecondary: "#D4D4D4",
|
|
257
|
+
|
|
70
258
|
textMuted: "#A3A3A3",
|
|
259
|
+
|
|
71
260
|
textDisabled: "#666666",
|
|
261
|
+
|
|
72
262
|
textInverse: "#111111",
|
|
73
263
|
|
|
264
|
+
// --------------------------------------------------
|
|
265
|
+
// BORDER
|
|
266
|
+
// --------------------------------------------------
|
|
267
|
+
|
|
74
268
|
border: "#292929",
|
|
269
|
+
|
|
75
270
|
borderStrong: "#3A3A3A",
|
|
271
|
+
|
|
272
|
+
borderSubtle: "#202020",
|
|
273
|
+
|
|
76
274
|
divider: "#252525",
|
|
77
275
|
|
|
276
|
+
// --------------------------------------------------
|
|
277
|
+
// INPUT
|
|
278
|
+
// --------------------------------------------------
|
|
279
|
+
|
|
78
280
|
input: "#1C1C1C",
|
|
281
|
+
|
|
79
282
|
inputFocused: "#202020",
|
|
283
|
+
|
|
80
284
|
inputDisabled: "#242424",
|
|
81
285
|
|
|
286
|
+
inputBorder: "#303030",
|
|
287
|
+
|
|
288
|
+
inputBorderFocused: "#FF7040",
|
|
289
|
+
|
|
290
|
+
// --------------------------------------------------
|
|
291
|
+
// SUCCESS
|
|
292
|
+
// --------------------------------------------------
|
|
293
|
+
|
|
82
294
|
success: "#4ADE80",
|
|
295
|
+
|
|
296
|
+
successPressed: "#22C55E",
|
|
297
|
+
|
|
83
298
|
successSoft: "#12351F",
|
|
84
299
|
|
|
300
|
+
successMuted: "#1C4829",
|
|
301
|
+
|
|
302
|
+
onSuccess: "#071A0D",
|
|
303
|
+
|
|
304
|
+
// --------------------------------------------------
|
|
305
|
+
// WARNING
|
|
306
|
+
// --------------------------------------------------
|
|
307
|
+
|
|
85
308
|
warning: "#FBBF24",
|
|
309
|
+
|
|
310
|
+
warningPressed: "#F59E0B",
|
|
311
|
+
|
|
86
312
|
warningSoft: "#382B0B",
|
|
87
313
|
|
|
314
|
+
warningMuted: "#4A380F",
|
|
315
|
+
|
|
316
|
+
onWarning: "#111111",
|
|
317
|
+
|
|
318
|
+
// --------------------------------------------------
|
|
319
|
+
// DANGER
|
|
320
|
+
// --------------------------------------------------
|
|
321
|
+
|
|
88
322
|
danger: "#F87171",
|
|
323
|
+
|
|
324
|
+
dangerPressed: "#EF4444",
|
|
325
|
+
|
|
89
326
|
dangerSoft: "#3B1616",
|
|
90
327
|
|
|
328
|
+
dangerMuted: "#511E1E",
|
|
329
|
+
|
|
330
|
+
onDanger: "#FFFFFF",
|
|
331
|
+
|
|
332
|
+
// --------------------------------------------------
|
|
333
|
+
// INFO
|
|
334
|
+
// --------------------------------------------------
|
|
335
|
+
|
|
91
336
|
info: "#60A5FA",
|
|
337
|
+
|
|
338
|
+
infoPressed: "#3B82F6",
|
|
339
|
+
|
|
92
340
|
infoSoft: "#132A46",
|
|
93
341
|
|
|
94
|
-
|
|
95
|
-
|
|
342
|
+
infoMuted: "#1C3554",
|
|
343
|
+
|
|
344
|
+
onInfo: "#FFFFFF",
|
|
345
|
+
|
|
346
|
+
// --------------------------------------------------
|
|
347
|
+
// OVERLAYS
|
|
348
|
+
// --------------------------------------------------
|
|
349
|
+
|
|
350
|
+
overlay: "rgba(0, 0, 0, 0.60)",
|
|
351
|
+
|
|
352
|
+
backdrop: "rgba(0, 0, 0, 0.72)",
|
|
353
|
+
|
|
354
|
+
// --------------------------------------------------
|
|
355
|
+
// SKELETON
|
|
356
|
+
// --------------------------------------------------
|
|
96
357
|
|
|
97
358
|
skeleton: "#292929",
|
|
359
|
+
|
|
98
360
|
skeletonHighlight: "#3A3A3A",
|
|
361
|
+
|
|
362
|
+
// --------------------------------------------------
|
|
363
|
+
// BUTTON
|
|
364
|
+
// --------------------------------------------------
|
|
365
|
+
|
|
366
|
+
buttonPrimaryBackground: "#FF7040",
|
|
367
|
+
|
|
368
|
+
buttonPrimaryPressed: "#FF5A1F",
|
|
369
|
+
|
|
370
|
+
buttonPrimaryText: "#FFFFFF",
|
|
371
|
+
|
|
372
|
+
buttonOutlineBackground: "transparent",
|
|
373
|
+
|
|
374
|
+
buttonOutlineBorder: "#FF7040",
|
|
375
|
+
|
|
376
|
+
buttonOutlineText: "#FF7040",
|
|
377
|
+
|
|
378
|
+
buttonGhostBackground: "transparent",
|
|
379
|
+
|
|
380
|
+
buttonGhostText: "#FF7040",
|
|
381
|
+
|
|
382
|
+
buttonSoftBackground: "#3A1C11",
|
|
383
|
+
|
|
384
|
+
buttonSoftText: "#FF7040",
|
|
385
|
+
|
|
386
|
+
buttonDangerBackground: "#F87171",
|
|
387
|
+
|
|
388
|
+
buttonDangerPressed: "#EF4444",
|
|
389
|
+
|
|
390
|
+
buttonDangerText: "#FFFFFF",
|
|
391
|
+
|
|
392
|
+
buttonSuccessBackground: "#4ADE80",
|
|
393
|
+
|
|
394
|
+
buttonSuccessPressed: "#22C55E",
|
|
395
|
+
|
|
396
|
+
buttonSuccessText: "#071A0D",
|
|
397
|
+
|
|
398
|
+
buttonDisabledBackground: "#292929",
|
|
399
|
+
|
|
400
|
+
buttonDisabledText: "#666666",
|
|
401
|
+
|
|
402
|
+
buttonDisabledBorder: "#292929",
|
|
403
|
+
|
|
404
|
+
buttonRipple: "rgba(255, 255, 255, 0.16)",
|
|
99
405
|
};
|