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
@@ -1,285 +0,0 @@
1
- import {useMemo} from 'react'
2
- import {StyleProp, View, ViewStyle} from 'react-native'
3
- import {StyleSheet} from 'react-native-unistyles'
4
-
5
- interface StackProps {
6
- backgroundColor?: ViewStyle['backgroundColor']
7
- bg?: ViewStyle['backgroundColor']
8
- width?: ViewStyle['width']
9
- w?: ViewStyle['width']
10
- height?: ViewStyle['height']
11
- h?: ViewStyle['height']
12
- borderColor?: ViewStyle['borderColor']
13
- borderWidth?: ViewStyle['borderWidth']
14
- borderStyle?: ViewStyle['borderStyle']
15
- borderRadius?: ViewStyle['borderRadius']
16
- br?: ViewStyle['borderRadius']
17
- alignSelf?: ViewStyle['alignSelf']
18
- alignItems?: ViewStyle['alignItems']
19
- justifyContent?: ViewStyle['justifyContent']
20
- flex?: ViewStyle['flex']
21
- flexShrink?: ViewStyle['flexShrink']
22
- flexGrow?: ViewStyle['flexGrow']
23
- flexBasis?: ViewStyle['flexBasis']
24
- flexWrap?: ViewStyle['flexWrap']
25
- gap?: ViewStyle['gap']
26
- m?: ViewStyle['margin']
27
- mt?: ViewStyle['marginTop']
28
- mb?: ViewStyle['marginBottom']
29
- ml?: ViewStyle['marginLeft']
30
- mr?: ViewStyle['marginRight']
31
- mx?: ViewStyle['marginHorizontal']
32
- my?: ViewStyle['marginVertical']
33
- margin?: ViewStyle['margin']
34
- marginVertical?: ViewStyle['marginVertical']
35
- marginHorizontal?: ViewStyle['marginHorizontal']
36
- marginTop?: ViewStyle['marginTop']
37
- marginBottom?: ViewStyle['marginBottom']
38
- marginLeft?: ViewStyle['marginLeft']
39
- marginRight?: ViewStyle['marginRight']
40
- p?: ViewStyle['padding']
41
- pt?: ViewStyle['paddingVertical']
42
- pb?: ViewStyle['paddingVertical']
43
- pl?: ViewStyle['paddingLeft']
44
- pr?: ViewStyle['paddingRight']
45
- px?: ViewStyle['paddingHorizontal']
46
- py?: ViewStyle['paddingVertical']
47
- padding?: ViewStyle['padding']
48
- paddingVertical?: ViewStyle['paddingVertical']
49
- paddingHorizontal?: ViewStyle['paddingHorizontal']
50
- paddingTop?: ViewStyle['paddingTop']
51
- paddingBottom?: ViewStyle['paddingBottom']
52
- paddingLeft?: ViewStyle['paddingLeft']
53
- paddingRight?: ViewStyle['paddingRight']
54
- children?: React.ReactNode
55
- // style?: ViewStyle
56
- style?: StyleProp<ViewStyle>
57
- align?: 'center' | 'vCenter' | 'hCenter'
58
- }
59
-
60
- function mapProps(props: StackProps) {
61
- const stylesArr: any[] = []
62
-
63
- Object.entries(props).forEach(([key, value]) => {
64
- if (value == null) return
65
-
66
- const fn = (stackStyles as any)[key]
67
- if (typeof fn === 'function') {
68
- stylesArr.push(fn(value))
69
- }
70
- })
71
-
72
- return stylesArr
73
- }
74
-
75
- const VStack = ({children, style, align, ...props}: StackProps) => {
76
- stackStyles.useVariants({align})
77
- const styleArr = useMemo(() => mapProps(props), [props])
78
-
79
- return (
80
- <View style={[stackStyles.stack, stackStyles.vstack, styleArr, style]}>
81
- {children}
82
- </View>
83
- )
84
- }
85
-
86
- const HStack = ({children, style, align, ...props}: StackProps) => {
87
- stackStyles.useVariants({align})
88
- const styleArr = useMemo(() => mapProps(props), [props])
89
-
90
- return (
91
- <View style={[stackStyles.stack, stackStyles.hstack, styleArr, style]}>
92
- {children}
93
- </View>
94
- )
95
- }
96
-
97
- const stackStyles = StyleSheet.create({
98
- stack: {},
99
- vstack: {
100
- flexDirection: 'column',
101
- variants: {
102
- align: {
103
- center: {
104
- alignItems: 'center',
105
- justifyContent: 'center',
106
- },
107
- vCenter: {
108
- justifyContent: 'center',
109
- },
110
- hCenter: {
111
- alignItems: 'center',
112
- },
113
- },
114
- },
115
- },
116
- hstack: {
117
- flexDirection: 'row',
118
- variants: {
119
- align: {
120
- center: {
121
- alignItems: 'center',
122
- justifyContent: 'center',
123
- },
124
- vCenter: {
125
- alignItems: 'center',
126
- },
127
- hCenter: {
128
- justifyContent: 'center',
129
- },
130
- },
131
- },
132
- },
133
-
134
- backgroundColor: value => ({
135
- backgroundColor: value,
136
- }),
137
- bg: value => ({
138
- backgroundColor: value,
139
- }),
140
-
141
- width: value => ({
142
- width: value,
143
- }),
144
- w: value => ({
145
- width: value,
146
- }),
147
- height: value => ({
148
- height: value,
149
- }),
150
- h: value => ({
151
- height: value,
152
- }),
153
-
154
- borderColor: value => ({
155
- borderColor: value,
156
- }),
157
- borderWidth: value => ({
158
- borderWidth: value,
159
- }),
160
- borderStyle: value => ({
161
- borderStyle: value,
162
- }),
163
- borderRadius: value => ({
164
- borderRadius: value,
165
- }),
166
- br: value => ({
167
- borderRadius: value,
168
- }),
169
-
170
- flex: value => ({
171
- flex: value,
172
- }),
173
- flexShrink: value => ({
174
- flexShrink: value,
175
- }),
176
- flexGrow: value => ({
177
- flexGrow: value,
178
- }),
179
- flexBasis: value => ({
180
- flexBasis: value,
181
- }),
182
- flexWrap: value => ({
183
- flexWrap: value,
184
- }),
185
- alignSelf: value => ({
186
- alignSelf: value,
187
- }),
188
- alignItems: value => ({
189
- alignItems: value,
190
- }),
191
- justifyContent: value => ({
192
- justifyContent: value,
193
- }),
194
- gap: value => ({
195
- gap: value,
196
- }),
197
-
198
- m: value => ({
199
- margin: value,
200
- }),
201
- mt: value => ({
202
- marginTop: value,
203
- }),
204
- mb: value => ({
205
- marginBottom: value,
206
- }),
207
- ml: value => ({
208
- marginLeft: value,
209
- }),
210
- mr: value => ({
211
- marginRight: value,
212
- }),
213
- mx: value => ({
214
- marginHorizontal: value,
215
- }),
216
- my: value => ({
217
- marginVertical: value,
218
- }),
219
- margin: value => ({
220
- margin: value,
221
- }),
222
- marginVertical: value => ({
223
- marginVertical: value,
224
- }),
225
- marginHorizontal: value => ({
226
- marginHorizontal: value,
227
- }),
228
- marginLeft: value => ({
229
- marginLeft: value,
230
- }),
231
- marginRight: value => ({
232
- marginRight: value,
233
- }),
234
- marginTop: value => ({
235
- marginTop: value,
236
- }),
237
- marginBottom: value => ({
238
- marginBottom: value,
239
- }),
240
-
241
- p: value => ({
242
- padding: value,
243
- }),
244
- pt: value => ({
245
- paddingTop: value,
246
- }),
247
- pb: value => ({
248
- paddingBottom: value,
249
- }),
250
- pl: value => ({
251
- paddingLeft: value,
252
- }),
253
- pr: value => ({
254
- paddingRight: value,
255
- }),
256
- px: value => ({
257
- paddingHorizontal: value,
258
- }),
259
- py: value => ({
260
- paddingVertical: value,
261
- }),
262
- padding: value => ({
263
- padding: value,
264
- }),
265
- paddingHorizontal: value => ({
266
- paddingHorizontal: value,
267
- }),
268
- paddingVertical: value => ({
269
- paddingVertical: value,
270
- }),
271
- paddingLeft: value => ({
272
- paddingLeft: value,
273
- }),
274
- paddingRight: value => ({
275
- paddingRight: value,
276
- }),
277
- paddingTop: value => ({
278
- paddingTop: value,
279
- }),
280
- paddingBottom: value => ({
281
- paddingBottom: value,
282
- }),
283
- })
284
-
285
- export {VStack, HStack}