react-native-varia 0.3.0 → 0.4.1

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 (45) hide show
  1. package/lib/components/Accordion.tsx +61 -21
  2. package/lib/components/Badge.tsx +9 -0
  3. package/lib/components/Button.tsx +19 -8
  4. package/lib/components/Checkbox.tsx +21 -12
  5. package/lib/components/CircleProgress.tsx +8 -0
  6. package/lib/components/Divider.tsx +6 -0
  7. package/lib/components/Drawer.tsx +16 -4
  8. package/lib/components/Field.tsx +4 -0
  9. package/lib/components/FloatingAction.tsx +215 -0
  10. package/lib/components/GradientBackground.tsx +3 -0
  11. package/lib/components/GradientText.tsx +27 -14
  12. package/lib/components/IconWrapper.tsx +4 -3
  13. package/lib/components/Input.tsx +47 -21
  14. package/lib/components/Link.tsx +4 -0
  15. package/lib/components/Modal.tsx +18 -5
  16. package/lib/components/NumberInput.tsx +27 -5
  17. package/lib/components/RadioGroup.tsx +16 -5
  18. package/lib/components/ReText.tsx +4 -1
  19. package/lib/components/Select.tsx +20 -0
  20. package/lib/components/Slider.tsx +59 -23
  21. package/lib/components/Slideshow.tsx +19 -3
  22. package/lib/components/Spinner.tsx +9 -3
  23. package/lib/components/Switch.tsx +57 -26
  24. package/lib/components/Text.tsx +3 -0
  25. package/lib/components/Toast.tsx +110 -36
  26. package/lib/patterns/index.tsx +299 -90
  27. package/lib/theme/Accordion.tsx +184 -0
  28. package/lib/theme/Button.recipe.tsx +24 -7
  29. package/lib/theme/Drawer.recipe.tsx +2 -4
  30. package/lib/theme/Field.recipe.tsx +45 -15
  31. package/lib/theme/FloatingAction.tsx +112 -0
  32. package/lib/theme/GradientText.recipe.tsx +103 -34
  33. package/lib/theme/Input.recipe.tsx +14 -6
  34. package/lib/theme/Select.recipe.tsx +3 -0
  35. package/lib/theme/Slider.recipe.tsx +86 -150
  36. package/lib/theme/Spinner.recipe.tsx +4 -0
  37. package/lib/theme/Switch.recipe.tsx +19 -0
  38. package/lib/theme/Text.recipe.tsx +63 -12
  39. package/lib/theme/Toast.recipe.tsx +40 -7
  40. package/lib/varia/types.ts +3 -0
  41. package/lib/varia/utils.ts +110 -18
  42. package/package.json +1 -1
  43. package/lib/components/OldSlider.tsx +0 -327
  44. package/lib/components/SlidingDrawer.tsx +0 -301
  45. package/lib/patterns/newPatterns.tsx +0 -285
