react-native-varia 0.3.0 → 0.4.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 (43) 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/GradientBackground.tsx +3 -0
  10. package/lib/components/GradientText.tsx +27 -14
  11. package/lib/components/IconWrapper.tsx +3 -2
  12. package/lib/components/Input.tsx +47 -21
  13. package/lib/components/Link.tsx +4 -0
  14. package/lib/components/Modal.tsx +18 -5
  15. package/lib/components/NumberInput.tsx +27 -5
  16. package/lib/components/RadioGroup.tsx +16 -5
  17. package/lib/components/ReText.tsx +4 -1
  18. package/lib/components/Select.tsx +20 -0
  19. package/lib/components/Slider.tsx +59 -23
  20. package/lib/components/Slideshow.tsx +19 -3
  21. package/lib/components/Spinner.tsx +9 -3
  22. package/lib/components/Switch.tsx +57 -26
  23. package/lib/components/Text.tsx +3 -0
  24. package/lib/components/Toast.tsx +110 -36
  25. package/lib/patterns/index.tsx +299 -90
  26. package/lib/theme/Accordion.tsx +184 -0
  27. package/lib/theme/Button.recipe.tsx +24 -7
  28. package/lib/theme/Drawer.recipe.tsx +2 -4
  29. package/lib/theme/Field.recipe.tsx +45 -15
  30. package/lib/theme/GradientText.recipe.tsx +103 -34
  31. package/lib/theme/Input.recipe.tsx +14 -6
  32. package/lib/theme/Select.recipe.tsx +3 -0
  33. package/lib/theme/Slider.recipe.tsx +86 -150
  34. package/lib/theme/Spinner.recipe.tsx +4 -0
  35. package/lib/theme/Switch.recipe.tsx +19 -0
  36. package/lib/theme/Text.recipe.tsx +63 -12
  37. package/lib/theme/Toast.recipe.tsx +40 -7
  38. package/lib/varia/types.ts +3 -0
  39. package/lib/varia/utils.ts +110 -18
  40. package/package.json +1 -1
  41. package/lib/components/OldSlider.tsx +0 -327
  42. package/lib/components/SlidingDrawer.tsx +0 -301
  43. package/lib/patterns/newPatterns.tsx +0 -285
