react-native-varia 0.5.2 → 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.
- package/lib/components/Accordion.tsx +55 -27
- package/lib/components/Badge.tsx +12 -6
- package/lib/components/Button.tsx +18 -6
- package/lib/components/Checkbox.tsx +22 -4
- package/lib/components/CircleProgress.tsx +7 -3
- package/lib/components/Divider.tsx +7 -3
- package/lib/components/Drawer.tsx +91 -47
- package/lib/components/Field.tsx +12 -6
- package/lib/components/FloatingAction.tsx +15 -4
- package/lib/components/GradientBackground.tsx +1 -1
- package/lib/components/GradientText.tsx +15 -5
- package/lib/components/IconWrapper.tsx +2 -2
- package/lib/components/Input.tsx +11 -6
- package/lib/components/Link.tsx +7 -7
- package/lib/components/Modal.tsx +42 -13
- package/lib/components/NumberInput.tsx +44 -23
- package/lib/components/RadioGroup.tsx +35 -6
- package/lib/components/ReText.tsx +1 -1
- package/lib/components/Select.tsx +61 -8
- package/lib/components/Slider.tsx +198 -200
- package/lib/components/Slideshow.tsx +12 -3
- package/lib/components/Switch.tsx +15 -3
- package/lib/components/Text.tsx +2 -2
- package/lib/components/Toast.tsx +14 -3
- package/lib/components/context/Field.tsx +2 -0
- package/lib/theme/Accordion.recipe.tsx +48 -0
- package/lib/theme/Drawer.recipe.tsx +1 -0
- package/lib/theme/Slider.recipe.tsx +143 -399
- package/lib/varia/types.ts +6 -0
- package/lib/varia/utils.ts +7 -0
- package/package.json +1 -1
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Platform,
|
|
3
|
+
StyleProp,
|
|
4
|
+
TouchableWithoutFeedback,
|
|
5
|
+
View,
|
|
6
|
+
ViewStyle,
|
|
7
|
+
} from 'react-native'
|
|
2
8
|
import Animated, {
|
|
3
9
|
useAnimatedStyle,
|
|
4
10
|
useSharedValue,
|
|
@@ -31,6 +37,8 @@ type SwitchProps = SwitchVariants & {
|
|
|
31
37
|
enabledIcon?: ReactNode
|
|
32
38
|
disabledIcon?: ReactNode
|
|
33
39
|
alignSelf?: AlignSelf
|
|
40
|
+
containerStyles?: StyleProp<ViewStyle>
|
|
41
|
+
thumbStyles?: StyleProp<ViewStyle>
|
|
34
42
|
}
|
|
35
43
|
|
|
36
44
|
const Switch = ({
|
|
@@ -44,6 +52,8 @@ const Switch = ({
|
|
|
44
52
|
size = SwitchTokens.defaultProps.size,
|
|
45
53
|
flex = 0,
|
|
46
54
|
alignSelf = 'flex-start',
|
|
55
|
+
containerStyles,
|
|
56
|
+
thumbStyles,
|
|
47
57
|
}: SwitchProps) => {
|
|
48
58
|
const animatedRef = useRef<View>(null)
|
|
49
59
|
|
|
@@ -166,15 +176,17 @@ const Switch = ({
|
|
|
166
176
|
<AnimatedView
|
|
167
177
|
ref={animatedRef}
|
|
168
178
|
style={[
|
|
179
|
+
SwitchStyles.container(colorPalette),
|
|
180
|
+
containerStyles,
|
|
169
181
|
styles.container(flex, alignSelf),
|
|
170
182
|
animatedStyle,
|
|
171
|
-
SwitchStyles.container(colorPalette),
|
|
172
183
|
]}>
|
|
173
184
|
<AnimatedView
|
|
174
185
|
testID="varia-switch-thumb"
|
|
175
186
|
style={[
|
|
176
|
-
styles.thumb,
|
|
177
187
|
SwitchStyles.thumb(colorPalette),
|
|
188
|
+
thumbStyles,
|
|
189
|
+
styles.thumb,
|
|
178
190
|
thumbAnimatedStyle,
|
|
179
191
|
circleTranslationStyle,
|
|
180
192
|
]}>
|
package/lib/components/Text.tsx
CHANGED
|
@@ -11,7 +11,7 @@ type TextProps = TextVariants &
|
|
|
11
11
|
colorPalette?: PalettesWithNestedKeys
|
|
12
12
|
fontSize?: number | undefined
|
|
13
13
|
color?: ThemeColors
|
|
14
|
-
style?: TextStyle
|
|
14
|
+
style?: StyleProp<TextStyle>
|
|
15
15
|
children?: React.ReactNode
|
|
16
16
|
mixins?: StyleProp<TextStyle> | StyleProp<TextStyle>[]
|
|
17
17
|
}
|
|
@@ -37,8 +37,8 @@ const Text = ({
|
|
|
37
37
|
style={[
|
|
38
38
|
TextStyles.text(colorPalette),
|
|
39
39
|
styles.text(color, fontSize),
|
|
40
|
-
mixins && mixins,
|
|
41
40
|
style,
|
|
41
|
+
mixins && mixins,
|
|
42
42
|
]}
|
|
43
43
|
{...props}>
|
|
44
44
|
{children}
|
package/lib/components/Toast.tsx
CHANGED
|
@@ -15,6 +15,7 @@ import {PalettesWithNestedKeys, ZIndex} from '../../style/varia/types'
|
|
|
15
15
|
import Text from './Text'
|
|
16
16
|
import {AnimatedHStack, VStack} from '../../patterns'
|
|
17
17
|
import {ZINDEXES} from '../../style/varia/constants'
|
|
18
|
+
import {StyleProp, TextStyle, ViewStyle} from 'react-native'
|
|
18
19
|
|
|
19
20
|
type ToastVariants = UnistylesVariants<typeof ToastStyles>
|
|
20
21
|
|
|
@@ -25,6 +26,8 @@ export type ToastProps = ToastVariants & {
|
|
|
25
26
|
onClose?: () => void
|
|
26
27
|
position?: 'top' | 'bottom'
|
|
27
28
|
zIndex?: ZIndex
|
|
29
|
+
containerStyles?: StyleProp<ViewStyle>
|
|
30
|
+
textStyles?: StyleProp<TextStyle>
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
const Toast: React.FC<ToastProps> = ({
|
|
@@ -36,6 +39,8 @@ const Toast: React.FC<ToastProps> = ({
|
|
|
36
39
|
onClose,
|
|
37
40
|
position = 'bottom',
|
|
38
41
|
zIndex,
|
|
42
|
+
containerStyles,
|
|
43
|
+
textStyles,
|
|
39
44
|
}) => {
|
|
40
45
|
ToastStyles.useVariants({variant, size})
|
|
41
46
|
|
|
@@ -91,13 +96,19 @@ const Toast: React.FC<ToastProps> = ({
|
|
|
91
96
|
justifyContent:
|
|
92
97
|
position === 'bottom' || !position ? 'flex-end' : 'flex-start',
|
|
93
98
|
},
|
|
94
|
-
styles.container(zIndex || ZINDEXES.toast),
|
|
95
99
|
ToastStyles.root,
|
|
100
|
+
styles.container(zIndex || ZINDEXES.toast),
|
|
96
101
|
]}>
|
|
97
102
|
<AnimatedHStack
|
|
98
103
|
ref={animatedRef}
|
|
99
|
-
style={[
|
|
100
|
-
|
|
104
|
+
style={[
|
|
105
|
+
animatedStyle,
|
|
106
|
+
ToastStyles.container(colorPalette),
|
|
107
|
+
containerStyles,
|
|
108
|
+
]}>
|
|
109
|
+
<Text style={[ToastStyles.text(colorPalette), textStyles]}>
|
|
110
|
+
{message}
|
|
111
|
+
</Text>
|
|
101
112
|
</AnimatedHStack>
|
|
102
113
|
</VStack>
|
|
103
114
|
)
|
|
@@ -2,6 +2,7 @@ import {createContext, useContext} from 'react'
|
|
|
2
2
|
import {UnistylesVariants} from 'react-native-unistyles'
|
|
3
3
|
import {FieldStyles} from '../../../theme/Field.recipe'
|
|
4
4
|
import {PalettesWithNestedKeys} from '../../../style/varia/types'
|
|
5
|
+
import {StyleProp, TextStyle} from 'react-native'
|
|
5
6
|
|
|
6
7
|
export type FieldVariants = UnistylesVariants<typeof FieldStyles>
|
|
7
8
|
|
|
@@ -10,6 +11,7 @@ export type FieldContextType = {
|
|
|
10
11
|
variant?: FieldVariants['variant']
|
|
11
12
|
size?: FieldVariants['size']
|
|
12
13
|
colorPalette?: PalettesWithNestedKeys
|
|
14
|
+
labelStyles?: StyleProp<TextStyle>
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
const FieldContext = createContext<FieldContextType | undefined>(undefined)
|
|
@@ -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,
|