react-native-varia 0.6.0 → 0.6.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.
@@ -294,33 +294,30 @@ const DrawerSliderInternal = ({
294
294
 
295
295
  const initialized = useSharedValue(false)
296
296
 
297
- const onLayout = () => {
298
- if (initialized.value) return
299
- const _screenHeight = screenHeight
300
- const _screenWidth = screenWidth
301
- const _axis = axis
302
- const _direction = direction
303
- const _snapPoints = snapPoints
297
+ const contentSize = useSharedValue(0) // altura o ancho del contenido
304
298
 
299
+ const onLayout = () => {
305
300
  scheduleOnUI(() => {
306
301
  'worklet'
307
302
  const measured = measure(viewRef)
308
- if (measured) {
309
- const {height, width} = measured
310
- const size = _axis === 'y' ? height : width
311
- const screenSize = _axis === 'y' ? _screenHeight : _screenWidth
312
-
313
- const resolved = _snapPoints.map(p => {
314
- if (p === 'hidden') return screenSize * _direction
315
- if (p === 'content') return (screenSize - size) * _direction
316
- return (p as number) * _direction
317
- })
303
+ if (!measured) return
304
+
305
+ contentSize.value = axis === 'y' ? measured.height : measured.width
318
306
 
319
- resolvedSnapPoints.value = resolved
320
- translate.value = resolved[0]
321
- context.value = {position: resolved[0], snapPoint: 0}
322
- initialized.value = true
307
+ // recalcular snapPoints
308
+ const screenSize = axis === 'y' ? screenHeight : screenWidth
309
+ resolvedSnapPoints.value = snapPoints.map(p => {
310
+ if (p === 'hidden') return screenSize * direction
311
+ if (p === 'content') return (screenSize - contentSize.value) * direction
312
+ return (p as number) * direction
313
+ })
314
+
315
+ // ajustar translate si estaba en hidden
316
+ if (context.value.snapPoint === 0) {
317
+ translate.value = resolvedSnapPoints.value[0]
318
+ context.value.position = resolvedSnapPoints.value[0]
323
319
  }
320
+ if (context.value.snapPoint !== 0) scheduleOnRN(expand)
324
321
  })
325
322
  }
326
323
 
@@ -556,7 +553,6 @@ const styles = StyleSheet.create((theme, rt) => ({
556
553
  },
557
554
  slider: (zIndex: ZIndex) => ({
558
555
  flex: 1,
559
- alignSelf: 'stretch',
560
556
  alignItems: 'center',
561
557
  justifyContent: 'flex-start',
562
558
  zIndex,
@@ -112,8 +112,6 @@ const Slider = ({
112
112
  'backgroundColor',
113
113
  ) || 'transparent'
114
114
 
115
- console.log(SliderStyles.maximumTrack(colorPalette))
116
-
117
115
  const halfSize = ((axis === 'x' ? thumbWidth : thumbHeight) ?? 0) / 2
118
116
 
119
117
  const context = useSharedValue({x: 0})
@@ -236,8 +234,6 @@ const Slider = ({
236
234
  }
237
235
  })
238
236
 
239
- console.log('maximum color', maximumTrackColor)
240
-
241
237
  return (
242
238
  <View
243
239
  testID="varia-slider-container"
@@ -6,6 +6,30 @@ export const AccordionDefaultVariants = {
6
6
  size: 'md',
7
7
  } as const
8
8
  export const AccordionStyles = StyleSheet.create(theme => ({
9
+ groupContainer: (colorPalette: PalettesWithNestedKeys) => ({
10
+ variants: {
11
+ variant: {
12
+ solid: {},
13
+ outline: {},
14
+ subtle: {},
15
+ },
16
+ size: {
17
+ sm: {
18
+ padding: theme.spacing[2],
19
+ },
20
+ md: {
21
+ padding: theme.spacing[2],
22
+ },
23
+ lg: {
24
+ padding: theme.spacing[2],
25
+ },
26
+ xl: {
27
+ padding: theme.spacing[3],
28
+ },
29
+ nosize: {},
30
+ },
31
+ },
32
+ }),
9
33
  itemContainer: (colorPalette: PalettesWithNestedKeys) => ({
10
34
  borderRadius: 12,
11
35
  variants: {
@@ -181,4 +205,28 @@ export const AccordionStyles = StyleSheet.create(theme => ({
181
205
  },
182
206
  ],
183
207
  }),
208
+ innerContent: (colorPalette: PalettesWithNestedKeys) => ({
209
+ variants: {
210
+ variant: {
211
+ solid: {},
212
+ outline: {},
213
+ subtle: {},
214
+ },
215
+ size: {
216
+ sm: {
217
+ padding: theme.spacing[2],
218
+ },
219
+ md: {
220
+ padding: theme.spacing[2],
221
+ },
222
+ lg: {
223
+ padding: theme.spacing[2],
224
+ },
225
+ xl: {
226
+ padding: theme.spacing[3],
227
+ },
228
+ nosize: {},
229
+ },
230
+ },
231
+ }),
184
232
  }))
@@ -49,6 +49,7 @@ export const DrawerStyles = StyleSheet.create((theme, rt) => ({
49
49
  },
50
50
  },
51
51
  slider: (colorPalette: PalettesWithNestedKeys) => ({
52
+ alignSelf: 'stretch',
52
53
  boxShadow: theme.shadows.sm,
53
54
  borderRadius: theme.radii.lg,
54
55
  backgroundColor: theme.colors.bg.default,
@@ -1,411 +1,155 @@
1
1
  import {StyleSheet} from 'react-native-unistyles'
2
2
  import {PalettesWithNestedKeys} from '../style/varia/types'
3
+ import {generateCompoundVariants} from '../style/varia/utils'
3
4
 
4
5
  export const SliderDefaultVariants = {
5
6
  size: 'md',
6
7
  variant: 'solid',
7
8
  } as const
8
- export const SliderStyles = StyleSheet.create(theme => ({
9
- container: (colorPalette: PalettesWithNestedKeys) => ({
10
- backgroundColor: theme.colors.bg.emphasized,
11
- borderRadius: theme.radii.xl,
12
- variants: {
13
- axis: {
14
- x: {},
15
- y: {},
16
- },
17
- variant: {
18
- solid: {},
19
- outline: {
20
- borderRadius: theme.radii.sm,
21
- borderColor: theme.colors[colorPalette].default,
22
- borderWidth: 1,
23
- },
24
- subtle: {
25
- backgroundColor: theme.colors.bg.subtle,
26
- },
27
- },
28
- size: {
29
- sm: {
30
- borderRadius: theme.radii.lg,
31
- },
32
- md: {
33
- borderRadius: theme.radii.xl,
34
- },
35
- lg: {
36
- borderRadius: theme.radii['2xl'],
37
- },
38
- flex: {},
39
- minimal: {},
40
- },
9
+
10
+ export const SliderStyles = StyleSheet.create(theme => {
11
+ const containerSizes = {
12
+ sm: {x: {height: theme.sizes[4]}, y: {width: theme.sizes[4]}},
13
+ md: {x: {height: theme.sizes[5]}, y: {width: theme.sizes[5]}},
14
+ lg: {x: {height: theme.sizes[8]}, y: {width: theme.sizes[8]}},
15
+ flex: {x: {minHeight: 50}, y: {minWidth: 50}},
16
+ minimal: {x: {}, y: {}},
17
+ }
18
+
19
+ const maximumTrackSizes = {
20
+ sm: {x: {height: theme.sizes[4]}, y: {width: theme.sizes[4]}},
21
+ md: {x: {height: theme.sizes[2]}, y: {width: theme.sizes[2]}},
22
+ lg: {x: {height: theme.sizes[4]}, y: {width: theme.sizes[4]}},
23
+ flex: {x: {}, y: {}},
24
+ minimal: {x: {}, y: {}},
25
+ }
26
+
27
+ const minimumTrackSizes = {
28
+ sm: {x: {height: theme.sizes[4]}, y: {width: theme.sizes[4]}},
29
+ // md: {x: {height: theme.sizes[5]}, y: {width: theme.sizes[5]}},
30
+ md: {x: {height: '100%'}, y: {width: '100%'}},
31
+ lg: {
32
+ x: {height: theme.sizes[8]},
33
+ y: {width: theme.sizes[8]},
41
34
  },
42
- compoundVariants: [
43
- {
44
- size: 'sm',
45
- variant: 'outline',
46
- styles: {
47
- borderRadius: theme.radii.sm,
48
- },
49
- },
50
- {
51
- size: 'md',
52
- variant: 'outline',
53
- styles: {
54
- borderRadius: theme.radii.sm,
55
- },
56
- },
57
- {
58
- size: 'lg',
59
- variant: 'outline',
60
- styles: {
61
- borderRadius: theme.radii.sm,
62
- },
63
- },
64
- {
65
- axis: 'x',
66
- size: 'sm',
67
- styles: {
68
- height: theme.sizes[4],
69
- },
70
- },
71
- {
72
- axis: 'x',
73
- size: 'md',
74
- styles: {
75
- height: theme.sizes[5],
76
- },
77
- },
78
- {
79
- axis: 'x',
80
- size: 'lg',
81
- styles: {
82
- height: theme.sizes[8],
83
- },
84
- },
85
- {
86
- axis: 'x',
87
- size: 'flex',
88
- styles: {
89
- minHeight: 50,
90
- },
91
- },
92
- {
93
- axis: 'y',
94
- size: 'sm',
95
- styles: {
96
- width: theme.sizes[4],
97
- },
98
- },
99
- {
100
- axis: 'y',
101
- size: 'md',
102
- styles: {
103
- width: theme.sizes[5],
104
- },
105
- },
106
- {
107
- axis: 'y',
108
- size: 'lg',
109
- styles: {
110
- width: theme.sizes[8],
111
- },
112
- },
113
- {
114
- axis: 'y',
115
- size: 'flex',
116
- styles: {
117
- minWidth: 50,
118
- },
119
- },
120
- ],
121
- }),
122
- maximumTrack: (colorPalette: PalettesWithNestedKeys) => ({
123
- backgroundColor: theme.colors.bg.emphasized,
124
- variants: {
125
- axis: {
126
- x: {},
127
- y: {},
128
- },
129
- variant: {
130
- solid: {},
131
- outline: {},
132
- subtle: {
133
- backgroundColor: theme.colors.bg.subtle,
134
- },
135
- },
136
- size: {
137
- sm: {},
138
- md: {},
139
- lg: {},
140
- flex: {},
141
- minimal: {},
142
- },
35
+ flex: {x: {flex: 1}, y: {flex: 1}},
36
+ minimal: {
37
+ x: {height: theme.sizes[8]},
38
+ y: {width: theme.sizes[8]},
143
39
  },
144
- compoundVariants: [
145
- {
146
- axis: 'x',
147
- size: 'sm',
148
- styles: {
149
- height: theme.sizes[4],
150
- },
151
- },
152
- {
153
- axis: 'x',
154
- size: 'md',
155
- styles: {
156
- height: theme.sizes[5],
157
- },
158
- },
159
- {
160
- axis: 'x',
161
- size: 'lg',
162
- styles: {
163
- height: theme.sizes[8],
164
- },
165
- },
166
- {
167
- axis: 'x',
168
- size: 'flex',
169
- styles: {},
170
- },
171
- {
172
- axis: 'y',
173
- size: 'sm',
174
- styles: {
175
- width: theme.sizes[4],
176
- },
177
- },
178
- {
179
- axis: 'y',
180
- size: 'md',
181
- styles: {
182
- width: theme.sizes[5],
183
- },
184
- },
185
- {
186
- axis: 'y',
187
- size: 'lg',
188
- styles: {
189
- width: theme.sizes[8],
190
- },
191
- },
192
- ],
193
- }),
194
- minimumTrack: (colorPalette: PalettesWithNestedKeys) => ({
195
- backgroundColor: theme.colors[colorPalette].default,
196
- variants: {
197
- axis: {
198
- x: {
199
- // borderBottomLeftRadius: theme.radii.xl,
200
- // borderBottomRightRadius: 0,
201
- // borderTopLeftRadius: theme.radii.xl,
202
- },
203
- y: {
204
- // borderBottomLeftRadius: theme.radii.xl,
205
- // borderBottomRightRadius: theme.radii.xl,
206
- // borderTopLeftRadius: 0,
207
- },
208
- },
209
- variant: {
210
- solid: {},
211
- outline: {},
212
- subtle: {},
213
- },
214
- size: {
215
- sm: {},
216
- md: {},
217
- lg: {},
218
- flex: {},
219
- minimal: {
220
- // borderRadius: theme.radii.sm,
221
- },
222
- },
40
+ }
41
+
42
+ const thumbSizes = {
43
+ sm: {
44
+ x: {width: theme.sizes[4], height: theme.sizes[4]},
45
+ y: {width: theme.sizes[6], height: theme.sizes[6]},
223
46
  },
224
- compoundVariants: [
225
- {
226
- axis: 'x',
227
- size: 'sm',
228
- styles: {
229
- height: theme.sizes[4],
230
- },
231
- },
232
- {
233
- axis: 'x',
234
- size: 'md',
235
- styles: {
236
- height: theme.sizes[5],
237
- },
238
- },
239
- {
240
- axis: 'x',
241
- size: 'lg',
242
- styles: {
243
- height: theme.sizes[8],
244
- },
245
- },
246
- {
247
- axis: 'x',
248
- size: 'flex',
249
- styles: {},
250
- },
251
- {
252
- axis: 'y',
253
- size: 'sm',
254
- styles: {
255
- width: theme.sizes[4],
256
- },
257
- },
258
- {
259
- axis: 'y',
260
- size: 'md',
261
- styles: {
262
- width: theme.sizes[5],
263
- },
264
- },
265
- {
266
- axis: 'y',
267
- size: 'lg',
268
- styles: {
269
- width: theme.sizes[8],
270
- },
271
- },
272
- {
273
- axis: 'y',
274
- size: 'flex',
275
- styles: {},
276
- },
277
- ],
278
- }),
279
- thumb: (colorPalette: PalettesWithNestedKeys) => ({
280
- variants: {
281
- axis: {
282
- x: {},
283
- y: {},
284
- },
285
- variant: {
286
- solid: {
287
- backgroundColor: theme.colors.bg.default,
288
- borderColor: theme.colors[colorPalette].default,
289
- borderRadius: theme.radii.full,
290
- borderWidth: 2,
291
- },
292
- subtle: {
293
- backgroundColor: theme.colors[colorPalette].default,
294
- },
295
- outline: {
296
- backgroundColor: theme.colors[colorPalette][11],
297
- },
298
- },
299
- size: {
300
- sm: {},
301
- md: {},
302
- lg: {},
303
- flex: {},
304
- minimal: {},
305
- },
47
+ md: {
48
+ x: {width: theme.sizes[5], height: theme.sizes[5]},
49
+ y: {width: theme.sizes[5], height: theme.sizes[5]},
306
50
  },
307
- compoundVariants: [
308
- {
309
- axis: 'x',
310
- size: 'sm',
311
- styles: {
312
- width: theme.sizes[4],
313
- height: theme.sizes[4],
314
- },
315
- },
316
- {
317
- axis: 'x',
318
- size: 'md',
319
- styles: {
320
- width: theme.sizes[5],
321
- height: theme.sizes[5],
322
- },
323
- },
324
- {
325
- axis: 'x',
326
- size: 'lg',
327
- styles: {
328
- width: theme.sizes[8],
329
- height: theme.sizes[8],
330
- },
331
- },
332
- {
333
- axis: 'x',
334
- size: 'flex',
335
- styles: {
336
- width: 30,
337
- },
338
- },
339
- {
340
- axis: 'x',
341
- size: 'minimal',
342
- styles: {
343
- width: 0,
344
- },
345
- },
346
- {
347
- axis: 'y',
348
- size: 'sm',
349
- styles: {
350
- width: theme.sizes[6],
351
- height: theme.sizes[6],
352
- },
353
- },
354
- {
355
- axis: 'y',
356
- size: 'md',
357
- styles: {
358
- width: theme.sizes[7],
359
- height: theme.sizes[7],
360
- },
361
- },
362
- {
363
- axis: 'y',
364
- size: 'lg',
365
- styles: {
366
- width: theme.sizes[8],
367
- height: theme.sizes[8],
368
- },
369
- },
370
- {
371
- axis: 'y',
372
- size: 'flex',
373
- styles: {
374
- alignSelf: 'stretch',
375
- height: 30,
376
- },
377
- },
378
- {
379
- axis: 'y',
380
- size: 'minimal',
381
- styles: {
382
- alignSelf: 'stretch',
383
- height: 5,
384
- },
385
- },
386
- ],
387
- }),
388
- step: (colorPalette: PalettesWithNestedKeys) => ({
389
- backgroundColor: theme.colors.bg.default,
390
- variants: {
391
- axis: {
392
- x: {},
393
- y: {},
394
- },
395
- variant: {
396
- solid: {
397
- backgroundColor: theme.colors.bg.default,
398
- },
399
- subtle: {},
400
- outline: {},
401
- },
402
- size: {
403
- sm: {},
404
- md: {},
405
- lg: {},
406
- flex: {},
407
- minimal: {},
408
- },
51
+ lg: {
52
+ x: {width: theme.sizes[8], height: theme.sizes[8]},
53
+ y: {width: theme.sizes[8], height: theme.sizes[8]},
409
54
  },
410
- }),
411
- }))
55
+ flex: {x: {width: 30, flex: 1}, y: {height: 30, alignSelf: 'stretch'}},
56
+ minimal: {x: {width: 0}, y: {height: 0}},
57
+ }
58
+
59
+ return {
60
+ container: (colorPalette: PalettesWithNestedKeys) => ({
61
+ borderRadius: theme.radii.xl,
62
+ variants: {
63
+ axis: {x: {}, y: {}},
64
+ variant: {
65
+ solid: {},
66
+ outline: {
67
+ borderRadius: theme.radii.sm,
68
+ borderColor: theme.colors[colorPalette].default,
69
+ borderWidth: 1,
70
+ },
71
+ subtle: {backgroundColor: theme.colors.bg.subtle},
72
+ },
73
+ size: {
74
+ sm: {borderRadius: theme.radii.lg},
75
+ md: {borderRadius: theme.radii.xl},
76
+ lg: {borderRadius: theme.radii['2xl']},
77
+ flex: {},
78
+ minimal: {},
79
+ },
80
+ },
81
+ compoundVariants: [
82
+ {
83
+ size: 'sm',
84
+ variant: 'outline',
85
+ styles: {borderRadius: theme.radii.sm},
86
+ },
87
+ {
88
+ size: 'md',
89
+ variant: 'outline',
90
+ styles: {borderRadius: theme.radii.sm},
91
+ },
92
+ {
93
+ size: 'lg',
94
+ variant: 'outline',
95
+ styles: {borderRadius: theme.radii.sm},
96
+ },
97
+ ...generateCompoundVariants(containerSizes),
98
+ ],
99
+ }),
100
+
101
+ maximumTrack: (colorPalette: PalettesWithNestedKeys) => ({
102
+ variants: {
103
+ axis: {x: {}, y: {}},
104
+ variant: {
105
+ solid: {backgroundColor: theme.colors.bg.emphasized},
106
+ outline: {},
107
+ subtle: {backgroundColor: theme.colors.bg.subtle},
108
+ },
109
+ size: {sm: {}, md: {}, lg: {}, flex: {}, minimal: {}},
110
+ },
111
+ compoundVariants: generateCompoundVariants(maximumTrackSizes),
112
+ }),
113
+
114
+ minimumTrack: (colorPalette: PalettesWithNestedKeys) => ({
115
+ backgroundColor: theme.colors[colorPalette].default,
116
+ variants: {
117
+ axis: {x: {}, y: {}},
118
+ variant: {solid: {}, outline: {}, subtle: {}},
119
+ size: {sm: {}, md: {}, lg: {}, flex: {}, minimal: {}},
120
+ },
121
+ compoundVariants: generateCompoundVariants(minimumTrackSizes),
122
+ }),
123
+
124
+ thumb: (colorPalette: PalettesWithNestedKeys) => ({
125
+ variants: {
126
+ axis: {x: {}, y: {}},
127
+ variant: {
128
+ solid: {
129
+ backgroundColor: theme.colors.bg.default,
130
+ borderColor: theme.colors[colorPalette].default,
131
+ borderRadius: theme.radii.full,
132
+ borderWidth: 2,
133
+ },
134
+ subtle: {backgroundColor: theme.colors[colorPalette].default},
135
+ outline: {backgroundColor: theme.colors[colorPalette][11]},
136
+ },
137
+ size: {sm: {}, md: {}, lg: {}, flex: {}, minimal: {}},
138
+ },
139
+ compoundVariants: generateCompoundVariants(thumbSizes),
140
+ }),
141
+
142
+ step: (colorPalette: PalettesWithNestedKeys) => ({
143
+ backgroundColor: theme.colors.bg.default,
144
+ variants: {
145
+ axis: {x: {}, y: {}},
146
+ variant: {
147
+ solid: {backgroundColor: theme.colors.bg.default},
148
+ subtle: {},
149
+ outline: {},
150
+ },
151
+ size: {sm: {}, md: {}, lg: {}, flex: {}, minimal: {}},
152
+ },
153
+ }),
154
+ }
155
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-varia",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "bin": {
5
5
  "varia": "bin/cli.js"
6
6
  },