react-native-varia 0.2.2 → 0.2.4
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/bin/cli.js +316 -139
- package/lib/components/Accordion.tsx +113 -0
- package/lib/components/Button.tsx +19 -8
- package/lib/components/CircleProgress.tsx +46 -28
- package/lib/components/Divider.tsx +18 -15
- package/lib/components/Drawer.tsx +496 -0
- package/lib/components/Field.tsx +24 -39
- package/lib/components/GradientBackground.tsx +25 -7
- package/lib/components/GradientText.tsx +38 -11
- package/lib/components/IconWrapper.tsx +20 -14
- package/lib/components/Input.tsx +106 -25
- package/lib/components/NumberInput.tsx +88 -19
- package/lib/components/OldSlider.tsx +327 -0
- package/lib/components/RadioGroup.tsx +55 -17
- package/lib/components/ReText.tsx +1 -1
- package/lib/components/Select.tsx +58 -22
- package/lib/components/Slider.tsx +176 -115
- package/lib/components/Slideshow.tsx +68 -69
- package/lib/components/SlidingDrawer.tsx +72 -29
- package/lib/components/Spinner.tsx +6 -2
- package/lib/components/Toast.tsx +89 -0
- package/lib/components/context/Field.tsx +27 -0
- package/lib/icons/Minus.tsx +24 -0
- package/lib/icons/Plus.tsx +23 -0
- package/lib/theme/Button.recipe.tsx +11 -1
- package/lib/theme/CircleProgress.recipe.tsx +3 -3
- package/lib/theme/Field.recipe.tsx +17 -2
- package/lib/theme/Input.recipe.tsx +12 -3
- package/lib/theme/NumberInput.recipe.tsx +9 -4
- package/lib/theme/RadioGroup.recipe.tsx +7 -1
- package/lib/theme/Select.recipe.tsx +7 -7
- package/lib/theme/Slider.recipe.tsx +366 -22
- package/lib/theme/Slideshow.recipe.tsx +1 -1
- package/lib/theme/SlidingDrawer.recipe.tsx +58 -4
- package/lib/theme/Toast.recipe.tsx +71 -0
- package/package.json +3 -2
- package/lib/components/NewSelect.tsx +0 -202
- package/lib/components/index.tsx +0 -83
- package/lib/components/layoutTest.tsx +0 -74
- package/lib/theme/Button.recipe-old.tsx +0 -67
|
@@ -10,9 +10,15 @@ type TextAdjustment = 'singleLine' | 'multiline' | 'adjustToFit'
|
|
|
10
10
|
|
|
11
11
|
type ButtonVariants = UnistylesVariants<typeof ButtonStyles>
|
|
12
12
|
|
|
13
|
+
interface TextAdjustmentProps {
|
|
14
|
+
adjustsFontSizeToFit?: boolean
|
|
15
|
+
numberOfLines?: number
|
|
16
|
+
ellipsizeMode?: 'tail' | 'head' | 'middle' | 'clip'
|
|
17
|
+
}
|
|
18
|
+
|
|
13
19
|
type ButtonProps = ButtonVariants & {
|
|
14
20
|
colorPalette?: PalettesWithNestedKeys
|
|
15
|
-
text
|
|
21
|
+
text?: string
|
|
16
22
|
onPress: () => void
|
|
17
23
|
loading?: boolean
|
|
18
24
|
disabled?: boolean
|
|
@@ -21,12 +27,13 @@ type ButtonProps = ButtonVariants & {
|
|
|
21
27
|
textAdjustment?: TextAdjustment
|
|
22
28
|
icon?: {
|
|
23
29
|
component: React.ComponentType<IconWrapperProps>
|
|
24
|
-
position
|
|
30
|
+
position?: 'left' | 'right'
|
|
25
31
|
scale?: number
|
|
26
32
|
rotation?: number
|
|
27
33
|
size?: number
|
|
28
34
|
}
|
|
29
35
|
mixins?: StyleProp<ViewStyle> | StyleProp<ViewStyle>[]
|
|
36
|
+
style?: StyleProp<ViewStyle>
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
const Button = ({
|
|
@@ -42,6 +49,7 @@ const Button = ({
|
|
|
42
49
|
textAdjustment = 'singleLine',
|
|
43
50
|
icon,
|
|
44
51
|
mixins,
|
|
52
|
+
style,
|
|
45
53
|
}: ButtonProps) => {
|
|
46
54
|
ButtonStyles.useVariants({
|
|
47
55
|
size,
|
|
@@ -50,7 +58,7 @@ const Button = ({
|
|
|
50
58
|
})
|
|
51
59
|
|
|
52
60
|
const getTextProps = useMemo(
|
|
53
|
-
() => ():
|
|
61
|
+
() => (): TextAdjustmentProps => {
|
|
54
62
|
switch (textAdjustment) {
|
|
55
63
|
case 'adjustToFit':
|
|
56
64
|
return {adjustsFontSizeToFit: true, numberOfLines: 1}
|
|
@@ -87,6 +95,7 @@ const Button = ({
|
|
|
87
95
|
styles.container(flex, maxWidth),
|
|
88
96
|
ButtonStyles.container(colorPalette),
|
|
89
97
|
mixins && mixins,
|
|
98
|
+
style,
|
|
90
99
|
]}
|
|
91
100
|
onPress={onPress}
|
|
92
101
|
disabled={disabled || loading}>
|
|
@@ -98,11 +107,13 @@ const Button = ({
|
|
|
98
107
|
) : (
|
|
99
108
|
<>
|
|
100
109
|
{icon?.position === 'left' && IconRendered}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
110
|
+
{text && (
|
|
111
|
+
<Text
|
|
112
|
+
{...getTextProps()}
|
|
113
|
+
style={[styles.text, ButtonStyles.text(colorPalette)]}>
|
|
114
|
+
{text}
|
|
115
|
+
</Text>
|
|
116
|
+
)}
|
|
106
117
|
{icon?.position === 'right' && IconRendered}
|
|
107
118
|
</>
|
|
108
119
|
)}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {useEffect} from 'react'
|
|
2
|
-
import {View,
|
|
2
|
+
import {TextStyle, View, ViewStyle} from 'react-native'
|
|
3
3
|
import Animated, {
|
|
4
4
|
Easing,
|
|
5
5
|
interpolate,
|
|
@@ -10,9 +10,16 @@ import Animated, {
|
|
|
10
10
|
} from 'react-native-reanimated'
|
|
11
11
|
import Svg, {Circle, G} from 'react-native-svg'
|
|
12
12
|
import {circleProgressTokens} from '../theme/CircleProgress.recipe'
|
|
13
|
-
import {withUnistyles} from 'react-native-unistyles'
|
|
13
|
+
import {withUnistyles, StyleSheet} from 'react-native-unistyles'
|
|
14
14
|
import {resolveColor} from '../style/varia/utils'
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
NestedColorsType,
|
|
17
|
+
PalettesWithNestedKeys,
|
|
18
|
+
progressDirection,
|
|
19
|
+
rotationDirection,
|
|
20
|
+
ThemeType,
|
|
21
|
+
} from '../style/varia/types'
|
|
22
|
+
import {SharedValue} from 'react-native-reanimated'
|
|
16
23
|
|
|
17
24
|
const AnimatedCircle = Animated.createAnimatedComponent(Circle)
|
|
18
25
|
const svgSize = 160
|
|
@@ -21,15 +28,19 @@ interface CircleProgressProps {
|
|
|
21
28
|
variant?: keyof typeof circleProgressTokens.variants.variant
|
|
22
29
|
size?: keyof typeof circleProgressTokens.variants.size
|
|
23
30
|
trackStrokeWidth?: number
|
|
31
|
+
progress: SharedValue<number>
|
|
24
32
|
progressStrokeWidth?: number
|
|
25
33
|
duration: number
|
|
26
34
|
trackColor?: string
|
|
27
35
|
progressColor?: string
|
|
28
|
-
progressDirection?:
|
|
29
|
-
rotationDirection?:
|
|
36
|
+
progressDirection?: progressDirection
|
|
37
|
+
rotationDirection?: rotationDirection
|
|
30
38
|
children?: React.ReactNode
|
|
31
|
-
fontSize?:
|
|
32
|
-
colors:
|
|
39
|
+
fontSize?: TextStyle['fontSize']
|
|
40
|
+
colors: NestedColorsType
|
|
41
|
+
flex?: ViewStyle['flex']
|
|
42
|
+
width?: ViewStyle['width']
|
|
43
|
+
height?: ViewStyle['height']
|
|
33
44
|
}
|
|
34
45
|
|
|
35
46
|
const BaseCircleProgress = ({
|
|
@@ -37,6 +48,7 @@ const BaseCircleProgress = ({
|
|
|
37
48
|
variant = circleProgressTokens.defaultProps.variant,
|
|
38
49
|
size = circleProgressTokens.defaultProps.size,
|
|
39
50
|
trackStrokeWidth,
|
|
51
|
+
progress,
|
|
40
52
|
progressStrokeWidth,
|
|
41
53
|
duration,
|
|
42
54
|
trackColor,
|
|
@@ -45,6 +57,9 @@ const BaseCircleProgress = ({
|
|
|
45
57
|
rotationDirection = 'clockwise',
|
|
46
58
|
children,
|
|
47
59
|
colors,
|
|
60
|
+
flex = 1,
|
|
61
|
+
width = '100%',
|
|
62
|
+
height,
|
|
48
63
|
}: CircleProgressProps) => {
|
|
49
64
|
const resolvedSize = circleProgressTokens.variants.size[size]
|
|
50
65
|
|
|
@@ -69,21 +84,26 @@ const BaseCircleProgress = ({
|
|
|
69
84
|
|
|
70
85
|
const center = svgSize! / 2
|
|
71
86
|
|
|
72
|
-
const
|
|
87
|
+
const internalProgress = useSharedValue(0)
|
|
73
88
|
|
|
74
89
|
useEffect(() => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
90
|
+
if (!progress) {
|
|
91
|
+
internalProgress.value = 0
|
|
92
|
+
internalProgress.value = withTiming(1, {
|
|
93
|
+
duration: duration,
|
|
94
|
+
easing: Easing.linear,
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
}, [progress, duration])
|
|
98
|
+
|
|
99
|
+
const progressValue = progress || internalProgress
|
|
80
100
|
|
|
81
101
|
const animatedProps = useAnimatedProps(() => {
|
|
82
102
|
const rStrokeDashOffset = interpolate(
|
|
83
|
-
|
|
103
|
+
progressValue.value,
|
|
84
104
|
[
|
|
85
|
-
progressDirection === 'forward' ?
|
|
86
|
-
progressDirection === 'forward' ?
|
|
105
|
+
progressDirection === 'forward' ? 0 : 1,
|
|
106
|
+
progressDirection === 'forward' ? 1 : 0,
|
|
87
107
|
],
|
|
88
108
|
[circumference, 0],
|
|
89
109
|
Extrapolation.CLAMP,
|
|
@@ -97,7 +117,7 @@ const BaseCircleProgress = ({
|
|
|
97
117
|
})
|
|
98
118
|
|
|
99
119
|
return (
|
|
100
|
-
<View style={styles.container}>
|
|
120
|
+
<View style={styles.container(flex, width, height)}>
|
|
101
121
|
<Svg
|
|
102
122
|
width="100%"
|
|
103
123
|
height="100%"
|
|
@@ -134,16 +154,17 @@ const BaseCircleProgress = ({
|
|
|
134
154
|
}
|
|
135
155
|
|
|
136
156
|
const styles = StyleSheet.create({
|
|
137
|
-
container:
|
|
157
|
+
container: (
|
|
158
|
+
flex: ViewStyle['flex'],
|
|
159
|
+
width: ViewStyle['width'],
|
|
160
|
+
height: ViewStyle['height'],
|
|
161
|
+
) => ({
|
|
138
162
|
aspectRatio: 1,
|
|
139
|
-
flex
|
|
140
|
-
|
|
163
|
+
flex,
|
|
164
|
+
maxWidth: width,
|
|
165
|
+
maxHeight: height,
|
|
166
|
+
}),
|
|
141
167
|
childContainer: {
|
|
142
|
-
position: 'absolute',
|
|
143
|
-
top: 0,
|
|
144
|
-
left: 0,
|
|
145
|
-
right: 0,
|
|
146
|
-
bottom: 0,
|
|
147
168
|
justifyContent: 'center',
|
|
148
169
|
alignItems: 'center',
|
|
149
170
|
},
|
|
@@ -154,6 +175,3 @@ const CircleProgress = withUnistyles(BaseCircleProgress, theme => ({
|
|
|
154
175
|
}))
|
|
155
176
|
|
|
156
177
|
export default CircleProgress
|
|
157
|
-
|
|
158
|
-
const clamp = (num: number, min: number, max: number) =>
|
|
159
|
-
Math.min(Math.max(num, min), max)
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import {View} from 'react-native'
|
|
2
|
+
import {StyleSheet} from 'react-native-unistyles'
|
|
3
|
+
import {PalettesWithNestedKeys, ThemeColors} from '../style/varia/types'
|
|
4
|
+
import {resolveColor} from '../style/varia/utils'
|
|
4
5
|
|
|
5
6
|
const Divider = ({
|
|
6
7
|
color,
|
|
7
8
|
size = 1,
|
|
8
9
|
axis = 'y',
|
|
9
10
|
margin = 0,
|
|
11
|
+
colorPalette = 'accent',
|
|
10
12
|
}: {
|
|
11
|
-
color?:
|
|
12
|
-
size?: number
|
|
13
|
-
axis?: 'x' | 'y'
|
|
14
|
-
margin?: number
|
|
13
|
+
color?: ThemeColors
|
|
14
|
+
size?: number
|
|
15
|
+
axis?: 'x' | 'y'
|
|
16
|
+
margin?: number
|
|
17
|
+
colorPalette?: PalettesWithNestedKeys
|
|
15
18
|
}) => {
|
|
16
19
|
return (
|
|
17
20
|
<View style={styles.container(size, axis, margin)}>
|
|
18
|
-
<View style={[styles.divider(color, size, axis)]} />
|
|
21
|
+
<View style={[styles.divider(color, colorPalette, size, axis)]} />
|
|
19
22
|
</View>
|
|
20
|
-
)
|
|
21
|
-
}
|
|
23
|
+
)
|
|
24
|
+
}
|
|
22
25
|
|
|
23
26
|
const styles = StyleSheet.create(theme => ({
|
|
24
27
|
container: (size, axis, margin) => ({
|
|
@@ -31,13 +34,13 @@ const styles = StyleSheet.create(theme => ({
|
|
|
31
34
|
marginHorizontal: axis === 'x' ? margin : 0,
|
|
32
35
|
marginVertical: axis === 'y' ? margin : 0,
|
|
33
36
|
}),
|
|
34
|
-
divider: (color, size, axis) => ({
|
|
37
|
+
divider: (color, colorPalette, size, axis) => ({
|
|
35
38
|
width: axis === 'x' ? size : '100%',
|
|
36
39
|
height: axis === 'y' ? size : '100%',
|
|
37
40
|
backgroundColor: color
|
|
38
|
-
? color
|
|
39
|
-
: theme.colors.
|
|
41
|
+
? resolveColor(color, theme.colors, colorPalette)
|
|
42
|
+
: theme.colors.fg.default,
|
|
40
43
|
}),
|
|
41
|
-
}))
|
|
44
|
+
}))
|
|
42
45
|
|
|
43
|
-
export default Divider
|
|
46
|
+
export default Divider
|