react-native-varia 0.2.4 → 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.
- package/lib/components/Accordion.tsx +61 -21
- package/lib/components/Badge.tsx +9 -0
- package/lib/components/Button.tsx +21 -6
- package/lib/components/Checkbox.tsx +22 -8
- package/lib/components/CircleProgress.tsx +8 -0
- package/lib/components/Divider.tsx +11 -4
- package/lib/components/Drawer.tsx +34 -25
- package/lib/components/Field.tsx +4 -0
- package/lib/components/GradientBackground.tsx +3 -0
- package/lib/components/GradientText.tsx +37 -11
- package/lib/components/IconWrapper.tsx +3 -2
- package/lib/components/Input.tsx +47 -20
- package/lib/components/Link.tsx +4 -0
- package/lib/components/Modal.tsx +21 -14
- package/lib/components/NumberInput.tsx +27 -5
- package/lib/components/RadioGroup.tsx +19 -6
- package/lib/components/ReText.tsx +4 -1
- package/lib/components/Select.tsx +20 -0
- package/lib/components/Slider.tsx +244 -134
- package/lib/components/Slideshow.tsx +19 -3
- package/lib/components/Spinner.tsx +12 -2
- package/lib/components/Switch.tsx +57 -26
- package/lib/components/Text.tsx +3 -0
- package/lib/components/Toast.tsx +110 -36
- package/lib/patterns/index.tsx +299 -79
- package/lib/theme/Accordion.tsx +184 -0
- package/lib/theme/Button.recipe.tsx +24 -7
- package/lib/theme/{SlidingDrawer.recipe.tsx → Drawer.recipe.tsx} +4 -6
- package/lib/theme/Field.recipe.tsx +45 -15
- package/lib/theme/GradientText.recipe.tsx +103 -34
- package/lib/theme/Input.recipe.tsx +14 -6
- package/lib/theme/Select.recipe.tsx +3 -0
- package/lib/theme/Slider.recipe.tsx +108 -141
- package/lib/theme/Spinner.recipe.tsx +4 -0
- package/lib/theme/Switch.recipe.tsx +19 -0
- package/lib/theme/Text.recipe.tsx +63 -12
- package/lib/theme/Toast.recipe.tsx +40 -7
- package/lib/varia/mixins.ts +0 -4
- package/lib/varia/types.ts +11 -0
- package/lib/varia/utils.ts +172 -14
- package/package.json +1 -1
- package/lib/components/OldSlider.tsx +0 -327
- package/lib/components/SlidingDrawer.tsx +0 -301
|
@@ -2,10 +2,16 @@ import React, {ReactNode, useState} from 'react'
|
|
|
2
2
|
import {View, Pressable} from 'react-native'
|
|
3
3
|
import Animated from 'react-native-reanimated'
|
|
4
4
|
import {LinearTransition} from 'react-native-reanimated'
|
|
5
|
-
import {StyleSheet} from 'react-native-unistyles'
|
|
5
|
+
import {StyleSheet, UnistylesVariants} from 'react-native-unistyles'
|
|
6
6
|
import Text from './Text'
|
|
7
|
+
import {AccordionStyles, AccordionDefaultVariants} from '../theme/Accordion'
|
|
8
|
+
import {AlignSelf, Flex, PalettesWithNestedKeys} from '../style/varia/types'
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
const AnimatedView = Animated.createAnimatedComponent(View)
|
|
11
|
+
type AccordionVariants = UnistylesVariants<typeof AccordionStyles>
|
|
12
|
+
|
|
13
|
+
type AccordionItemProps = AccordionVariants & {
|
|
14
|
+
colorPalette?: PalettesWithNestedKeys
|
|
9
15
|
title: string
|
|
10
16
|
itemKey: string
|
|
11
17
|
children: ReactNode
|
|
@@ -14,10 +20,12 @@ type AccordionItemProps = {
|
|
|
14
20
|
scrollViewRef?: any
|
|
15
21
|
}
|
|
16
22
|
|
|
17
|
-
type AccordionGroupRootProps = {
|
|
23
|
+
type AccordionGroupRootProps = AccordionVariants & {
|
|
18
24
|
children: ReactNode
|
|
19
25
|
defaultOpenKeys?: string[]
|
|
20
26
|
allowMultiple?: boolean
|
|
27
|
+
flex?: Flex
|
|
28
|
+
alignSelf?: AlignSelf
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
export const AccordionGroup = {
|
|
@@ -26,9 +34,13 @@ export const AccordionGroup = {
|
|
|
26
34
|
}
|
|
27
35
|
|
|
28
36
|
function AccordionGroupRoot({
|
|
37
|
+
variant = AccordionDefaultVariants.variant,
|
|
38
|
+
size = AccordionDefaultVariants.size,
|
|
29
39
|
children,
|
|
30
40
|
defaultOpenKeys = [],
|
|
31
41
|
allowMultiple = false,
|
|
42
|
+
flex = 1,
|
|
43
|
+
alignSelf = 'auto',
|
|
32
44
|
}: AccordionGroupRootProps) {
|
|
33
45
|
const [openKeys, setOpenKeys] = useState<Set<string>>(
|
|
34
46
|
() => new Set(defaultOpenKeys),
|
|
@@ -52,31 +64,43 @@ function AccordionGroupRoot({
|
|
|
52
64
|
|
|
53
65
|
const items = React.Children.map(children, child => {
|
|
54
66
|
if (!React.isValidElement(child)) return child
|
|
55
|
-
|
|
56
|
-
const
|
|
67
|
+
|
|
68
|
+
const element = child as React.ReactElement<AccordionItemProps>
|
|
69
|
+
const key = element.props.itemKey
|
|
57
70
|
const isOpen = openKeys.has(key)
|
|
58
|
-
|
|
71
|
+
|
|
72
|
+
return React.cloneElement(element, {
|
|
59
73
|
isOpen,
|
|
74
|
+
variant,
|
|
75
|
+
size,
|
|
60
76
|
onToggle: () => toggleItem(key),
|
|
61
77
|
})
|
|
62
78
|
})
|
|
63
79
|
|
|
64
|
-
return <View style={styles.groupContainer}>{items}</View>
|
|
80
|
+
return <View style={styles.groupContainer(flex, alignSelf)}>{items}</View>
|
|
65
81
|
}
|
|
66
82
|
|
|
67
83
|
function AccordionGroupItem({
|
|
84
|
+
variant = AccordionDefaultVariants.variant,
|
|
85
|
+
size = AccordionDefaultVariants.size,
|
|
86
|
+
colorPalette = 'accent',
|
|
68
87
|
title,
|
|
69
88
|
children,
|
|
70
89
|
isOpen = false,
|
|
71
90
|
onToggle,
|
|
72
91
|
}: AccordionItemProps) {
|
|
92
|
+
AccordionStyles.useVariants({variant, size, active: isOpen})
|
|
73
93
|
return (
|
|
74
|
-
<
|
|
75
|
-
// Aquí aplicas la transición de layout
|
|
94
|
+
<AnimatedView
|
|
76
95
|
layout={LinearTransition.duration(150)}
|
|
77
|
-
style={
|
|
78
|
-
|
|
79
|
-
|
|
96
|
+
style={[
|
|
97
|
+
styles.itemContainer,
|
|
98
|
+
AccordionStyles.itemContainer(colorPalette),
|
|
99
|
+
]}>
|
|
100
|
+
<Pressable
|
|
101
|
+
onPress={onToggle}
|
|
102
|
+
style={[styles.header, AccordionStyles.header(colorPalette)]}>
|
|
103
|
+
<Text style={AccordionStyles.headerTitle(colorPalette)}>{title}</Text>
|
|
80
104
|
</Pressable>
|
|
81
105
|
|
|
82
106
|
{isOpen && (
|
|
@@ -84,30 +108,46 @@ function AccordionGroupItem({
|
|
|
84
108
|
<View style={styles.innerContent}>{children}</View>
|
|
85
109
|
</View>
|
|
86
110
|
)}
|
|
87
|
-
</
|
|
111
|
+
</AnimatedView>
|
|
88
112
|
)
|
|
89
113
|
}
|
|
90
114
|
|
|
91
115
|
const styles = StyleSheet.create({
|
|
92
|
-
groupContainer: {
|
|
116
|
+
groupContainer: (flex: Flex, alignSelf: AlignSelf) => ({
|
|
117
|
+
flex,
|
|
118
|
+
alignSelf,
|
|
119
|
+
flexBasis: 'auto',
|
|
120
|
+
_web: {
|
|
121
|
+
_classNames: 'accordion-group-container-base',
|
|
122
|
+
},
|
|
123
|
+
}),
|
|
93
124
|
itemContainer: {
|
|
94
125
|
borderWidth: 1,
|
|
95
|
-
borderColor: '#ddd',
|
|
96
126
|
borderRadius: 6,
|
|
97
127
|
marginVertical: 8,
|
|
98
|
-
overflow: 'hidden',
|
|
128
|
+
overflow: 'hidden',
|
|
129
|
+
_web: {
|
|
130
|
+
_classNames: 'accordion-item-container-base',
|
|
131
|
+
},
|
|
99
132
|
},
|
|
100
133
|
header: {
|
|
101
|
-
|
|
102
|
-
|
|
134
|
+
justifyContent: 'center',
|
|
135
|
+
_web: {
|
|
136
|
+
_classNames: 'accordion-header-base',
|
|
137
|
+
},
|
|
103
138
|
},
|
|
104
139
|
headerText: {
|
|
105
140
|
fontSize: 16,
|
|
141
|
+
color: 'blue',
|
|
142
|
+
_web: {
|
|
143
|
+
_classNames: 'accordion-header-text-base',
|
|
144
|
+
},
|
|
106
145
|
},
|
|
107
|
-
contentContainer: {
|
|
108
|
-
// no necesitamos animar altura manual, lo hace el layout
|
|
109
|
-
},
|
|
146
|
+
contentContainer: {},
|
|
110
147
|
innerContent: {
|
|
111
148
|
padding: 12,
|
|
149
|
+
_web: {
|
|
150
|
+
_classNames: 'accordion-item-content-base',
|
|
151
|
+
},
|
|
112
152
|
},
|
|
113
153
|
})
|
package/lib/components/Badge.tsx
CHANGED
|
@@ -80,6 +80,9 @@ const styles = StyleSheet.create({
|
|
|
80
80
|
borderWidth: 1,
|
|
81
81
|
alignItems: 'center',
|
|
82
82
|
justifyContent: 'center',
|
|
83
|
+
_web: {
|
|
84
|
+
_classNames: 'badge-base',
|
|
85
|
+
},
|
|
83
86
|
},
|
|
84
87
|
badgeAbsolute: (x, y) => ({
|
|
85
88
|
position: 'absolute',
|
|
@@ -89,9 +92,15 @@ const styles = StyleSheet.create({
|
|
|
89
92
|
{translateY: y === 'top' ? '-50%' : '50%'},
|
|
90
93
|
{translateX: x === 'left' ? '-50%' : '50%'},
|
|
91
94
|
],
|
|
95
|
+
_web: {
|
|
96
|
+
_classNames: 'badge-absolute-base',
|
|
97
|
+
},
|
|
92
98
|
}),
|
|
93
99
|
text: {
|
|
94
100
|
textAlign: 'center',
|
|
101
|
+
_web: {
|
|
102
|
+
_classNames: 'badge-text-base',
|
|
103
|
+
},
|
|
95
104
|
},
|
|
96
105
|
customStyle: style => ({
|
|
97
106
|
...style,
|
|
@@ -5,6 +5,7 @@ import {useMemo} from 'react'
|
|
|
5
5
|
import {IconWrapperProps} from './IconWrapper'
|
|
6
6
|
import Spinner, {SpinnerProps} from './Spinner'
|
|
7
7
|
import {PalettesWithNestedKeys} from '../style/varia/types'
|
|
8
|
+
import {getVariantValue} from '../style/varia/utils'
|
|
8
9
|
|
|
9
10
|
type TextAdjustment = 'singleLine' | 'multiline' | 'adjustToFit'
|
|
10
11
|
|
|
@@ -22,6 +23,7 @@ type ButtonProps = ButtonVariants & {
|
|
|
22
23
|
onPress: () => void
|
|
23
24
|
loading?: boolean
|
|
24
25
|
disabled?: boolean
|
|
26
|
+
activeOpacity?: number
|
|
25
27
|
maxWidth?: number | string
|
|
26
28
|
flex?: number
|
|
27
29
|
textAdjustment?: TextAdjustment
|
|
@@ -40,6 +42,7 @@ const Button = ({
|
|
|
40
42
|
colorPalette = 'accent',
|
|
41
43
|
size = ButtonDefaultVariants.size,
|
|
42
44
|
variant = ButtonDefaultVariants.variant,
|
|
45
|
+
activeOpacity = 0.6,
|
|
43
46
|
onPress,
|
|
44
47
|
text,
|
|
45
48
|
loading = false,
|
|
@@ -76,6 +79,13 @@ const Button = ({
|
|
|
76
79
|
[textAdjustment],
|
|
77
80
|
)
|
|
78
81
|
|
|
82
|
+
const resolvedColor = getVariantValue(
|
|
83
|
+
ButtonStyles.text(colorPalette),
|
|
84
|
+
'variant',
|
|
85
|
+
variant,
|
|
86
|
+
'color',
|
|
87
|
+
)
|
|
88
|
+
|
|
79
89
|
const IconComponent = icon?.component
|
|
80
90
|
const IconRendered = IconComponent ? (
|
|
81
91
|
<IconComponent
|
|
@@ -84,13 +94,15 @@ const Button = ({
|
|
|
84
94
|
scale: icon.scale,
|
|
85
95
|
colorPalette,
|
|
86
96
|
size: icon.size,
|
|
87
|
-
color:
|
|
97
|
+
color: resolvedColor,
|
|
88
98
|
}}
|
|
89
99
|
/>
|
|
90
100
|
) : null
|
|
91
101
|
|
|
92
102
|
return (
|
|
93
103
|
<TouchableOpacity
|
|
104
|
+
role="button"
|
|
105
|
+
activeOpacity={activeOpacity}
|
|
94
106
|
style={[
|
|
95
107
|
styles.container(flex, maxWidth),
|
|
96
108
|
ButtonStyles.container(colorPalette),
|
|
@@ -100,10 +112,7 @@ const Button = ({
|
|
|
100
112
|
onPress={onPress}
|
|
101
113
|
disabled={disabled || loading}>
|
|
102
114
|
{loading ? (
|
|
103
|
-
<Spinner
|
|
104
|
-
size={size as SpinnerProps['size']}
|
|
105
|
-
color={ButtonStyles.text(colorPalette).color}
|
|
106
|
-
/>
|
|
115
|
+
<Spinner size={size as SpinnerProps['size']} color={resolvedColor} />
|
|
107
116
|
) : (
|
|
108
117
|
<>
|
|
109
118
|
{icon?.position === 'left' && IconRendered}
|
|
@@ -129,10 +138,16 @@ const styles = StyleSheet.create({
|
|
|
129
138
|
flexDirection: 'row',
|
|
130
139
|
justifyContent: 'center',
|
|
131
140
|
alignItems: 'center',
|
|
132
|
-
|
|
141
|
+
flexBasis: 'auto',
|
|
142
|
+
_web: {
|
|
143
|
+
_classNames: 'button-container-base',
|
|
144
|
+
},
|
|
133
145
|
}),
|
|
134
146
|
text: {
|
|
135
147
|
textAlign: 'center',
|
|
148
|
+
_web: {
|
|
149
|
+
_classNames: 'button-text-base',
|
|
150
|
+
},
|
|
136
151
|
},
|
|
137
152
|
})
|
|
138
153
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React, {useCallback} from 'react'
|
|
2
|
-
import {View, Text, Pressable
|
|
2
|
+
import {View, Text, Pressable} from 'react-native'
|
|
3
|
+
import {StyleSheet} from 'react-native-unistyles'
|
|
3
4
|
import {UnistylesVariants} from 'react-native-unistyles'
|
|
4
5
|
import {CheckboxDefaultVariants, CheckboxStyles} from '../theme/Checkbox.recipe'
|
|
5
6
|
import {PalettesWithNestedKeys} from '../style/varia/types'
|
|
6
7
|
import Svg, {Line} from 'react-native-svg'
|
|
8
|
+
import {getVariantValue} from '../style/varia/utils'
|
|
7
9
|
|
|
8
10
|
type CheckboxVariants = UnistylesVariants<typeof CheckboxStyles>
|
|
9
11
|
|
|
@@ -31,12 +33,18 @@ function Checkbox({
|
|
|
31
33
|
|
|
32
34
|
const isChecked = checked
|
|
33
35
|
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const checkColor = getVariantValue(
|
|
37
|
+
CheckboxStyles.check(colorPalette),
|
|
38
|
+
'variant',
|
|
39
|
+
variant,
|
|
40
|
+
'color',
|
|
41
|
+
)
|
|
42
|
+
const checkSize = getVariantValue(
|
|
43
|
+
CheckboxStyles.check(colorPalette),
|
|
44
|
+
'size',
|
|
45
|
+
size,
|
|
46
|
+
'width',
|
|
47
|
+
)
|
|
40
48
|
|
|
41
49
|
return (
|
|
42
50
|
<Pressable
|
|
@@ -58,14 +66,20 @@ const styles = StyleSheet.create({
|
|
|
58
66
|
container: {
|
|
59
67
|
flexDirection: 'row',
|
|
60
68
|
alignItems: 'center',
|
|
69
|
+
_web: {
|
|
70
|
+
_classNames: 'checkbox-container-base',
|
|
71
|
+
},
|
|
61
72
|
},
|
|
62
73
|
checkContainer: {
|
|
63
74
|
alignItems: 'center',
|
|
64
75
|
justifyContent: 'center',
|
|
76
|
+
_web: {
|
|
77
|
+
_classNames: 'badge-check-container-base',
|
|
78
|
+
},
|
|
65
79
|
},
|
|
66
80
|
})
|
|
67
81
|
|
|
68
|
-
export
|
|
82
|
+
export default Checkbox
|
|
69
83
|
|
|
70
84
|
const Check = ({size, color}: {size: string; color: string}) => {
|
|
71
85
|
return (
|
|
@@ -163,10 +163,18 @@ const styles = StyleSheet.create({
|
|
|
163
163
|
flex,
|
|
164
164
|
maxWidth: width,
|
|
165
165
|
maxHeight: height,
|
|
166
|
+
flexBasis: 'auto',
|
|
167
|
+
_web: {
|
|
168
|
+
_classNames: 'circle-progress-container',
|
|
169
|
+
},
|
|
166
170
|
}),
|
|
167
171
|
childContainer: {
|
|
172
|
+
flexBasis: 'auto',
|
|
168
173
|
justifyContent: 'center',
|
|
169
174
|
alignItems: 'center',
|
|
175
|
+
_web: {
|
|
176
|
+
_classNames: 'circle-progress-child-container',
|
|
177
|
+
},
|
|
170
178
|
},
|
|
171
179
|
})
|
|
172
180
|
|
|
@@ -26,20 +26,27 @@ const Divider = ({
|
|
|
26
26
|
const styles = StyleSheet.create(theme => ({
|
|
27
27
|
container: (size, axis, margin) => ({
|
|
28
28
|
flex: 1,
|
|
29
|
+
alignSelf: 'stretch',
|
|
29
30
|
flexDirection: 'row',
|
|
30
31
|
alignItems: 'center',
|
|
31
32
|
justifyContent: 'center',
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
maxWidth: axis === 'y' ? size : '100%',
|
|
34
|
+
maxHeight: axis === 'x' ? size : '100%',
|
|
34
35
|
marginHorizontal: axis === 'x' ? margin : 0,
|
|
35
36
|
marginVertical: axis === 'y' ? margin : 0,
|
|
37
|
+
_web: {
|
|
38
|
+
_classNames: 'divider-container-base',
|
|
39
|
+
},
|
|
36
40
|
}),
|
|
37
41
|
divider: (color, colorPalette, size, axis) => ({
|
|
38
|
-
width: axis === '
|
|
39
|
-
height: axis === '
|
|
42
|
+
width: axis === 'y' ? size : '100%',
|
|
43
|
+
height: axis === 'x' ? size : '100%',
|
|
40
44
|
backgroundColor: color
|
|
41
45
|
? resolveColor(color, theme.colors, colorPalette)
|
|
42
46
|
: theme.colors.fg.default,
|
|
47
|
+
_web: {
|
|
48
|
+
_classNames: 'divider-base',
|
|
49
|
+
},
|
|
43
50
|
}),
|
|
44
51
|
}))
|
|
45
52
|
|
|
@@ -4,7 +4,7 @@ import React, {
|
|
|
4
4
|
useImperativeHandle,
|
|
5
5
|
useMemo,
|
|
6
6
|
} from 'react'
|
|
7
|
-
import {TouchableWithoutFeedback} from 'react-native'
|
|
7
|
+
import {Platform, TouchableWithoutFeedback, View} from 'react-native'
|
|
8
8
|
import {Gesture, GestureDetector} from 'react-native-gesture-handler'
|
|
9
9
|
import Animated, {
|
|
10
10
|
measure,
|
|
@@ -16,11 +16,8 @@ import Animated, {
|
|
|
16
16
|
withSpring,
|
|
17
17
|
withTiming,
|
|
18
18
|
} from 'react-native-reanimated'
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
SlidingDrawerTokens,
|
|
22
|
-
SlidingDrawerStyles,
|
|
23
|
-
} from '../theme/SlidingDrawer.recipe'
|
|
19
|
+
import {scheduleOnRN, scheduleOnUI} from 'react-native-worklets'
|
|
20
|
+
import {DrawerTokens, DrawerStyles} from '../theme/Drawer.recipe'
|
|
24
21
|
import {PalettesWithNestedKeys} from '../style/varia/types'
|
|
25
22
|
import {
|
|
26
23
|
StyleSheet,
|
|
@@ -33,21 +30,21 @@ import {HStack} from '../patterns'
|
|
|
33
30
|
* Types
|
|
34
31
|
* ----------------------------*/
|
|
35
32
|
|
|
36
|
-
export type
|
|
33
|
+
export type DrawerRef = {
|
|
37
34
|
expand: () => void | null
|
|
38
35
|
collapse: () => void | null
|
|
39
36
|
snapTo: (point: number) => void | null
|
|
40
37
|
isCollapsed: () => boolean
|
|
41
38
|
}
|
|
42
39
|
|
|
43
|
-
type
|
|
40
|
+
type DrawerVariants = UnistylesVariants<typeof DrawerStyles>
|
|
44
41
|
|
|
45
|
-
type DrawerContextType =
|
|
42
|
+
type DrawerContextType = DrawerVariants & {
|
|
46
43
|
colorPalette: PalettesWithNestedKeys
|
|
47
44
|
overlayOpacity: SharedValue<number>
|
|
48
45
|
}
|
|
49
46
|
|
|
50
|
-
type DrawerRootProps =
|
|
47
|
+
type DrawerRootProps = DrawerVariants & {
|
|
51
48
|
colorPalette?: PalettesWithNestedKeys
|
|
52
49
|
children?: React.ReactNode
|
|
53
50
|
}
|
|
@@ -70,10 +67,10 @@ const useDrawer = () => {
|
|
|
70
67
|
|
|
71
68
|
const DrawerRoot = ({
|
|
72
69
|
colorPalette = 'accent',
|
|
73
|
-
variant =
|
|
70
|
+
variant = DrawerTokens.defaultProps.variant,
|
|
74
71
|
children,
|
|
75
72
|
}: DrawerRootProps) => {
|
|
76
|
-
|
|
73
|
+
DrawerStyles.useVariants({variant})
|
|
77
74
|
|
|
78
75
|
const overlayOpacity = useSharedValue(0)
|
|
79
76
|
const value = useMemo(
|
|
@@ -103,7 +100,7 @@ const DrawerPositioner = ({
|
|
|
103
100
|
axis: 'x' | 'y'
|
|
104
101
|
}) => {
|
|
105
102
|
const {variant} = useDrawer()
|
|
106
|
-
|
|
103
|
+
DrawerStyles.useVariants({variant})
|
|
107
104
|
|
|
108
105
|
type WithDirection = {direction?: 1 | -1; axis?: 'x' | 'y'}
|
|
109
106
|
|
|
@@ -121,7 +118,7 @@ const DrawerPositioner = ({
|
|
|
121
118
|
<HStack
|
|
122
119
|
style={[
|
|
123
120
|
styles.positioner,
|
|
124
|
-
|
|
121
|
+
DrawerStyles.positioner,
|
|
125
122
|
{
|
|
126
123
|
justifyContent:
|
|
127
124
|
axis === 'y'
|
|
@@ -148,10 +145,11 @@ const DrawerPositioner = ({
|
|
|
148
145
|
const AnimatedTouchable = Animated.createAnimatedComponent(
|
|
149
146
|
TouchableWithoutFeedback,
|
|
150
147
|
)
|
|
148
|
+
const AnimatedView = Animated.createAnimatedComponent(View)
|
|
151
149
|
|
|
152
150
|
const DrawerOverlay = ({onPress}: {onPress?: () => void}) => {
|
|
153
151
|
const {colorPalette, overlayOpacity, variant} = useDrawer()
|
|
154
|
-
|
|
152
|
+
DrawerStyles.useVariants({variant})
|
|
155
153
|
const visible = useSharedValue(0)
|
|
156
154
|
|
|
157
155
|
useAnimatedReaction(
|
|
@@ -172,11 +170,12 @@ const DrawerOverlay = ({onPress}: {onPress?: () => void}) => {
|
|
|
172
170
|
|
|
173
171
|
return (
|
|
174
172
|
<AnimatedTouchable onPress={onPress}>
|
|
175
|
-
<
|
|
173
|
+
<AnimatedView
|
|
176
174
|
style={[
|
|
177
175
|
StyleSheet.absoluteFillObject,
|
|
178
176
|
displayOverlayStyle,
|
|
179
|
-
|
|
177
|
+
DrawerStyles.overlay(colorPalette),
|
|
178
|
+
{pointerEvents: 'auto'},
|
|
180
179
|
]}
|
|
181
180
|
/>
|
|
182
181
|
</AnimatedTouchable>
|
|
@@ -192,13 +191,13 @@ type InternalDrawerSliderProps = {
|
|
|
192
191
|
direction: 1 | -1
|
|
193
192
|
lockAtEdges?: boolean
|
|
194
193
|
snapPoints?: number[] | ('hidden' | 'content')[]
|
|
195
|
-
animation?: keyof typeof
|
|
194
|
+
animation?: keyof typeof DrawerTokens.variants.animation
|
|
196
195
|
onExpand?: () => void
|
|
197
196
|
onCollapse?: () => void
|
|
198
197
|
onSnap?: (point: number) => void
|
|
199
198
|
allowGestures?: boolean
|
|
200
199
|
children?: React.ReactNode
|
|
201
|
-
ref?: React.RefObject<
|
|
200
|
+
ref?: React.RefObject<DrawerRef | null>
|
|
202
201
|
externalTranslate?: SharedValue<number>
|
|
203
202
|
}
|
|
204
203
|
|
|
@@ -216,7 +215,7 @@ const DrawerSliderInternal = ({
|
|
|
216
215
|
direction,
|
|
217
216
|
lockAtEdges = false,
|
|
218
217
|
snapPoints = ['hidden', 'content'],
|
|
219
|
-
animation =
|
|
218
|
+
animation = DrawerTokens.defaultProps.animation,
|
|
220
219
|
onExpand,
|
|
221
220
|
onCollapse,
|
|
222
221
|
onSnap,
|
|
@@ -227,14 +226,14 @@ const DrawerSliderInternal = ({
|
|
|
227
226
|
}: InternalDrawerSliderProps) => {
|
|
228
227
|
const {variant, colorPalette, overlayOpacity} = useDrawer()
|
|
229
228
|
|
|
230
|
-
|
|
229
|
+
DrawerStyles.useVariants({variant})
|
|
231
230
|
|
|
232
231
|
const screenHeight =
|
|
233
232
|
UnistylesRuntime.screen.height - UnistylesRuntime.insets.top
|
|
234
233
|
const screenWidth = UnistylesRuntime.screen.width
|
|
235
234
|
|
|
236
235
|
const animations = {withSpring, withTiming}
|
|
237
|
-
const animationVariant =
|
|
236
|
+
const animationVariant = DrawerTokens.variants.animation[animation]
|
|
238
237
|
const VELOCITY_THRESHOLD = 2000
|
|
239
238
|
|
|
240
239
|
const viewRef = useAnimatedRef<Animated.View>()
|
|
@@ -455,16 +454,17 @@ const DrawerSliderInternal = ({
|
|
|
455
454
|
|
|
456
455
|
return (
|
|
457
456
|
<GestureDetector gesture={slideGesture}>
|
|
458
|
-
<
|
|
457
|
+
<AnimatedView
|
|
459
458
|
ref={viewRef}
|
|
460
459
|
onLayout={onLayout}
|
|
461
460
|
style={[
|
|
462
461
|
styles.slider,
|
|
463
462
|
blockAnimatedStyle,
|
|
464
|
-
|
|
463
|
+
DrawerStyles.slider(colorPalette),
|
|
464
|
+
{pointerEvents: 'auto'},
|
|
465
465
|
]}>
|
|
466
466
|
{children}
|
|
467
|
-
</
|
|
467
|
+
</AnimatedView>
|
|
468
468
|
</GestureDetector>
|
|
469
469
|
)
|
|
470
470
|
}
|
|
@@ -485,6 +485,12 @@ const styles = StyleSheet.create((theme, rt) => ({
|
|
|
485
485
|
left: 0,
|
|
486
486
|
right: 0,
|
|
487
487
|
bottom: 0,
|
|
488
|
+
pointerEvents: 'box-none',
|
|
489
|
+
_web: {
|
|
490
|
+
pointerEvents: 'none',
|
|
491
|
+
overflow: 'hidden',
|
|
492
|
+
_classNames: 'drawer-positioner-base',
|
|
493
|
+
},
|
|
488
494
|
},
|
|
489
495
|
slider: {
|
|
490
496
|
flex: 1,
|
|
@@ -492,5 +498,8 @@ const styles = StyleSheet.create((theme, rt) => ({
|
|
|
492
498
|
alignItems: 'center',
|
|
493
499
|
justifyContent: 'flex-start',
|
|
494
500
|
zIndex: 100,
|
|
501
|
+
_web: {
|
|
502
|
+
_classNames: 'drawer-slider-base',
|
|
503
|
+
},
|
|
495
504
|
},
|
|
496
505
|
}))
|
package/lib/components/Field.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {TextStyle, View, type ColorValue} from 'react-native'
|
|
2
2
|
import Svg, {
|
|
3
3
|
Defs,
|
|
4
4
|
LinearGradient,
|
|
@@ -6,17 +6,25 @@ import Svg, {
|
|
|
6
6
|
Text,
|
|
7
7
|
type NumberProp,
|
|
8
8
|
} from 'react-native-svg'
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
UnistylesVariants,
|
|
11
|
+
withUnistyles,
|
|
12
|
+
StyleSheet,
|
|
13
|
+
} from 'react-native-unistyles'
|
|
10
14
|
import {gradientTextTokens} from '../theme/GradientText.recipe'
|
|
11
15
|
import {
|
|
12
16
|
NestedColorsType,
|
|
13
17
|
PalettesWithNestedKeys,
|
|
14
18
|
ThemeType,
|
|
15
19
|
} from '../style/varia/types'
|
|
16
|
-
import {
|
|
20
|
+
import {getVariantValue, resolveColor} from '../style/varia/utils'
|
|
17
21
|
import {ThemeColors} from '../style/varia/types'
|
|
22
|
+
import {TextStyles} from '../theme/Text.recipe'
|
|
23
|
+
|
|
24
|
+
type AllTextVariants = UnistylesVariants<typeof TextStyles>
|
|
25
|
+
type TextVariantsWithoutVariant = Omit<AllTextVariants, 'variant'>
|
|
18
26
|
|
|
19
|
-
|
|
27
|
+
type GradientTextProps = TextVariantsWithoutVariant & {
|
|
20
28
|
colorPalette: PalettesWithNestedKeys
|
|
21
29
|
variant?: keyof typeof gradientTextTokens.variants.variant
|
|
22
30
|
direction?: keyof typeof gradientTextTokens.variants.direction
|
|
@@ -26,7 +34,7 @@ interface GradientTextProps {
|
|
|
26
34
|
fontSizes: ThemeType['fontSizes']
|
|
27
35
|
fontSize?: TextStyle['fontSize']
|
|
28
36
|
children?: React.ReactNode
|
|
29
|
-
size?: keyof typeof gradientTextTokens.variants.size
|
|
37
|
+
// size?: keyof typeof gradientTextTokens.variants.size
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
const BaseGradientText = ({
|
|
@@ -41,6 +49,10 @@ const BaseGradientText = ({
|
|
|
41
49
|
children,
|
|
42
50
|
size = gradientTextTokens.defaultProps.size,
|
|
43
51
|
}: GradientTextProps) => {
|
|
52
|
+
TextStyles.useVariants({
|
|
53
|
+
size,
|
|
54
|
+
})
|
|
55
|
+
|
|
44
56
|
const colorValue = gradientTextTokens.variants.variant[variant]
|
|
45
57
|
|
|
46
58
|
const resolvedStartColor = resolveColor(
|
|
@@ -54,8 +66,19 @@ const BaseGradientText = ({
|
|
|
54
66
|
colorPalette,
|
|
55
67
|
)
|
|
56
68
|
|
|
57
|
-
const fontSizeValue = gradientTextTokens.variants.size[size].fontSize
|
|
58
|
-
const resolvedFontSize = fontSize || resolveFontSize(fontSizeValue, fontSizes)
|
|
69
|
+
// const fontSizeValue = gradientTextTokens.variants.size[size].fontSize
|
|
70
|
+
// const resolvedFontSize = fontSize || resolveFontSize(fontSizeValue, fontSizes)
|
|
71
|
+
|
|
72
|
+
const resolvedFontSize =
|
|
73
|
+
fontSize ||
|
|
74
|
+
getVariantValue(TextStyles.text(colorPalette), 'size', size, 'fontSize')
|
|
75
|
+
const resolvedFontWeight =
|
|
76
|
+
getVariantValue(
|
|
77
|
+
TextStyles.text(colorPalette),
|
|
78
|
+
'size',
|
|
79
|
+
size,
|
|
80
|
+
'fontWeight',
|
|
81
|
+
) || 400
|
|
59
82
|
|
|
60
83
|
const directionVariant = gradientTextTokens.variants.direction[direction]
|
|
61
84
|
|
|
@@ -77,10 +100,7 @@ const BaseGradientText = ({
|
|
|
77
100
|
<Text
|
|
78
101
|
fill="url(#gradient)"
|
|
79
102
|
fontSize={resolvedFontSize}
|
|
80
|
-
fontWeight={
|
|
81
|
-
(gradientTextTokens.variants.size[size] as {fontWeight?: number})
|
|
82
|
-
.fontWeight ?? 400
|
|
83
|
-
}
|
|
103
|
+
fontWeight={resolvedFontWeight}
|
|
84
104
|
x="50%"
|
|
85
105
|
y={resolvedFontSize}
|
|
86
106
|
textAnchor="middle">
|
|
@@ -95,9 +115,15 @@ const BaseGradientText = ({
|
|
|
95
115
|
const styles = StyleSheet.create({
|
|
96
116
|
root: {
|
|
97
117
|
flexDirection: 'row',
|
|
118
|
+
_web: {
|
|
119
|
+
_classNames: 'gradient_text-root-base',
|
|
120
|
+
},
|
|
98
121
|
},
|
|
99
122
|
innerContainer: {
|
|
100
123
|
width: '100%',
|
|
124
|
+
_web: {
|
|
125
|
+
_classNames: 'gradient-inner-container-base',
|
|
126
|
+
},
|
|
101
127
|
},
|
|
102
128
|
})
|
|
103
129
|
|