react-native-varia 0.2.3 → 0.3.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/bin/cli.js +24 -34
  2. package/lib/components/Accordion.tsx +113 -0
  3. package/lib/components/Button.tsx +16 -3
  4. package/lib/components/Checkbox.tsx +12 -7
  5. package/lib/components/CircleProgress.tsx +30 -21
  6. package/lib/components/Divider.tsx +23 -19
  7. package/lib/components/Drawer.tsx +23 -69
  8. package/lib/components/Field.tsx +24 -39
  9. package/lib/components/GradientBackground.tsx +25 -7
  10. package/lib/components/GradientText.tsx +61 -21
  11. package/lib/components/IconWrapper.tsx +20 -14
  12. package/lib/components/Input.tsx +107 -25
  13. package/lib/components/Modal.tsx +4 -10
  14. package/lib/components/NumberInput.tsx +54 -11
  15. package/lib/components/OldSlider.tsx +327 -0
  16. package/lib/components/RadioGroup.tsx +58 -18
  17. package/lib/components/ReText.tsx +1 -1
  18. package/lib/components/Select.tsx +58 -22
  19. package/lib/components/Slider.tsx +273 -138
  20. package/lib/components/Slideshow.tsx +65 -63
  21. package/lib/components/SlidingDrawer.tsx +20 -21
  22. package/lib/components/Spinner.tsx +13 -5
  23. package/lib/components/Toast.tsx +89 -0
  24. package/lib/components/context/Field.tsx +27 -0
  25. package/lib/patterns/index.tsx +16 -5
  26. package/lib/patterns/newPatterns.tsx +285 -0
  27. package/lib/theme/Button.recipe.tsx +11 -1
  28. package/lib/theme/CircleProgress.recipe.tsx +3 -3
  29. package/lib/theme/Drawer.recipe.tsx +107 -0
  30. package/lib/theme/Field.recipe.tsx +17 -2
  31. package/lib/theme/Input.recipe.tsx +12 -3
  32. package/lib/theme/NumberInput.recipe.tsx +8 -3
  33. package/lib/theme/RadioGroup.recipe.tsx +7 -1
  34. package/lib/theme/Select.recipe.tsx +7 -7
  35. package/lib/theme/Slider.recipe.tsx +402 -27
  36. package/lib/theme/Slideshow.recipe.tsx +1 -1
  37. package/lib/theme/Toast.recipe.tsx +71 -0
  38. package/lib/varia/mixins.ts +0 -4
  39. package/lib/varia/types.ts +8 -0
  40. package/lib/varia/utils.ts +66 -0
  41. package/package.json +1 -1
  42. package/lib/theme/Button.recipe-old.tsx +0 -67
  43. package/lib/theme/SlidingDrawer.recipe.tsx +0 -53
@@ -1,5 +1,4 @@
1
1
  import {StyleSheet} from 'react-native-unistyles'
2
- import {hexToRgba} from '../style/varia/utils'
3
2
  import {PalettesWithNestedKeys} from '../style/varia/types'
4
3
 
