react-native-varia 0.5.2 → 0.6.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.
- 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 +73 -25
- 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 +202 -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/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)
|
package/lib/varia/types.ts
CHANGED
|
@@ -287,3 +287,9 @@ export type rotationDirection = 'clockwise' | 'counterclockwise'
|
|
|
287
287
|
export type Flex = ViewStyle['flex']
|
|
288
288
|
export type MaxWidth = ViewStyle['maxWidth']
|
|
289
289
|
export type ZIndex = ViewStyle['zIndex']
|
|
290
|
+
|
|
291
|
+
export type Axis = 'x' | 'y'
|
|
292
|
+
export type SizeEntry = {
|
|
293
|
+
x?: Record<string, any>
|
|
294
|
+
y?: Record<string, any>
|
|
295
|
+
}
|
package/lib/varia/utils.ts
CHANGED
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
ColorScheme,
|
|
38
38
|
CreatePresetDTO,
|
|
39
39
|
CustomColorScheme,
|
|
40
|
+
SizeEntry,
|
|
40
41
|
ThemeColors,
|
|
41
42
|
ThemePresetDTO,
|
|
42
43
|
} from './types'
|
|
@@ -439,3 +440,9 @@ export function getCompoundVariantValue<
|
|
|
439
440
|
|
|
440
441
|
return match.styles[propName]
|
|
441
442
|
}
|
|
443
|
+
|
|
444
|
+
export const generateCompoundVariants = (sizes: Record<string, SizeEntry>) =>
|
|
445
|
+
Object.entries(sizes).flatMap(([size, axes]) => [
|
|
446
|
+
{axis: 'x', size, styles: axes.x ?? {}},
|
|
447
|
+
{axis: 'y', size, styles: axes.y ?? {}},
|
|
448
|
+
])
|