@@ -8,7 +8,7 @@ export const SliderDefaultVariants = {
8
8
  export const SliderStyles = StyleSheet.create(theme => ({
9
9
  container: (colorPalette: PalettesWithNestedKeys) => ({
10
10
  backgroundColor: theme.colors.bg.emphasized,
11
- borderRadius: theme.radii['2xl'],
11
+ borderRadius: theme.radii.xl,
12
12
  variants: {
13
13
  axis: {
14
14
  x: {},
@@ -16,34 +16,25 @@ export const SliderStyles = StyleSheet.create(theme => ({
16
16
  },
17
17
  variant: {
18
18
  solid: {},
19
- },
20
- size: {
21
- xs: {
22
- // height: theme.sizes[2],
23
- },
24
- sm: {
25
- // height: theme.sizes[4],
26
- },
27
- md: {
28
- // height: theme.sizes[5],
19
+ outline: {
20
+ borderRadius: theme.radii.sm,
21
+ borderColor: theme.colors[colorPalette].default,
22
+ borderWidth: 1,
29
23
  },
30
- lg: {
31
- // height: theme.sizes[8],
32
- },
33
- xl: {
34
- // height: theme.sizes[10],
24
+ subtle: {
25
+ backgroundColor: theme.colors.bg.subtle,
35
26
  },
27
+ },
28
+ size: {
29
+ sm: {},
30
+ md: {},
31
+ lg: {},
32
+ xl: {},
36
33
  flex: {},
34
+ minimal: {},
37
35
  },
38
36
  },
39
37
  compoundVariants: [
40
- {
41
- axis: 'x',
42
- size: 'xs',
43
- styles: {
44
- height: theme.sizes[2],
45
- },
46
- },
47
38
  {
48
39
  axis: 'x',
49
40
  size: 'sm',
@@ -79,13 +70,6 @@ export const SliderStyles = StyleSheet.create(theme => ({
79
70
  minHeight: 50,
80
71
  },
81
72
  },
82
- {
83
- axis: 'y',
84
- size: 'xs',
85
- styles: {
86
- width: theme.sizes[2],
87
- },
88
- },
89
73
  {
90
74
  axis: 'y',
91
75
  size: 'sm',
@@ -125,8 +109,6 @@ export const SliderStyles = StyleSheet.create(theme => ({
125
109
  }),
126
110
  maximumTrack: (colorPalette: PalettesWithNestedKeys) => ({
127
111
  backgroundColor: theme.colors.bg.emphasized,
128
- // borderRadius: theme.radii.full,
129
- // height: theme.sizes[5],
130
112
  variants: {
131
113
  axis: {
132
114
  x: {},
@@ -134,34 +116,21 @@ export const SliderStyles = StyleSheet.create(theme => ({
134
116
  },
135
117
  variant: {
136
118
  solid: {},
119
+ outline: {},
120
+ subtle: {
121
+ backgroundColor: theme.colors.bg.subtle,
122
+ },
137
123
  },
138
124
  size: {
139
- xs: {
140
- // height: theme.sizes[2],
141
- },
142
- sm: {
143
- // height: theme.sizes[4],
144
- },
145
- md: {
146
- // height: theme.sizes[5],
147
- },
148
- lg: {
149
- // height: theme.sizes[8],
150
- },
151
- xl: {
152
- // height: theme.sizes[10],
153
- },
125
+ sm: {},
126
+ md: {},
127
+ lg: {},
128
+ xl: {},
154
129
  flex: {},
130
+ minimal: {},
155
131
  },
156
132
  },
157
133
  compoundVariants: [
158
- {
159
- axis: 'x',
160
- size: 'xs',
161
- styles: {
162
- height: theme.sizes[2],
163
- },
164
- },
165
134
  {
166
135
  axis: 'x',
167
136
  size: 'sm',
@@ -195,13 +164,6 @@ export const SliderStyles = StyleSheet.create(theme => ({
195
164
  size: 'flex',
196
165
  styles: {},
197
166
  },
198
- {
199
- axis: 'y',
200
- size: 'xs',
201
- styles: {
202
- width: theme.sizes[2],
203
- },
204
- },
205
167
  {
206
168
  axis: 'y',
207
169
  size: 'sm',
@@ -232,50 +194,38 @@ export const SliderStyles = StyleSheet.create(theme => ({
232
194
  },
233
195
  ],
234
196
  }),
235
- minimumTrack: (
236
- colorPalette: PalettesWithNestedKeys,
237
- opacityTrack: boolean,
238
- ) => ({
197
+ minimumTrack: (colorPalette: PalettesWithNestedKeys) => ({
239
198
  backgroundColor: theme.colors[colorPalette].default,
240
- // opacityTrack
241
- // ? hexToRgba(theme.colors[colorPalette].default, 0.5)
242
- // : theme.colors[colorPalette].default,
243
- // height: theme.sizes[5],
244
199
  variants: {
245
200
  axis: {
246
- x: {},
247
- y: {},
201
+ x: {
202
+ borderBottomLeftRadius: theme.radii.xl,
203
+ borderBottomRightRadius: 0,
204
+ borderTopLeftRadius: theme.radii.xl,
205
+ },
206
+ y: {
207
+ borderBottomLeftRadius: theme.radii.xl,
208
+ borderBottomRightRadius: theme.radii.xl,
209
+ borderTopLeftRadius: 0,
210
+ },
248
211
  },
249
212
  variant: {
250
213
  solid: {},
214
+ outline: {},
215
+ subtle: {},
251
216
  },
252
217
  size: {
253
- xs: {
254
- // height: theme.sizes[2],
255
- },
256
- sm: {
257
- // height: theme.sizes[4],
258
- },
259
- md: {
260
- // height: theme.sizes[5],
261
- },
262
- lg: {
263
- // height: theme.sizes[8],
264
- },
265
- xl: {
266
- // height: theme.sizes[10],
267
- },
218
+ sm: {},
219
+ md: {},
220
+ lg: {},
221
+ xl: {},
268
222
  flex: {},
223
+ minimal: {
224
+ borderRadius: theme.radii.sm,
225
+ },
269
226
  },
270
227
  },
271
228
  compoundVariants: [
272
- {
273
- axis: 'x',
274
- size: 'xs',
275
- styles: {
276
- height: theme.sizes[2],
277
- },
278
- },
279
229
  {
280
230
  axis: 'x',
281
231
  size: 'sm',
@@ -309,13 +259,6 @@ export const SliderStyles = StyleSheet.create(theme => ({
309
259
  size: 'flex',
310
260
  styles: {},
311
261
  },
312
- {
313
- axis: 'y',
314
- size: 'xs',
315
- styles: {
316
- width: theme.sizes[2],
317
- },
318
- },
319
262
  {
320
263
  axis: 'y',
321
264
  size: 'sm',
@@ -344,59 +287,43 @@ export const SliderStyles = StyleSheet.create(theme => ({
344
287
  width: theme.sizes[10],
345
288
  },
346
289
  },
290
+ {
291
+ axis: 'y',
292
+ size: 'flex',
293
+ styles: {},
294
+ },
347
295
  ],
348
296
  }),
349
297
  thumb: (colorPalette: PalettesWithNestedKeys) => ({
350
- backgroundColor: theme.colors.bg.default,
351
- borderColor: theme.colors[colorPalette].default,
352
- borderRadius: theme.radii.full,
353
- borderWidth: 2,
354
- // width: theme.sizes[7],
355
- // height: theme.sizes[7],
356
298
  variants: {
357
299
  axis: {
358
300
  x: {},
359
301
  y: {},
360
302
  },
361
303
  variant: {
362
- solid: {},
363
- },
364
- size: {
365
- xs: {
366
- // width: theme.sizes[4],
367
- // height: theme.sizes[4],
368
- },
369
- sm: {
370
- // width: theme.sizes[6],
371
- // height: theme.sizes[6],
372
- },
373
- md: {
374
- // width: theme.sizes[7],
375
- // height: theme.sizes[7],
376
- },
377
- lg: {
378
- // width: theme.sizes[8],
379
- // height: theme.sizes[8],
304
+ solid: {
305
+ backgroundColor: theme.colors.bg.default,
306
+ borderColor: theme.colors[colorPalette].default,
307
+ borderRadius: theme.radii.full,
308
+ borderWidth: 2,
380
309
  },
381
- xl: {
382
- // width: theme.sizes[11],
383
- // height: theme.sizes[11],
310
+ subtle: {
311
+ backgroundColor: theme.colors[colorPalette].default,
384
312
  },
385
- flex: {
386
- // width: 30,
387
- // height: 50,
313
+ outline: {
314
+ backgroundColor: theme.colors[colorPalette][11],
388
315
  },
389
316
  },
317
+ size: {
318
+ sm: {},
319
+ md: {},
320
+ lg: {},
321
+ xl: {},
322
+ flex: {},
323
+ minimal: {},
324
+ },
390
325
  },
391
326
  compoundVariants: [
392
- {
393
- axis: 'x',
394
- size: 'xs',
395
- styles: {
396
- width: theme.sizes[4],
397
- height: theme.sizes[4],
398
- },
399
- },
400
327
  {
401
328
  axis: 'x',
402
329
  size: 'sm',
@@ -440,11 +367,13 @@ export const SliderStyles = StyleSheet.create(theme => ({
440
367
  },
441
368
  },
442
369
  {
443
- axis: 'y',
444
- size: 'xs',
370
+ axis: 'x',
371
+ size: 'minimal',
445
372
  styles: {
446
- width: theme.sizes[4],
447
- height: theme.sizes[4],
373
+ width: 0,
374
+ // height: 50,
375
+ // alignSel: 'stretch',
376
+ // flex: 1,
448
377
  },
449
378
  },
450
379
  {
@@ -487,11 +416,17 @@ export const SliderStyles = StyleSheet.create(theme => ({
487
416
  height: 30,
488
417
  },
489
418
  },
419
+ {
420
+ axis: 'y',
421
+ size: 'minimal',
422
+ styles: {
423
+ alignSelf: 'stretch',
424
+ height: 5,
425
+ },
426
+ },
490
427
  ],
491
428
  }),
492
429
  step: (colorPalette: PalettesWithNestedKeys) => ({
493
- // TODO: type correctly theme.colors
494
- // @ts-ignore
495
430
  backgroundColor: theme.colors.bg.default,
496
431
  variants: {
497
432
  axis: {
@@ -499,18 +434,19 @@ export const SliderStyles = StyleSheet.create(theme => ({
499
434
  y: {},
500
435
  },
501
436
  variant: {
502
- solid: {},
437
+ solid: {
438
+ backgroundColor: theme.colors.bg.default,
439
+ },
440
+ subtle: {},
441
+ outline: {},
503
442
  },
504
443
  size: {
505
- xs: {},
506
444
  sm: {},
507
445
  md: {},
508
446
  lg: {},
509
447
  xl: {},
510
- flex: {
511
- width: 5,
512
- height: 5,
513
- },
448
+ flex: {},
449
+ minimal: {},
514
450
  },
515
451
  },
516
452
  }),
@@ -10,6 +10,7 @@ export const SpinnerTokens = {
10
10
 
11
11
  export const SpinnerStyles = StyleSheet.create(theme => ({
12
12
  base: {
13
+ height: 100,
13
14
  variants: {
14
15
  size: {
15
16
  xs: {
@@ -29,5 +30,8 @@ export const SpinnerStyles = StyleSheet.create(theme => ({
29
30
  },
30
31
  },
31
32
  },
33
+ _web: {
34
+ height: 120,
35
+ },
32
36
  },
33
37
  }))
@@ -30,7 +30,11 @@ export const SwitchTokens = {
30
30
 
31
31
  export const SwitchStyles = StyleSheet.create(theme => ({
32
32
  container: (colorPalette: PalettesWithNestedKeys) => ({
33
+ // width: theme.sizes[16],
34
+ // height: theme.sizes[16],
33
35
  borderRadius: theme.radii.full,
36
+ padding: theme.spacing['0.5'],
37
+ borderWidth: 0,
34
38
  variants: {
35
39
  variant: {
36
40
  solid: {},
@@ -39,14 +43,21 @@ export const SwitchStyles = StyleSheet.create(theme => ({
39
43
  sm: {
40
44
  padding: theme.spacing['0.5'],
41
45
  maxWidth: theme.sizes[10],
46
+ minWidth: theme.sizes[10],
42
47
  },
43
48
  md: {
44
49
  padding: theme.spacing['0.5'],
45
50
  maxWidth: theme.sizes[16],
51
+ minWidth: theme.sizes[16],
46
52
  },
47
53
  lg: {
48
54
  padding: theme.spacing[1],
49
55
  maxWidth: theme.sizes[20],
56
+ minWidth: theme.sizes[20],
57
+ },
58
+ flex: {
59
+ borderRadius: theme.radii.md,
60
+ // alignSelf: 'stretch',
50
61
  },
51
62
  },
52
63
  enabled: {
@@ -70,6 +81,8 @@ export const SwitchStyles = StyleSheet.create(theme => ({
70
81
  thumb: (colorPalette: PalettesWithNestedKeys) => ({
71
82
  backgroundColor: theme.colors.bg.default,
72
83
  borderRadius: theme.radii.full,
84
+ // width: theme.sizes[6],
85
+ // height: theme.sizes[6],
73
86
  variants: {
74
87
  variant: {
75
88
  solid: {},
@@ -78,6 +91,12 @@ export const SwitchStyles = StyleSheet.create(theme => ({
78
91
  sm: {height: theme.sizes[5], width: theme.sizes[5]},
79
92
  md: {height: theme.sizes[6], width: theme.sizes[6]},
80
93
  lg: {height: theme.sizes[8], width: theme.sizes[8]},
94
+ flex: {
95
+ borderRadius: theme.radii.md,
96
+ alignSelf: 'stretch',
97
+ width: 30,
98
+ minHeight: 30,
99
+ },
81
100
  },
82
101
  },
83
102
  compoundVariants: [
@@ -11,7 +11,7 @@ export const TextStyles = StyleSheet.create(theme => ({
11
11
  variant: {
12
12
  heading: {
13
13
  color: theme.colors.fg.default,
14
- fontWeight: theme.fontWeights.semibold,
14
+ fontWeight: theme.fontWeights.bold,
15
15
  },
16
16
  default: {
17
17
  color: theme.colors.fg.default,
@@ -19,46 +19,97 @@ export const TextStyles = StyleSheet.create(theme => ({
19
19
  },
20
20
  },
21
21
  size: {
22
+ // xs: {
23
+ // ...textStyle.xs,
24
+ // // fontSize: 100
25
+ // },
26
+ // sm: {
27
+ // ...textStyle.sm,
28
+ // // fontSize: 100
29
+ // },
30
+ // md: {
31
+ // // ...textStyle.md,
32
+ // fontSize: 100
33
+ // },
34
+ // lg: {
35
+ // ...textStyle.lg,
36
+ // },
37
+ // xl: {
38
+ // ...textStyle.xl,
39
+ // },
40
+ // '2xl': {
41
+ // ...textStyle['2xl'],
42
+ // lineHeight: 32,
43
+ // },
44
+ // '3xl': {
45
+ // ...textStyle['3xl'],
46
+ // lineHeight: 38,
47
+ // },
48
+ // '4xl': {
49
+ // ...textStyle['4xl'],
50
+ // lineHeight: 44,
51
+ // letterSpacing: -0.032,
52
+ // },
53
+ // '5xl': {
54
+ // ...textStyle['5xl'],
55
+ // lineHeight: 60,
56
+ // letterSpacing: -0.032,
57
+ // },
58
+ // '6xl': {
59
+ // ...textStyle['6xl'],
60
+ // lineHeight: 72,
61
+ // letterSpacing: -0.032,
62
+ // },
63
+ // '7xl': {
64
+ // ...textStyle['7xl'],
65
+ // lineHeight: 92,
66
+ // letterSpacing: -0.032,
67
+ // },
22
68
  xs: {
23
- ...textStyle.xs,
69
+ fontSize: theme.fontSizes.xs,
70
+ lineHeight: 12,
24
71
  },
25
72
  sm: {
26
- ...textStyle.sm,
73
+ fontSize: theme.fontSizes.sm,
74
+ lineHeight: 20,
27
75
  },
28
76
  md: {
29
- ...textStyle.md,
77
+ fontSize: theme.fontSizes.md,
78
+ lineHeight: 24,
30
79
  },
31
80
  lg: {
32
- ...textStyle.lg,
81
+ fontSize: theme.fontSizes.lg,
82
+ lineHeight: 28,
33
83
  },
34
84
  xl: {
35
- ...textStyle.xl,
85
+ fontSize: theme.fontSizes.xl,
86
+ lineHeight: 30,
36
87
  },
37
88
  '2xl': {
38
- ...textStyle['2xl'],
89
+ fontSize: theme.fontSizes['2xl'],
39
90
  lineHeight: 32,
40
91
  },
41
92
  '3xl': {
42
- ...textStyle['3xl'],
93
+ fontSize: theme.fontSizes['3xl'],
43
94
  lineHeight: 38,
44
95
  },
45
96
  '4xl': {
46
- ...textStyle['4xl'],
97
+ fontSize: theme.fontSizes['4xl'],
47
98
  lineHeight: 44,
48
99
  letterSpacing: -0.032,
49
100
  },
50
101
  '5xl': {
51
- ...textStyle['5xl'],
102
+ fontSize: theme.fontSizes['5xl'],
52
103
  lineHeight: 60,
53
104
  letterSpacing: -0.032,
54
105
  },
55
106
  '6xl': {
56
- ...textStyle['6xl'],
107
+ fontSize: theme.fontSizes['6xl'],
57
108
  lineHeight: 72,
58
109
  letterSpacing: -0.032,
59
110
  },
60
111
  '7xl': {
61
- ...textStyle['7xl'],
112
+ fontSize: theme.fontSizes['7xl'],
62
113
  lineHeight: 92,
63
114
  letterSpacing: -0.032,
64
115
  },
@@ -8,7 +8,34 @@ export const ToastDefaultVariants = {
8
8
  } as const
9
9
 
10
10
  export const ToastStyles = StyleSheet.create(theme => ({
11
+ root: {
12
+ variants: {
13
+ variant: {
14
+ solid: {},
15
+ subtle: {},
16
+ outline: {},
17
+ error: {},
18
+ },
19
+ size: {
20
+ sm: {
21
+ marginVertical: theme.spacing[6],
22
+ marginHorizontal: theme.spacing[6],
23
+ },
24
+ md: {
25
+ marginVertical: theme.spacing[10],
26
+ marginHorizontal: theme.spacing[10],
27
+ },
28
+ lg: {
29
+ marginVertical: theme.spacing[12],
30
+ marginHorizontal: theme.spacing[10],
31
+ },
32
+ },
33
+ },
34
+ },
11
35
  container: (colorPalette: PalettesWithNestedKeys) => ({
36
+ borderRadius: theme.radii.md,
37
+ alignItems: 'center',
38
+ backgroundColor: theme.colors[colorPalette].default,
12
39
  variants: {
13
40
  variant: {
14
41
  solid: {
@@ -21,7 +48,8 @@ export const ToastStyles = StyleSheet.create(theme => ({
21
48
  },
22
49
  outline: {
23
50
  borderWidth: 2,
24
- borderColor: theme.colors.border.default,
51
+ backgroundColor: theme.colors.bg.subtle,
52
+ borderColor: theme.colors[colorPalette][5],
25
53
  },
26
54
  error: {
27
55
  borderColor: theme.colors.red[9],
@@ -31,13 +59,15 @@ export const ToastStyles = StyleSheet.create(theme => ({
31
59
  },
32
60
  size: {
33
61
  sm: {
34
- bottom: theme.spacing[5],
62
+ padding: theme.spacing[3],
35
63
  },
36
64
  md: {
37
- bottom: theme.spacing[5],
65
+ padding: theme.spacing[4],
66
+ alignSelf: 'stretch',
38
67
  },
39
68
  lg: {
40
- bottom: theme.spacing[8],
69
+ padding: theme.spacing[4],
70
+ alignSelf: 'stretch',
41
71
  },
42
72
  },
43
73
  },
@@ -57,13 +87,16 @@ export const ToastStyles = StyleSheet.create(theme => ({
57
87
  },
58
88
  size: {
59
89
  sm: {
60
- ...textStyle.xs,
90
+ // ...textStyle.xs,
91
+ fontSize: theme.fontSizes.xs,
61
92
  },
62
93
  md: {
63
- ...textStyle.xs,
94
+ // ...textStyle.xs,
95
+ fontSize: theme.fontSizes.xs,
64
96
  },
65
97
  lg: {
66
- ...textStyle.sm,
98
+ // ...textStyle.sm,
99
+ fontSize: theme.fontSizes.sm,
67
100
  },
68
101
  },
69
102
  },
@@ -279,6 +279,9 @@ export function createCircleProgressTokens<
279
279
 
280
280
  export type AlignSelf = ViewStyle['alignSelf']
281
281
  export type StackDirection = 'row' | 'column'
282
+ export type JustifyContent = ViewStyle['justifyContent']
283
+ export type Gap = ViewStyle['gap']
284
+ export type AlignItems = ViewStyle['alignItems']
282
285
  export type progressDirection = 'forward' | 'reverse'
283
286
  export type rotationDirection = 'clockwise' | 'counterclockwise'
284
287
  export type Flex = ViewStyle['flex']