5
4
  export const SliderDefaultVariants = {
@@ -9,124 +8,496 @@ export const SliderDefaultVariants = {
9
8
  export const SliderStyles = StyleSheet.create(theme => ({
10
9
  container: (colorPalette: PalettesWithNestedKeys) => ({
11
10
  backgroundColor: theme.colors.bg.emphasized,
12
- borderRadius: theme.radii.full,
11
+ borderRadius: theme.radii['2xl'],
13
12
  variants: {
13
+ axis: {
14
+ x: {},
15
+ y: {},
16
+ },
14
17
  variant: {
15
18
  solid: {},
16
19
  },
17
20
  size: {
18
21
  xs: {
19
- height: theme.sizes[2],
22
+ // height: theme.sizes[2],
20
23
  },
21
24
  sm: {
22
- height: theme.sizes[4],
25
+ // height: theme.sizes[4],
23
26
  },
24
27
  md: {
25
- height: theme.sizes[5],
28
+ // height: theme.sizes[5],
26
29
  },
27
30
  lg: {
28
- height: theme.sizes[8],
31
+ // height: theme.sizes[8],
29
32
  },
30
33
  xl: {
31
- height: theme.sizes[10],
34
+ // height: theme.sizes[10],
32
35
  },
36
+ flex: {},
33
37
  },
34
38
  },
39
+ compoundVariants: [
40
+ {
41
+ axis: 'x',
42
+ size: 'xs',
43
+ styles: {
44
+ height: theme.sizes[2],
45
+ },
46
+ },
47
+ {
48
+ axis: 'x',
49
+ size: 'sm',
50
+ styles: {
51
+ height: theme.sizes[4],
52
+ },
53
+ },
54
+ {
55
+ axis: 'x',
56
+ size: 'md',
57
+ styles: {
58
+ height: theme.sizes[5],
59
+ },
60
+ },
61
+ {
62
+ axis: 'x',
63
+ size: 'lg',
64
+ styles: {
65
+ height: theme.sizes[8],
66
+ },
67
+ },
68
+ {
69
+ axis: 'x',
70
+ size: 'xl',
71
+ styles: {
72
+ height: theme.sizes[10],
73
+ },
74
+ },
75
+ {
76
+ axis: 'x',
77
+ size: 'flex',
78
+ styles: {
79
+ minHeight: 50,
80
+ },
81
+ },
82
+ {
83
+ axis: 'y',
84
+ size: 'xs',
85
+ styles: {
86
+ width: theme.sizes[2],
87
+ },
88
+ },
89
+ {
90
+ axis: 'y',
91
+ size: 'sm',
92
+ styles: {
93
+ width: theme.sizes[4],
94
+ },
95
+ },
96
+ {
97
+ axis: 'y',
98
+ size: 'md',
99
+ styles: {
100
+ width: theme.sizes[5],
101
+ },
102
+ },
103
+ {
104
+ axis: 'y',
105
+ size: 'lg',
106
+ styles: {
107
+ width: theme.sizes[8],
108
+ },
109
+ },
110
+ {
111
+ axis: 'y',
112
+ size: 'xl',
113
+ styles: {
114
+ width: theme.sizes[10],
115
+ },
116
+ },
117
+ {
118
+ axis: 'y',
119
+ size: 'flex',
120
+ styles: {
121
+ minWidth: 50,
122
+ },
123
+ },
124
+ ],
35
125
  }),
36
126
  maximumTrack: (colorPalette: PalettesWithNestedKeys) => ({
37
127
  backgroundColor: theme.colors.bg.emphasized,
38
- borderRadius: theme.radii.full,
128
+ // borderRadius: theme.radii.full,
129
+ // height: theme.sizes[5],
39
130
  variants: {
131
+ axis: {
132
+ x: {},
133
+ y: {},
134
+ },
40
135
  variant: {
41
136
  solid: {},
42
137
  },
43
138
  size: {
44
139
  xs: {
45
- height: theme.sizes[2],
140
+ // height: theme.sizes[2],
46
141
  },
47
142
  sm: {
48
- height: theme.sizes[4],
143
+ // height: theme.sizes[4],
49
144
  },
50
145
  md: {
51
- height: theme.sizes[5],
146
+ // height: theme.sizes[5],
52
147
  },
53
148
  lg: {
54
- height: theme.sizes[8],
149
+ // height: theme.sizes[8],
55
150
  },
56
151
  xl: {
57
- height: theme.sizes[10],
152
+ // height: theme.sizes[10],
58
153
  },
154
+ flex: {},
59
155
  },
60
156
  },
157
+ compoundVariants: [
158
+ {
159
+ axis: 'x',
160
+ size: 'xs',
161
+ styles: {
162
+ height: theme.sizes[2],
163
+ },
164
+ },
165
+ {
166
+ axis: 'x',
167
+ size: 'sm',
168
+ styles: {
169
+ height: theme.sizes[4],
170
+ },
171
+ },
172
+ {
173
+ axis: 'x',
174
+ size: 'md',
175
+ styles: {
176
+ height: theme.sizes[5],
177
+ },
178
+ },
179
+ {
180
+ axis: 'x',
181
+ size: 'lg',
182
+ styles: {
183
+ height: theme.sizes[8],
184
+ },
185
+ },
186
+ {
187
+ axis: 'x',
188
+ size: 'xl',
189
+ styles: {
190
+ height: theme.sizes[10],
191
+ },
192
+ },
193
+ {
194
+ axis: 'x',
195
+ size: 'flex',
196
+ styles: {},
197
+ },
198
+ {
199
+ axis: 'y',
200
+ size: 'xs',
201
+ styles: {
202
+ width: theme.sizes[2],
203
+ },
204
+ },
205
+ {
206
+ axis: 'y',
207
+ size: 'sm',
208
+ styles: {
209
+ width: theme.sizes[4],
210
+ },
211
+ },
212
+ {
213
+ axis: 'y',
214
+ size: 'md',
215
+ styles: {
216
+ width: theme.sizes[5],
217
+ },
218
+ },
219
+ {
220
+ axis: 'y',
221
+ size: 'lg',
222
+ styles: {
223
+ width: theme.sizes[8],
224
+ },
225
+ },
226
+ {
227
+ axis: 'y',
228
+ size: 'xl',
229
+ styles: {
230
+ width: theme.sizes[10],
231
+ },
232
+ },
233
+ ],
61
234
  }),
62
235
  minimumTrack: (
63
236
  colorPalette: PalettesWithNestedKeys,
64
237
  opacityTrack: boolean,
65
238
  ) => ({
66
- backgroundColor: opacityTrack
67
- ? hexToRgba(theme.colors[colorPalette].default, 0.5)
68
- : theme.colors[colorPalette].default,
239
+ 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],
69
244
  variants: {
245
+ axis: {
246
+ x: {},
247
+ y: {},
248
+ },
70
249
  variant: {
71
250
  solid: {},
72
251
  },
73
252
  size: {
74
253
  xs: {
75
- height: theme.sizes[2],
254
+ // height: theme.sizes[2],
76
255
  },
77
256
  sm: {
78
- height: theme.sizes[4],
257
+ // height: theme.sizes[4],
79
258
  },
80
259
  md: {
81
- height: theme.sizes[5],
260
+ // height: theme.sizes[5],
82
261
  },
83
262
  lg: {
84
- height: theme.sizes[8],
263
+ // height: theme.sizes[8],
85
264
  },
86
265
  xl: {
87
- height: theme.sizes[10],
266
+ // height: theme.sizes[10],
88
267
  },
268
+ flex: {},
89
269
  },
90
270
  },
271
+ compoundVariants: [
272
+ {
273
+ axis: 'x',
274
+ size: 'xs',
275
+ styles: {
276
+ height: theme.sizes[2],
277
+ },
278
+ },
279
+ {
280
+ axis: 'x',
281
+ size: 'sm',
282
+ styles: {
283
+ height: theme.sizes[4],
284
+ },
285
+ },
286
+ {
287
+ axis: 'x',
288
+ size: 'md',
289
+ styles: {
290
+ height: theme.sizes[5],
291
+ },
292
+ },
293
+ {
294
+ axis: 'x',
295
+ size: 'lg',
296
+ styles: {
297
+ height: theme.sizes[8],
298
+ },
299
+ },
300
+ {
301
+ axis: 'x',
302
+ size: 'xl',
303
+ styles: {
304
+ height: theme.sizes[10],
305
+ },
306
+ },
307
+ {
308
+ axis: 'x',
309
+ size: 'flex',
310
+ styles: {},
311
+ },
312
+ {
313
+ axis: 'y',
314
+ size: 'xs',
315
+ styles: {
316
+ width: theme.sizes[2],
317
+ },
318
+ },
319
+ {
320
+ axis: 'y',
321
+ size: 'sm',
322
+ styles: {
323
+ width: theme.sizes[4],
324
+ },
325
+ },
326
+ {
327
+ axis: 'y',
328
+ size: 'md',
329
+ styles: {
330
+ width: theme.sizes[5],
331
+ },
332
+ },
333
+ {
334
+ axis: 'y',
335
+ size: 'lg',
336
+ styles: {
337
+ width: theme.sizes[8],
338
+ },
339
+ },
340
+ {
341
+ axis: 'y',
342
+ size: 'xl',
343
+ styles: {
344
+ width: theme.sizes[10],
345
+ },
346
+ },
347
+ ],
91
348
  }),
92
349
  thumb: (colorPalette: PalettesWithNestedKeys) => ({
93
350
  backgroundColor: theme.colors.bg.default,
94
351
  borderColor: theme.colors[colorPalette].default,
95
352
  borderRadius: theme.radii.full,
96
353
  borderWidth: 2,
354
+ // width: theme.sizes[7],
355
+ // height: theme.sizes[7],
97
356
  variants: {
357
+ axis: {
358
+ x: {},
359
+ y: {},
360
+ },
98
361
  variant: {
99
362
  solid: {},
100
363
  },
101
364
  size: {
102
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],
380
+ },
381
+ xl: {
382
+ // width: theme.sizes[11],
383
+ // height: theme.sizes[11],
384
+ },
385
+ flex: {
386
+ // width: 30,
387
+ // height: 50,
388
+ },
389
+ },
390
+ },
391
+ compoundVariants: [
392
+ {
393
+ axis: 'x',
394
+ size: 'xs',
395
+ styles: {
103
396
  width: theme.sizes[4],
104
397
  height: theme.sizes[4],
105
398
  },
106
- sm: {
399
+ },
400
+ {
401
+ axis: 'x',
402
+ size: 'sm',
403
+ styles: {
107
404
  width: theme.sizes[6],
108
405
  height: theme.sizes[6],
109
406
  },
110
- md: {
407
+ },
408
+ {
409
+ axis: 'x',
410
+ size: 'md',
411
+ styles: {
111
412
  width: theme.sizes[7],
112
413
  height: theme.sizes[7],
113
414
  },
114
- lg: {
415
+ },
416
+ {
417
+ axis: 'x',
418
+ size: 'lg',
419
+ styles: {
115
420
  width: theme.sizes[8],
116
421
  height: theme.sizes[8],
117
422
  },
118
- xl: {
423
+ },
424
+ {
425
+ axis: 'x',
426
+ size: 'xl',
427
+ styles: {
119
428
  width: theme.sizes[11],
120
429
  height: theme.sizes[11],
121
430
  },
122
431
  },
123
- },
432
+ {
433
+ axis: 'x',
434
+ size: 'flex',
435
+ styles: {
436
+ width: 30,
437
+ // height: 50,
438
+ // alignSel: 'stretch',
439
+ // flex: 1,
440
+ },
441
+ },
442
+ {
443
+ axis: 'y',
444
+ size: 'xs',
445
+ styles: {
446
+ width: theme.sizes[4],
447
+ height: theme.sizes[4],
448
+ },
449
+ },
450
+ {
451
+ axis: 'y',
452
+ size: 'sm',
453
+ styles: {
454
+ width: theme.sizes[6],
455
+ height: theme.sizes[6],
456
+ },
457
+ },
458
+ {
459
+ axis: 'y',
460
+ size: 'md',
461
+ styles: {
462
+ width: theme.sizes[7],
463
+ height: theme.sizes[7],
464
+ },
465
+ },
466
+ {
467
+ axis: 'y',
468
+ size: 'lg',
469
+ styles: {
470
+ width: theme.sizes[8],
471
+ height: theme.sizes[8],
472
+ },
473
+ },
474
+ {
475
+ axis: 'y',
476
+ size: 'xl',
477
+ styles: {
478
+ width: theme.sizes[11],
479
+ height: theme.sizes[11],
480
+ },
481
+ },
482
+ {
483
+ axis: 'y',
484
+ size: 'flex',
485
+ styles: {
486
+ alignSelf: 'stretch',
487
+ height: 30,
488
+ },
489
+ },
490
+ ],
124
491
  }),
125
492
  step: (colorPalette: PalettesWithNestedKeys) => ({
126
493
  // TODO: type correctly theme.colors
127
494
  // @ts-ignore
128
- backgroundColor: theme.colors.white['0'],
495
+ backgroundColor: theme.colors.bg.default,
129
496
  variants: {
497
+ axis: {
498
+ x: {},
499
+ y: {},
500
+ },
130
501
  variant: {
131
502
  solid: {},
132
503
  },
@@ -136,6 +507,10 @@ export const SliderStyles = StyleSheet.create(theme => ({
136
507
  md: {},
137
508
  lg: {},
138
509
  xl: {},
510
+ flex: {
511
+ width: 5,
512
+ height: 5,
513
+ },
139
514
  },
140
515
  },
141
516
  }),
@@ -56,7 +56,7 @@ export const SlideshowStyles = StyleSheet.create(theme => ({
56
56
  borderColor: theme.colors.border.default,
57
57
  borderWidth: 1,
58
58
  borderRadius: theme.radii['3xl'],
59
- margin: theme.spacing[2],
59
+ padding: theme.spacing[2],
60
60
  },
61
61
  },
62
62
  },
@@ -0,0 +1,71 @@
1
+ import {StyleSheet} from 'react-native-unistyles'
2
+ import {PalettesWithNestedKeys} from '../style/varia/types'
3
+ import {textStyle} from '../style/varia/textStyles'
4
+
5
+ export const ToastDefaultVariants = {
6
+ variant: 'solid',
7
+ size: 'md',
8
+ } as const
9
+
10
+ export const ToastStyles = StyleSheet.create(theme => ({
11
+ container: (colorPalette: PalettesWithNestedKeys) => ({
12
+ variants: {
13
+ variant: {
14
+ solid: {
15
+ backgroundColor: theme.colors[colorPalette].default,
16
+ boxShadow: theme.shadows.md,
17
+ },
18
+ subtle: {
19
+ backgroundColor: theme.colors.bg.subtle,
20
+ boxShadow: theme.shadows.sm,
21
+ },
22
+ outline: {
23
+ borderWidth: 2,
24
+ borderColor: theme.colors.border.default,
25
+ },
26
+ error: {
27
+ borderColor: theme.colors.red[9],
28
+ borderWidth: 1,
29
+ backgroundColor: theme.colors.red[7],
30
+ },
31
+ },
32
+ size: {
33
+ sm: {
34
+ bottom: theme.spacing[5],
35
+ },
36
+ md: {
37
+ bottom: theme.spacing[5],
38
+ },
39
+ lg: {
40
+ bottom: theme.spacing[8],
41
+ },
42
+ },
43
+ },
44
+ }),
45
+ text: (colorPalette: PalettesWithNestedKeys) => ({
46
+ variants: {
47
+ variant: {
48
+ solid: {
49
+ color: theme.colors[colorPalette].fg,
50
+ },
51
+ subtle: {
52
+ color: theme.colors.fg.default,
53
+ },
54
+ outline: {
55
+ color: theme.colors.fg.default,
56
+ },
57
+ },
58
+ size: {
59
+ sm: {
60
+ ...textStyle.xs,
61
+ },
62
+ md: {
63
+ ...textStyle.xs,
64
+ },
65
+ lg: {
66
+ ...textStyle.sm,
67
+ },
68
+ },
69
+ },
70
+ }),
71
+ }))
@@ -18,9 +18,6 @@ const mixins = StyleSheet.create((theme, rt) => ({
18
18
  alignItems: 'center',
19
19
  justifyContent: 'center',
20
20
  },
21
- sx: (sx: any) => ({
22
- ...sx,
23
- }),
24
21
  w: (width: number) => ({
25
22
  width,
26
23
  }),
@@ -181,7 +178,6 @@ export const {
181
178
  row,
182
179
  gap,
183
180
  center,
184
- sx,
185
181
  flexColumn,
186
182
  w,
187
183
  h,
@@ -1,3 +1,4 @@
1
+ import {ViewStyle} from 'react-native'
1
2
  import {darkTheme, lightTheme} from '../themes'
2
3
 
3
4
  export interface AlphaPalette {
@@ -275,3 +276,10 @@ export function createCircleProgressTokens<
275
276
  }) {
276
277
  return tokens
277
278
  }
279
+
280
+ export type AlignSelf = ViewStyle['alignSelf']
281
+ export type StackDirection = 'row' | 'column'
282
+ export type progressDirection = 'forward' | 'reverse'
283
+ export type rotationDirection = 'clockwise' | 'counterclockwise'
284
+ export type Flex = ViewStyle['flex']
285
+ export type MaxWidth = ViewStyle['maxWidth']