@@ -23,15 +23,13 @@ export const FieldStyles = StyleSheet.create(theme => ({
23
23
  color: theme.colors.fg.default,
24
24
  variants: {
25
25
  variant: {
26
- solid: {
27
- // transform: [{translateY: theme.spacing['3.5']}],
28
- // marginLeft: theme.spacing['3'],
29
- // paddingHorizontal: theme.spacing['1'],
30
- backgroundColor: theme.colors.bg.default,
31
- zIndex: 10,
32
- flex: 0,
33
- width: 'auto',
26
+ solid: {},
27
+ floating: {
34
28
  alignSelf: 'baseline',
29
+ width: 'auto',
30
+ flex: 0,
31
+ zIndex: 10,
32
+ backgroundColor: theme.colors.bg.default,
35
33
  },
36
34
  },
37
35
  size: {
@@ -43,18 +41,50 @@ export const FieldStyles = StyleSheet.create(theme => ({
43
41
  },
44
42
  md: {
45
43
  fontSize: theme.fontSizes.md,
46
- transform: [{translateY: theme.spacing['4.5']}],
47
- marginLeft: theme.spacing['2'],
48
- paddingHorizontal: theme.spacing['1'],
49
44
  },
50
45
  lg: {
51
- fontSize: theme.fontSizes['2xl'],
52
- transform: [{translateY: theme.spacing['5']}],
53
- marginLeft: theme.spacing['2.5'],
54
- paddingHorizontal: theme.spacing['1'],
46
+ fontSize: theme.fontSizes['lg'],
55
47
  },
56
48
  },
57
49
  },
50
+ compoundVariants: [
51
+ {
52
+ variant: 'floating',
53
+ size: 'xs',
54
+ styles: {
55
+ paddingHorizontal: theme.spacing['1'],
56
+ marginLeft: theme.spacing['1'],
57
+ transform: [{translateY: theme.spacing['3']}],
58
+ },
59
+ },
60
+ {
61
+ variant: 'floating',
62
+ size: 'sm',
63
+ styles: {
64
+ paddingHorizontal: theme.spacing['1'],
65
+ marginLeft: theme.spacing['2'],
66
+ transform: [{translateY: theme.spacing['3.5']}],
67
+ },
68
+ },
69
+ {
70
+ variant: 'floating',
71
+ size: 'md',
72
+ styles: {
73
+ paddingHorizontal: theme.spacing['1'],
74
+ marginLeft: theme.spacing['2'],
75
+ transform: [{translateY: theme.spacing['4.5']}],
76
+ },
77
+ },
78
+ {
79
+ variant: 'floating',
80
+ size: 'lg',
81
+ styles: {
82
+ paddingHorizontal: theme.spacing['1.5'],
83
+ marginLeft: theme.spacing['2'],
84
+ transform: [{translateY: theme.spacing['6']}],
85
+ },
86
+ },
87
+ ],
58
88
  }),
59
89
  error: (colorPalette: PalettesWithNestedKeys) => ({
60
90
  color: theme.colors.fg.error,
@@ -1,5 +1,6 @@
1
+ import { StyleSheet } from 'react-native-unistyles'
1
2
  import {textStyle} from '../style/varia/textStyles'
2
- import {createGradientTextTokens} from '../style/varia/types'
3
+ import {createGradientTextTokens, PalettesWithNestedKeys} from '../style/varia/types'
3
4
 
4
5
  export const gradientTextTokens = createGradientTextTokens({
5
6
  defaultProps: {
@@ -25,39 +26,107 @@ export const gradientTextTokens = createGradientTextTokens({
25
26
  },
26
27
  },
27
28
  size: {
28
- xs: {
29
- ...textStyle.xs,
30
- },
31
- sm: {
32
- ...textStyle.sm,
33
- },
34
- md: {
35
- ...textStyle.md,
36
- },
37
- lg: {
38
- ...textStyle.lg,
39
- },
40
- xl: {
41
- ...textStyle.xl,
42
- },
43
- '2xl': {
44
- ...textStyle['2xl'],
45
- },
46
- '3xl': {
47
- ...textStyle['3xl'],
48
- },
49
- '4xl': {
50
- ...textStyle['4xl'],
51
- },
52
- '5xl': {
53
- ...textStyle['5xl'],
54
- },
55
- '6xl': {
56
- ...textStyle['6xl'],
57
- },
58
- '7xl': {
59
- ...textStyle['7xl'],
60
- },
29
+ // xs: {
30
+ // ...textStyle.xs,
31
+ // },
32
+ // sm: {
33
+ // ...textStyle.sm,
34
+ // },
35
+ // md: {
36
+ // ...textStyle.md,
37
+ // },
38
+ // lg: {
39
+ // ...textStyle.lg,
40
+ // },
41
+ // xl: {
42
+ // ...textStyle.xl,
43
+ // },
44
+ // '2xl': {
45
+ // ...textStyle['2xl'],
46
+ // },
47
+ // '3xl': {
48
+ // ...textStyle['3xl'],
49
+ // },
50
+ // '4xl': {
51
+ // ...textStyle['4xl'],
52
+ // },
53
+ // '5xl': {
54
+ // ...textStyle['5xl'],
55
+ // },
56
+ // '6xl': {
57
+ // ...textStyle['6xl'],
58
+ // },
59
+ // '7xl': {
60
+ // ...textStyle['7xl'],
61
+ // },
61
62
  },
62
63
  },
63
64
  } as const)
65
+
66
+ const GradientTextStyles = StyleSheet.create(theme => ({
67
+ text: (colorPalette: PalettesWithNestedKeys) => ({
68
+ color: theme.colors.fg.default,
69
+ variants: {
70
+ variant: {
71
+ heading: {
72
+ color: theme.colors.fg.default,
73
+ fontWeight: theme.fontWeights.bold,
74
+ },
75
+ default: {
76
+ color: theme.colors.fg.default,
77
+ fontWeight: theme.fontWeights.medium,
78
+ },
79
+ },
80
+ size: {
81
+ xs: {
82
+ fontSize: theme.fontSizes.xs,
83
+ lineHeight: 12,
84
+ },
85
+ sm: {
86
+ fontSize: theme.fontSizes.sm,
87
+ lineHeight: 20,
88
+ },
89
+ md: {
90
+ fontSize: theme.fontSizes.md,
91
+ lineHeight: 24,
92
+ },
93
+ lg: {
94
+ fontSize: theme.fontSizes.lg,
95
+ lineHeight: 28,
96
+ },
97
+ xl: {
98
+ fontSize: theme.fontSizes.xl,
99
+ lineHeight: 30,
100
+ },
101
+ '2xl': {
102
+ fontSize: theme.fontSizes['2xl'],
103
+ lineHeight: 32,
104
+ },
105
+ '3xl': {
106
+ fontSize: theme.fontSizes['3xl'],
107
+ lineHeight: 38,
108
+ },
109
+ '4xl': {
110
+ fontSize: theme.fontSizes['4xl'],
111
+ lineHeight: 44,
112
+ letterSpacing: -0.032,
113
+ },
114
+ '5xl': {
115
+ fontSize: theme.fontSizes['5xl'],
116
+ lineHeight: 60,
117
+ letterSpacing: -0.032,
118
+ },
119
+ '6xl': {
120
+ fontSize: theme.fontSizes['6xl'],
121
+ lineHeight: 72,
122
+ letterSpacing: -0.032,
123
+ },
124
+ '7xl': {
125
+ fontSize: theme.fontSizes['7xl'],
126
+ lineHeight: 92,
127
+ letterSpacing: -0.032,
128
+ },
129
+ },
130
+ },
131
+ }),
132
+ }))
@@ -11,7 +11,9 @@ export const InputStyles = StyleSheet.create(theme => ({
11
11
  placeholder: (colorPalette: PalettesWithNestedKeys) => ({
12
12
  variants: {
13
13
  variant: {
14
- solid: {},
14
+ solid: {
15
+ color: theme.colors.fg.subtle,
16
+ },
15
17
  },
16
18
  invalid: {
17
19
  true: {
@@ -38,6 +40,11 @@ export const InputStyles = StyleSheet.create(theme => ({
38
40
  variants: {
39
41
  variant: {
40
42
  solid: {},
43
+ underline: {
44
+ borderWidth: 0,
45
+ borderBottomWidth: 1,
46
+ borderRadius: 0,
47
+ },
41
48
  },
42
49
  focused: {
43
50
  true: {
@@ -75,14 +82,14 @@ export const InputStyles = StyleSheet.create(theme => ({
75
82
  fontSize: theme.fontSizes.sm,
76
83
  },
77
84
  md: {
78
- paddingHorizontal: theme.sizes[3],
85
+ paddingHorizontal: theme.sizes['2.5'],
79
86
  minHeight: theme.sizes[10],
80
87
  maxHeight: theme.sizes[20],
81
88
  minWidth: theme.sizes[10],
82
89
  fontSize: theme.fontSizes.md,
83
90
  },
84
91
  lg: {
85
- paddingHorizontal: theme.sizes['3.5'],
92
+ paddingHorizontal: theme.sizes[3],
86
93
  minHeight: theme.sizes[11],
87
94
  maxHeight: theme.sizes[11],
88
95
  minWidth: theme.sizes[11],
@@ -90,18 +97,19 @@ export const InputStyles = StyleSheet.create(theme => ({
90
97
  lineHeight: 18,
91
98
  },
92
99
  xl: {
93
- paddingHorizontal: theme.sizes[4],
100
+ paddingHorizontal: theme.sizes['3.5'],
94
101
  minHeight: theme.sizes[12],
95
102
  maxHeight: theme.sizes[12],
96
103
  minWidth: theme.sizes[12],
97
104
  fontSize: theme.fontSizes.lg,
98
105
  },
99
106
  '2xl': {
100
- paddingHorizontal: theme.sizes['4.5'],
107
+ paddingHorizontal: theme.sizes[4],
101
108
  minHeight: theme.sizes[16],
102
109
  maxHeight: theme.sizes[16],
103
110
  minWidth: theme.sizes[16],
104
- ...textStyle['3xl'],
111
+ // ...textStyle['3xl'],
112
+ fontSize: theme.fontSizes['3xl'],
105
113
  },
106
114
  flex: {
107
115
  paddingHorizontal: theme.sizes[2],
@@ -24,12 +24,15 @@ export const SelectStyles = StyleSheet.create((theme, rt) => ({
24
24
  size: {
25
25
  sm: {
26
26
  height: theme.sizes[9],
27
+ padding: theme.spacing[1],
27
28
  },
28
29
  md: {
29
30
  height: theme.sizes[10],
31
+ padding: theme.spacing[2],
30
32
  },
31
33
  lg: {
32
34
  height: theme.sizes[11],
35
+ padding: theme.spacing[3],
33
36
  },
34
37
  nosize: {},
35
38
  },
@@ -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
  }))