@hero-design/rn 8.25.3 → 8.26.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/.turbo/turbo-build.log +8 -9
- package/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/es/index.js +282 -186
- package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/lib/index.js +282 -186
- package/package.json +5 -5
- package/src/components/FAB/ActionGroup/ActionItem.tsx +6 -1
- package/src/components/FAB/ActionGroup/StyledActionItem.tsx +1 -4
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +374 -202
- package/src/components/FAB/ActionGroup/index.tsx +15 -9
- package/src/components/FAB/AnimatedFABIcon.tsx +5 -3
- package/src/components/FAB/FAB.tsx +16 -3
- package/src/components/FAB/StyledFAB.tsx +10 -3
- package/src/components/FAB/__tests__/__snapshots__/AnimatedFABIcon.spec.tsx.snap +4 -4
- package/src/components/FAB/__tests__/__snapshots__/StyledFAB.spec.tsx.snap +1 -2
- package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +74 -43
- package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
- package/src/components/Icon/IconList.ts +1 -0
- package/src/components/Switch/SelectorSwitch/Option.tsx +31 -5
- package/src/components/Switch/SelectorSwitch/StyledSelectorSwitch.tsx +18 -4
- package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/Option.spec.tsx.snap +25 -18
- package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/index.spec.tsx.snap +49 -18
- package/src/components/Switch/SelectorSwitch/index.tsx +81 -17
- package/src/components/Switch/index.tsx +1 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +7 -9
- package/src/theme/components/fab.ts +7 -9
- package/types/components/FAB/ActionGroup/ActionItem.d.ts +1 -0
- package/types/components/FAB/StyledFAB.d.ts +5 -1
- package/types/components/Icon/IconList.d.ts +1 -1
- package/types/components/Icon/index.d.ts +1 -1
- package/types/components/Icon/utils.d.ts +1 -1
- package/types/components/Switch/SelectorSwitch/Option.d.ts +4 -1
- package/types/components/Switch/SelectorSwitch/StyledSelectorSwitch.d.ts +15 -9
- package/types/components/Switch/SelectorSwitch/index.d.ts +1 -1
- package/types/theme/components/fab.d.ts +4 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
|
-
import { Animated, View } from 'react-native';
|
|
2
|
+
import { Animated, Easing, Platform, View } from 'react-native';
|
|
3
3
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
4
4
|
import ActionItem from './ActionItem';
|
|
5
5
|
import {
|
|
@@ -19,13 +19,18 @@ type ActionItemsContainerProps = {
|
|
|
19
19
|
const ActionItemsListComponent = ({
|
|
20
20
|
style,
|
|
21
21
|
items,
|
|
22
|
-
}: ActionItemsContainerProps) =>
|
|
23
|
-
|
|
24
|
-
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
}: ActionItemsContainerProps) => {
|
|
23
|
+
return (
|
|
24
|
+
<View style={style}>
|
|
25
|
+
{items?.map((itemProp) => (
|
|
26
|
+
<ActionItem
|
|
27
|
+
key={itemProp.key || `${itemProp.icon}_${itemProp.title}`}
|
|
28
|
+
{...itemProp}
|
|
29
|
+
/>
|
|
30
|
+
))}
|
|
31
|
+
</View>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
29
34
|
|
|
30
35
|
export interface ActionGroupProps {
|
|
31
36
|
/**
|
|
@@ -85,7 +90,8 @@ const ActionGroup = ({
|
|
|
85
90
|
useEffect(() => {
|
|
86
91
|
const animation = Animated.timing(tranlateXAnimation.current, {
|
|
87
92
|
toValue: active ? 1 : 0,
|
|
88
|
-
useNativeDriver:
|
|
93
|
+
useNativeDriver: Platform.OS === 'ios' || Platform.OS === 'android',
|
|
94
|
+
easing: Easing.inOut(Easing.cubic),
|
|
89
95
|
});
|
|
90
96
|
|
|
91
97
|
animation.start();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
|
-
import { Animated, StyleSheet } from 'react-native';
|
|
2
|
+
import { Animated, Easing, Platform, StyleSheet } from 'react-native';
|
|
3
3
|
import { StyledFABIcon } from './StyledFAB';
|
|
4
4
|
import type { IconProps } from '../Icon';
|
|
5
5
|
|
|
@@ -16,7 +16,9 @@ const AnimatedFABIcon = ({ active, ...iconProps }: Props) => {
|
|
|
16
16
|
useEffect(() => {
|
|
17
17
|
const animation = Animated.timing(rotateAnimation.current, {
|
|
18
18
|
toValue: active ? 1 : 0,
|
|
19
|
-
useNativeDriver:
|
|
19
|
+
useNativeDriver: Platform.OS === 'ios' || Platform.OS === 'android',
|
|
20
|
+
easing: Easing.inOut(Easing.ease),
|
|
21
|
+
duration: 300,
|
|
20
22
|
});
|
|
21
23
|
|
|
22
24
|
animation.start();
|
|
@@ -39,7 +41,7 @@ const AnimatedFABIcon = ({ active, ...iconProps }: Props) => {
|
|
|
39
41
|
},
|
|
40
42
|
])}
|
|
41
43
|
>
|
|
42
|
-
<AnimatedIcons {...iconProps} />
|
|
44
|
+
<AnimatedIcons size="xsmall" {...iconProps} />
|
|
43
45
|
</Animated.View>
|
|
44
46
|
);
|
|
45
47
|
};
|
|
@@ -3,7 +3,12 @@ import type { StyleProp, ViewStyle } from 'react-native';
|
|
|
3
3
|
import { useTheme } from '../../theme';
|
|
4
4
|
import type { IconName } from '../Icon';
|
|
5
5
|
import { AnimatedFABIcon } from './AnimatedFABIcon';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
StyledFAB,
|
|
8
|
+
StyledFABIcon,
|
|
9
|
+
StyledFABText,
|
|
10
|
+
StyledIconContainer,
|
|
11
|
+
} from './StyledFAB';
|
|
7
12
|
|
|
8
13
|
export interface FABProps {
|
|
9
14
|
/**
|
|
@@ -54,7 +59,13 @@ const IconOnlyContent = ({
|
|
|
54
59
|
}) => {
|
|
55
60
|
if (animated) {
|
|
56
61
|
return (
|
|
57
|
-
<
|
|
62
|
+
<StyledIconContainer>
|
|
63
|
+
<AnimatedFABIcon
|
|
64
|
+
active={active}
|
|
65
|
+
icon={icon}
|
|
66
|
+
testID="animated-fab-icon"
|
|
67
|
+
/>
|
|
68
|
+
</StyledIconContainer>
|
|
58
69
|
);
|
|
59
70
|
}
|
|
60
71
|
return <StyledFABIcon icon={icon} testID="styled-fab-icon" />;
|
|
@@ -68,7 +79,9 @@ const IconWithTextContent = ({
|
|
|
68
79
|
title?: string;
|
|
69
80
|
}) => (
|
|
70
81
|
<>
|
|
71
|
-
<
|
|
82
|
+
<StyledIconContainer>
|
|
83
|
+
<StyledFABIcon size="xsmall" icon={icon} testID="styled-fab-icon" />
|
|
84
|
+
</StyledIconContainer>
|
|
72
85
|
<StyledFABText>{title}</StyledFABText>
|
|
73
86
|
</>
|
|
74
87
|
);
|
|
@@ -4,6 +4,7 @@ import { TouchableHighlight } from 'react-native';
|
|
|
4
4
|
import type { IconProps } from '../Icon';
|
|
5
5
|
import Icon from '../Icon';
|
|
6
6
|
import Typography from '../Typography';
|
|
7
|
+
import Box from '../Box';
|
|
7
8
|
|
|
8
9
|
const StyledFAB = styled(TouchableHighlight)<TouchableHighlightProps>(
|
|
9
10
|
({ theme }) => ({
|
|
@@ -12,8 +13,7 @@ const StyledFAB = styled(TouchableHighlight)<TouchableHighlightProps>(
|
|
|
12
13
|
alignItems: 'center',
|
|
13
14
|
justifyContent: 'center',
|
|
14
15
|
alignSelf: 'flex-start',
|
|
15
|
-
|
|
16
|
-
paddingVertical: theme.__hd__.fab.space.containerPaddingVertical,
|
|
16
|
+
padding: theme.__hd__.fab.space.containerPadding,
|
|
17
17
|
flexDirection: 'row',
|
|
18
18
|
elevation: theme.__hd__.fab.shadows.elevation,
|
|
19
19
|
shadowColor: theme.__hd__.fab.colors.shadow,
|
|
@@ -40,4 +40,11 @@ const StyledFABText = styled(Typography.Text)<TextProps>(({ theme }) => ({
|
|
|
40
40
|
marginHorizontal: theme.__hd__.fab.space.titleMarginHorizontal,
|
|
41
41
|
}));
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
const StyledIconContainer = styled(Box)(({ theme }) => ({
|
|
44
|
+
width: theme.__hd__.fab.sizes.iconContainerWidth,
|
|
45
|
+
height: theme.__hd__.fab.sizes.iconContainerHeight,
|
|
46
|
+
justifyContent: 'center',
|
|
47
|
+
alignItems: 'center',
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
export { StyledFAB, StyledFABIcon, StyledFABText, StyledIconContainer };
|
|
@@ -19,7 +19,7 @@ exports[`AnimatedFABIcon renders correctly when isActive is false 1`] = `
|
|
|
19
19
|
Array [
|
|
20
20
|
Object {
|
|
21
21
|
"color": "#001f23",
|
|
22
|
-
"fontSize":
|
|
22
|
+
"fontSize": 16,
|
|
23
23
|
},
|
|
24
24
|
Array [
|
|
25
25
|
Object {
|
|
@@ -33,7 +33,7 @@ exports[`AnimatedFABIcon renders correctly when isActive is false 1`] = `
|
|
|
33
33
|
]
|
|
34
34
|
}
|
|
35
35
|
themeIntent="text"
|
|
36
|
-
themeSize="
|
|
36
|
+
themeSize="xsmall"
|
|
37
37
|
/>
|
|
38
38
|
</View>
|
|
39
39
|
`;
|
|
@@ -57,7 +57,7 @@ exports[`AnimatedFABIcon renders correctly when isActive is true 1`] = `
|
|
|
57
57
|
Array [
|
|
58
58
|
Object {
|
|
59
59
|
"color": "#001f23",
|
|
60
|
-
"fontSize":
|
|
60
|
+
"fontSize": 16,
|
|
61
61
|
},
|
|
62
62
|
Array [
|
|
63
63
|
Object {
|
|
@@ -71,7 +71,7 @@ exports[`AnimatedFABIcon renders correctly when isActive is true 1`] = `
|
|
|
71
71
|
]
|
|
72
72
|
}
|
|
73
73
|
themeIntent="text"
|
|
74
|
-
themeSize="
|
|
74
|
+
themeSize="xsmall"
|
|
75
75
|
/>
|
|
76
76
|
</View>
|
|
77
77
|
`;
|
|
@@ -21,8 +21,7 @@ exports[`StyledFAB renders correctly 1`] = `
|
|
|
21
21
|
"elevation": 2,
|
|
22
22
|
"flexDirection": "row",
|
|
23
23
|
"justifyContent": "center",
|
|
24
|
-
"
|
|
25
|
-
"paddingVertical": 16,
|
|
24
|
+
"padding": 20,
|
|
26
25
|
"shadowColor": "#001f23",
|
|
27
26
|
"shadowOffset": Object {
|
|
28
27
|
"height": 2,
|
|
@@ -21,8 +21,7 @@ exports[`FAB when animated is false renders StyledFABIcon 1`] = `
|
|
|
21
21
|
"elevation": 2,
|
|
22
22
|
"flexDirection": "row",
|
|
23
23
|
"justifyContent": "center",
|
|
24
|
-
"
|
|
25
|
-
"paddingVertical": 16,
|
|
24
|
+
"padding": 20,
|
|
26
25
|
"shadowColor": "#001f23",
|
|
27
26
|
"shadowOffset": Object {
|
|
28
27
|
"height": 2,
|
|
@@ -84,8 +83,7 @@ exports[`FAB when animated is true renders animatedFABIcon 1`] = `
|
|
|
84
83
|
"elevation": 2,
|
|
85
84
|
"flexDirection": "row",
|
|
86
85
|
"justifyContent": "center",
|
|
87
|
-
"
|
|
88
|
-
"paddingVertical": 16,
|
|
86
|
+
"padding": 20,
|
|
89
87
|
"shadowColor": "#001f23",
|
|
90
88
|
"shadowOffset": Object {
|
|
91
89
|
"height": 2,
|
|
@@ -101,40 +99,57 @@ exports[`FAB when animated is true renders animatedFABIcon 1`] = `
|
|
|
101
99
|
}
|
|
102
100
|
>
|
|
103
101
|
<View
|
|
104
|
-
collapsable={false}
|
|
105
102
|
style={
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
Array [
|
|
104
|
+
Object {},
|
|
105
|
+
Array [
|
|
108
106
|
Object {
|
|
109
|
-
"
|
|
107
|
+
"alignItems": "center",
|
|
108
|
+
"height": 24,
|
|
109
|
+
"justifyContent": "center",
|
|
110
|
+
"width": 24,
|
|
110
111
|
},
|
|
112
|
+
undefined,
|
|
111
113
|
],
|
|
112
|
-
|
|
114
|
+
]
|
|
113
115
|
}
|
|
114
116
|
>
|
|
115
|
-
<
|
|
116
|
-
|
|
117
|
+
<View
|
|
118
|
+
collapsable={false}
|
|
117
119
|
style={
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"color": "#001f23",
|
|
121
|
-
"fontSize": 24,
|
|
122
|
-
},
|
|
123
|
-
Array [
|
|
120
|
+
Object {
|
|
121
|
+
"transform": Array [
|
|
124
122
|
Object {
|
|
125
|
-
"
|
|
126
|
-
"lineHeight": 24,
|
|
127
|
-
"textAlign": "center",
|
|
128
|
-
"textAlignVertical": "center",
|
|
123
|
+
"rotate": "0deg",
|
|
129
124
|
},
|
|
130
|
-
Object {},
|
|
131
125
|
],
|
|
132
|
-
|
|
126
|
+
}
|
|
133
127
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
128
|
+
>
|
|
129
|
+
<HeroIcon
|
|
130
|
+
name="add"
|
|
131
|
+
style={
|
|
132
|
+
Array [
|
|
133
|
+
Object {
|
|
134
|
+
"color": "#001f23",
|
|
135
|
+
"fontSize": 16,
|
|
136
|
+
},
|
|
137
|
+
Array [
|
|
138
|
+
Object {
|
|
139
|
+
"color": "#ffffff",
|
|
140
|
+
"lineHeight": 24,
|
|
141
|
+
"textAlign": "center",
|
|
142
|
+
"textAlignVertical": "center",
|
|
143
|
+
},
|
|
144
|
+
Object {},
|
|
145
|
+
],
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
testID="animated-fab-icon"
|
|
149
|
+
themeIntent="text"
|
|
150
|
+
themeSize="xsmall"
|
|
151
|
+
/>
|
|
152
|
+
</View>
|
|
138
153
|
</View>
|
|
139
154
|
</View>
|
|
140
155
|
`;
|
|
@@ -160,8 +175,7 @@ exports[`FAB when title has value renders correctly 1`] = `
|
|
|
160
175
|
"elevation": 2,
|
|
161
176
|
"flexDirection": "row",
|
|
162
177
|
"justifyContent": "center",
|
|
163
|
-
"
|
|
164
|
-
"paddingVertical": 16,
|
|
178
|
+
"padding": 20,
|
|
165
179
|
"shadowColor": "#001f23",
|
|
166
180
|
"shadowOffset": Object {
|
|
167
181
|
"height": 2,
|
|
@@ -176,29 +190,46 @@ exports[`FAB when title has value renders correctly 1`] = `
|
|
|
176
190
|
]
|
|
177
191
|
}
|
|
178
192
|
>
|
|
179
|
-
<
|
|
180
|
-
name="pencil"
|
|
193
|
+
<View
|
|
181
194
|
style={
|
|
182
195
|
Array [
|
|
183
|
-
Object {
|
|
184
|
-
"color": "#001f23",
|
|
185
|
-
"fontSize": 16,
|
|
186
|
-
},
|
|
196
|
+
Object {},
|
|
187
197
|
Array [
|
|
188
198
|
Object {
|
|
189
|
-
"
|
|
190
|
-
"
|
|
191
|
-
"
|
|
192
|
-
"
|
|
199
|
+
"alignItems": "center",
|
|
200
|
+
"height": 24,
|
|
201
|
+
"justifyContent": "center",
|
|
202
|
+
"width": 24,
|
|
193
203
|
},
|
|
194
204
|
undefined,
|
|
195
205
|
],
|
|
196
206
|
]
|
|
197
207
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
208
|
+
>
|
|
209
|
+
<HeroIcon
|
|
210
|
+
name="pencil"
|
|
211
|
+
style={
|
|
212
|
+
Array [
|
|
213
|
+
Object {
|
|
214
|
+
"color": "#001f23",
|
|
215
|
+
"fontSize": 16,
|
|
216
|
+
},
|
|
217
|
+
Array [
|
|
218
|
+
Object {
|
|
219
|
+
"color": "#ffffff",
|
|
220
|
+
"lineHeight": 24,
|
|
221
|
+
"textAlign": "center",
|
|
222
|
+
"textAlignVertical": "center",
|
|
223
|
+
},
|
|
224
|
+
undefined,
|
|
225
|
+
],
|
|
226
|
+
]
|
|
227
|
+
}
|
|
228
|
+
testID="styled-fab-icon"
|
|
229
|
+
themeIntent="text"
|
|
230
|
+
themeSize="xsmall"
|
|
231
|
+
/>
|
|
232
|
+
</View>
|
|
202
233
|
<Text
|
|
203
234
|
allowFontScaling={false}
|
|
204
235
|
style={
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"activate":59000,"add-emoji":59001,"add-person":59002,"adjustment":59003,"alignment":59004,"antenna":59005,"archive":59006,"assignment-warning":59007,"bank":59008,"bell":59009,"billing":59010,"bolt":59011,"bookmark-added":59012,"bookmark":59013,"box-check":59014,"box":59015,"bpay":59016,"buildings":59017,"cake":59018,"calendar-clock":59019,"calendar":59020,"candy-box-menu":59021,"caret-down-small":59022,"caret-down":59023,"caret-left-small":59024,"caret-left":59025,"caret-right-small":59026,"caret-right":59027,"caret-up-small":59028,"caret-up":59029,"check-radio":59030,"circle-add":59031,"circle-cancel":59032,"circle-check":59033,"circle-down":59034,"circle-info":59035,"circle-left":59036,"circle-ok":59037,"circle-pencil":59038,"circle-question":59039,"circle-remove":59040,"circle-right":59041,"circle-up":59042,"circle-warning":59043,"clock-3":59044,"clock":59045,"cloud-download":59046,"cloud-upload":59047,"cog":59048,"coin":59049,"contacts":59050,"credit-card":59051,"diamond":59052,"direction-arrows":59053,"directory":59054,"document":59055,"dollar-coin-shine":59056,"double-buildings":59057,"edit-template":59058,"envelope":59059,"exclude":59060,"expense":59061,"eye-circle":59062,"eye-invisible":59063,"eye":59064,"face-meh":59065,"face-sad":59066,"face-smiley":59067,"feed":59068,"feedbacks":59069,"file-certified":59070,"file-clone":59071,"file-copy":59072,"file-csv":59073,"file-dispose":59074,"file-doc":59075,"file-excel":59076,"file-export":59077,"file-lock":59078,"file-pdf":59079,"file-powerpoint":59080,"file-search":59081,"file-secured":59082,"file-sheets":59083,"file-slide":59084,"file-verified":59085,"file-word":59086,"file":59087,"filter":59088,"folder-user":59089,"folder":59090,"format-bold":59091,"format-heading1":59092,"format-heading2":59093,"format-italic":59094,"format-list-bulleted":59095,"format-list-numbered":59096,"format-underlined":59097,"funnel-filter":59098,"global-dollar":59099,"globe":59100,"graduation-cap":59101,"graph":59102,"happy-sun":59103,"health-bag":59104,"heart":59105,"home":59106,"image":59107,"import":59108,"incident-siren":59109,"instapay":59110,"list":59111,"loading-2":59112,"loading":59113,"location":59114,"lock":59115,"looks-one":59116,"looks-two":59117,"media-content":59118,"menu":59119,"money-notes":59120,"moneybag":59121,"moon":59122,"multiple-stars":59123,"multiple-users":59124,"node":59125,"open-folder":59126,"paperclip":59127,"payment-summary":59128,"pencil":59129,"phone":59130,"piggy-bank":59131,"plane-up":59132,"plane":59133,"play-circle":59134,"print":59135,"raising-hands":59136,"reply-arrow":59137,"reply":59138,"reschedule":59139,"rostering":59140,"save":59141,"schedule-send":59142,"schedule":59143,"search-person":59144,"send":59145,"speaker-active":59146,"speaker":59147,"star-award":59148,"star-badge":59149,"star-circle":59150,"star-medal":59151,"star":59152,"steps-circle":59153,"stopwatch":59154,"suitcase":59155,"surfing":59156,"survey":59157,"swag-pillar-benefit":59158,"swag-pillar-career":59159,"swag-pillar-money":59160,"swag-pillar-work":59161,"swag":59162,"switch":59163,"tag":59164,"target":59165,"teams":59166,"timesheet":59167,"touch-id":59168,"trash-bin":59169,"unlock":59170,"user":59171,"video-1":59172,"video-2":59173,"wallet":59174,"warning":59175,"activate-outlined":59176,"add-credit-card-outlined":59177,"add-person-outlined":59178,"add-section-outlined":59179,"add-time-outlined":59180,"add":59181,"adjustment-outlined":59182,"alignment-2-outlined":59183,"alignment-outlined":59184,"all-caps":59185,"arrow-down":59186,"arrow-downwards":59187,"arrow-left":59188,"arrow-leftwards":59189,"arrow-right":59190,"arrow-rightwards":59191,"arrow-up":59192,"arrow-upwards":59193,"article-outlined":59194,"at-sign":59195,"auto-graph-outlined":59196,"beer-outlined":59197,"bell-active-outlined":59198,"bell-outlined":59199,"bell-slash-outlined":59200,"billing-outlined":59201,"body-outlined":59202,"bold":59203,"book-outlined":59204,"bookmark-added-outlined":59205,"bookmark-outlined":59206,"box-check-outlined":59207,"box-outlined":59208,"bullet-points":59209,"cake-outlined":59210,"calendar-dates-outlined":59211,"calendar-star-outlined":59212,"call-split-outlined":59213,"camera-outlined":59214,"cancel":59215,"car-forward-outlined":59216,"charging-station-outlined":59217,"chat-bubble-outlined":59218,"chat-unread-outlined":59219,"checkmark":59220,"circle-add-outlined":59221,"circle-cancel-outlined":59222,"circle-down-outlined":59223,"circle-info-outlined":59224,"circle-left-outlined":59225,"circle-ok-outlined":59226,"circle-question-outlined":59227,"circle-remove-outlined":59228,"circle-right-outlined":59229,"circle-up-outlined":59230,"circle-warning-outlined":59231,"clock-2-outlined":59232,"clock-outlined":59233,"cog-outlined":59234,"coin-outlined":59235,"coin-super-outlined":59236,"comment-outlined":59237,"contacts-outlined":59238,"contacts-user-outlined":59239,"credit-card-outlined":59240,"cup-outlined":59241,"dentistry-outlined":59242,"direction-arrows-outlined":59243,"directory-outlined":59244,"document-outlined":59245,"dollar-box-outlined":59246,"dollar-card-outlined":59247,"dollar-coin-shine-outlined":59248,"dollar-credit-card-outlined":59249,"dollar-sign":59250,"double-buildings-outlined":59251,"double-left-arrows":59252,"double-right-arrows":59253,"download-outlined":59254,"edit-template-outlined":
|
|
1
|
+
{"activate":59000,"add-emoji":59001,"add-person":59002,"adjustment":59003,"alignment":59004,"antenna":59005,"archive":59006,"assignment-warning":59007,"bank":59008,"bell":59009,"billing":59010,"bolt":59011,"bookmark-added":59012,"bookmark":59013,"box-check":59014,"box":59015,"bpay":59016,"buildings":59017,"cake":59018,"calendar-clock":59019,"calendar":59020,"candy-box-menu":59021,"caret-down-small":59022,"caret-down":59023,"caret-left-small":59024,"caret-left":59025,"caret-right-small":59026,"caret-right":59027,"caret-up-small":59028,"caret-up":59029,"check-radio":59030,"circle-add":59031,"circle-cancel":59032,"circle-check":59033,"circle-down":59034,"circle-info":59035,"circle-left":59036,"circle-ok":59037,"circle-pencil":59038,"circle-question":59039,"circle-remove":59040,"circle-right":59041,"circle-up":59042,"circle-warning":59043,"clock-3":59044,"clock":59045,"cloud-download":59046,"cloud-upload":59047,"cog":59048,"coin":59049,"contacts":59050,"credit-card":59051,"diamond":59052,"direction-arrows":59053,"directory":59054,"document":59055,"dollar-coin-shine":59056,"double-buildings":59057,"edit-template":59058,"envelope":59059,"exclude":59060,"expense":59061,"eye-circle":59062,"eye-invisible":59063,"eye":59064,"face-meh":59065,"face-sad":59066,"face-smiley":59067,"feed":59068,"feedbacks":59069,"file-certified":59070,"file-clone":59071,"file-copy":59072,"file-csv":59073,"file-dispose":59074,"file-doc":59075,"file-excel":59076,"file-export":59077,"file-lock":59078,"file-pdf":59079,"file-powerpoint":59080,"file-search":59081,"file-secured":59082,"file-sheets":59083,"file-slide":59084,"file-verified":59085,"file-word":59086,"file":59087,"filter":59088,"folder-user":59089,"folder":59090,"format-bold":59091,"format-heading1":59092,"format-heading2":59093,"format-italic":59094,"format-list-bulleted":59095,"format-list-numbered":59096,"format-underlined":59097,"funnel-filter":59098,"global-dollar":59099,"globe":59100,"graduation-cap":59101,"graph":59102,"happy-sun":59103,"health-bag":59104,"heart":59105,"home":59106,"image":59107,"import":59108,"incident-siren":59109,"instapay":59110,"list":59111,"loading-2":59112,"loading":59113,"location":59114,"lock":59115,"looks-one":59116,"looks-two":59117,"media-content":59118,"menu":59119,"money-notes":59120,"moneybag":59121,"moon":59122,"multiple-stars":59123,"multiple-users":59124,"node":59125,"open-folder":59126,"paperclip":59127,"payment-summary":59128,"pencil":59129,"phone":59130,"piggy-bank":59131,"plane-up":59132,"plane":59133,"play-circle":59134,"print":59135,"raising-hands":59136,"reply-arrow":59137,"reply":59138,"reschedule":59139,"rostering":59140,"save":59141,"schedule-send":59142,"schedule":59143,"search-person":59144,"send":59145,"speaker-active":59146,"speaker":59147,"star-award":59148,"star-badge":59149,"star-circle":59150,"star-medal":59151,"star":59152,"steps-circle":59153,"stopwatch":59154,"suitcase":59155,"surfing":59156,"survey":59157,"swag-pillar-benefit":59158,"swag-pillar-career":59159,"swag-pillar-money":59160,"swag-pillar-work":59161,"swag":59162,"switch":59163,"tag":59164,"target":59165,"teams":59166,"timesheet":59167,"touch-id":59168,"trash-bin":59169,"unlock":59170,"user":59171,"video-1":59172,"video-2":59173,"wallet":59174,"warning":59175,"activate-outlined":59176,"add-credit-card-outlined":59177,"add-person-outlined":59178,"add-section-outlined":59179,"add-time-outlined":59180,"add":59181,"adjustment-outlined":59182,"alignment-2-outlined":59183,"alignment-outlined":59184,"all-caps":59185,"arrow-down":59186,"arrow-downwards":59187,"arrow-left":59188,"arrow-leftwards":59189,"arrow-right":59190,"arrow-rightwards":59191,"arrow-up":59192,"arrow-upwards":59193,"article-outlined":59194,"at-sign":59195,"auto-graph-outlined":59196,"beer-outlined":59197,"bell-active-outlined":59198,"bell-outlined":59199,"bell-slash-outlined":59200,"billing-outlined":59201,"body-outlined":59202,"bold":59203,"book-outlined":59204,"bookmark-added-outlined":59205,"bookmark-outlined":59206,"box-check-outlined":59207,"box-outlined":59208,"bullet-points":59209,"cake-outlined":59210,"calendar-dates-outlined":59211,"calendar-star-outlined":59212,"call-split-outlined":59213,"camera-outlined":59214,"cancel":59215,"car-forward-outlined":59216,"charging-station-outlined":59217,"chat-bubble-outlined":59218,"chat-unread-outlined":59219,"checkmark":59220,"circle-add-outlined":59221,"circle-cancel-outlined":59222,"circle-down-outlined":59223,"circle-info-outlined":59224,"circle-left-outlined":59225,"circle-ok-outlined":59226,"circle-question-outlined":59227,"circle-remove-outlined":59228,"circle-right-outlined":59229,"circle-up-outlined":59230,"circle-warning-outlined":59231,"clock-2-outlined":59232,"clock-outlined":59233,"cog-outlined":59234,"coin-outlined":59235,"coin-super-outlined":59236,"comment-outlined":59237,"contacts-outlined":59238,"contacts-user-outlined":59239,"credit-card-outlined":59240,"cup-outlined":59241,"dentistry-outlined":59242,"direction-arrows-outlined":59243,"directory-outlined":59244,"document-outlined":59245,"dollar-box-outlined":59246,"dollar-card-outlined":59247,"dollar-coin-shine-outlined":59248,"dollar-credit-card-outlined":59249,"dollar-sign":59250,"double-buildings-outlined":59251,"double-left-arrows":59252,"double-right-arrows":59253,"download-box-outlined":59254,"download-outlined":59255,"edit-template-outlined":59256,"email-outlined":59257,"enter-arrow":59258,"envelope-outlined":59259,"expense-outlined":59260,"explore-outlined":59261,"external-link":59262,"eye-invisible-outlined":59263,"eye-outlined":59264,"face-id":59265,"face-meh-outlined":59266,"face-open-smiley-outlined":59267,"face-sad-outlined":59268,"face-smiley-outlined":59269,"fastfood-outlined":59270,"feed-outlined":59271,"file-certified-outlined":59272,"file-clone-outlined":59273,"file-copy-outlined":59274,"file-dispose-outlined":59275,"file-dollar-certified-outlined":59276,"file-dollar-outlined":59277,"file-download-outlined":59278,"file-export-outlined":59279,"file-lock-outlined":59280,"file-outlined":59281,"file-search-outlined":59282,"file-secured-outlined":59283,"file-statutory-outlined":59284,"file-verified-outlined":59285,"filter-outlined":59286,"folder-outlined":59287,"folder-user-outlined":59288,"form-outlined":59289,"funnel-filter-outline":59290,"graph-outlined":59291,"hand-holding-user-outlined":59292,"happy-sun-outlined":59293,"health-bag-outlined":59294,"heart-outlined":59295,"home-active-outlined":59296,"home-outlined":59297,"id-card-outlined":59298,"image-outlined":59299,"import-outlined":59300,"instapay-outlined":59301,"italic":59302,"link-1":59303,"link-2":59304,"list-outlined":59305,"live-help-outlined":59306,"location-on-outlined":59307,"location-outlined":59308,"lock-outlined":59309,"locked-file-outlined":59310,"log-out":59311,"media-content-outlined":59312,"menu-close":59313,"menu-expand":59314,"menu-fold-outlined":59315,"menu-unfold-outlined":59316,"moneybag-outlined":59317,"moon-outlined":59318,"more-horizontal":59319,"more-vertical":59320,"multiple-folders-outlined":59321,"multiple-users-outlined":59322,"near-me-outlined":59323,"node-outlined":59324,"number-points":59325,"number":59326,"overview-outlined":59327,"payment-summary-outlined":59328,"payslip-outlined":59329,"pencil-outlined":59330,"percentage":59331,"phone-outlined":59332,"piggy-bank-outlined":59333,"plane-outlined":59334,"play-circle-outlined":59335,"print-outlined":59336,"qr-code-outlined":59337,"qualification-outlined":59338,"re-assign":59339,"redeem":59340,"refresh":59341,"remove":59342,"reply-outlined":59343,"restart":59344,"return-arrow":59345,"rostering-outlined":59346,"save-outlined":59347,"schedule-outlined":59348,"search-outlined":59349,"search-secured-outlined":59350,"send-outlined":59351,"share-1":59352,"share-2":59353,"share-outlined":59354,"show-chart-outlined":59355,"single-down-arrow":59356,"single-left-arrow":59357,"single-right-arrow":59358,"single-up-arrow":59359,"speaker-active-outlined":59360,"speaker-outlined":59361,"star-circle-outlined":59362,"star-outlined":59363,"stopwatch-outlined":59364,"strikethrough":59365,"styler-outlined":59366,"suitcase-clock-outlined":59367,"suitcase-outlined":59368,"survey-outlined":59369,"switch-outlined":59370,"sync":59371,"tag-outlined":59372,"target-outlined":59373,"tennis-outlined":59374,"ticket-outlined":59375,"timesheet-outlined":59376,"today-outlined":59377,"transfer":59378,"trash-bin-outlined":59379,"umbrela-outlined":59380,"unavailable":59381,"underline":59382,"union-outlined":59383,"unlock-outlined":59384,"upload-outlined":59385,"user-circle-outlined":59386,"user-gear-outlined":59387,"user-outlined":59388,"user-rectangle-outlined":59389,"video-1-outlined":59390,"video-2-outlined":59391,"volunteer-outlined":59392,"wallet-outlined":59393}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { ReactElement } from 'react';
|
|
2
|
+
import React, { useEffect, useRef } from 'react';
|
|
3
|
+
import { Animated, Easing, LayoutChangeEvent, Platform } from 'react-native';
|
|
3
4
|
import type { BadgeConfigType, OptionType } from '.';
|
|
4
5
|
import { useTheme } from '../../../theme';
|
|
5
|
-
import { StyledIconWrapper, StyledTextWrapper } from './StyledSelectorSwitch';
|
|
6
|
-
import Typography from '../../Typography';
|
|
7
6
|
import Badge from '../../Badge';
|
|
8
7
|
import Icon from '../../Icon';
|
|
8
|
+
import Typography from '../../Typography';
|
|
9
|
+
import { StyledIconWrapper, StyledTextWrapper } from './StyledSelectorSwitch';
|
|
9
10
|
|
|
10
11
|
export const OptionContent = ({
|
|
11
12
|
content,
|
|
@@ -39,12 +40,34 @@ const Option = <T,>({
|
|
|
39
40
|
icon,
|
|
40
41
|
badge,
|
|
41
42
|
selected,
|
|
43
|
+
onLayout,
|
|
44
|
+
index = 0,
|
|
42
45
|
}: Pick<OptionType<T>, 'text' | 'icon' | 'badge'> & {
|
|
43
46
|
selected: boolean;
|
|
47
|
+
onLayout?: (e: LayoutChangeEvent) => void;
|
|
48
|
+
index?: number;
|
|
44
49
|
}): ReactElement => {
|
|
50
|
+
const animatedValue = useRef(new Animated.Value(1)).current;
|
|
51
|
+
const translateX = animatedValue.interpolate({
|
|
52
|
+
inputRange: [0, 1],
|
|
53
|
+
outputRange: index === 1 ? [-5, 0] : [5, 0],
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
Animated.timing(animatedValue, {
|
|
58
|
+
toValue: selected ? 1 : 0,
|
|
59
|
+
duration: 200,
|
|
60
|
+
easing: Easing.linear,
|
|
61
|
+
useNativeDriver: Platform.OS === 'ios' || Platform.OS === 'android',
|
|
62
|
+
}).start();
|
|
63
|
+
}, [selected]);
|
|
64
|
+
|
|
45
65
|
if (selected) {
|
|
46
66
|
return (
|
|
47
|
-
<StyledTextWrapper
|
|
67
|
+
<StyledTextWrapper
|
|
68
|
+
style={{ transform: [{ translateX }] }}
|
|
69
|
+
onLayout={onLayout}
|
|
70
|
+
>
|
|
48
71
|
<OptionContent
|
|
49
72
|
content={<Typography.Text fontSize="large">{text}</Typography.Text>}
|
|
50
73
|
badge={badge}
|
|
@@ -54,7 +77,10 @@ const Option = <T,>({
|
|
|
54
77
|
}
|
|
55
78
|
|
|
56
79
|
return (
|
|
57
|
-
<StyledIconWrapper
|
|
80
|
+
<StyledIconWrapper
|
|
81
|
+
style={{ transform: [{ translateX }] }}
|
|
82
|
+
onLayout={onLayout}
|
|
83
|
+
>
|
|
58
84
|
<OptionContent content={<Icon icon={icon} />} badge={badge} />
|
|
59
85
|
</StyledIconWrapper>
|
|
60
86
|
);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import styled from '@emotion/native';
|
|
2
|
-
import { View } from 'react-native';
|
|
2
|
+
import { View, Animated } from 'react-native';
|
|
3
|
+
|
|
4
|
+
const AnimatedView = Animated.createAnimatedComponent(View);
|
|
3
5
|
|
|
4
6
|
export const StyledWrapper = styled(View)(({ theme }) => ({
|
|
5
7
|
flexDirection: 'row',
|
|
@@ -8,18 +10,30 @@ export const StyledWrapper = styled(View)(({ theme }) => ({
|
|
|
8
10
|
borderRadius: theme.__hd__.switch.radii.selector.default,
|
|
9
11
|
backgroundColor: theme.__hd__.switch.colors.selector.background,
|
|
10
12
|
padding: theme.__hd__.switch.spaces.selector.wrapperPadding,
|
|
13
|
+
position: 'relative',
|
|
11
14
|
}));
|
|
12
15
|
|
|
13
|
-
export const StyledTextWrapper = styled(
|
|
16
|
+
export const StyledTextWrapper = styled(AnimatedView)(({ theme }) => ({
|
|
14
17
|
flex: 1,
|
|
15
18
|
borderRadius: theme.__hd__.switch.radii.selector.default,
|
|
16
|
-
backgroundColor: theme.__hd__.switch.colors.selector.textBackground,
|
|
17
19
|
justifyContent: 'center',
|
|
18
20
|
alignItems: 'center',
|
|
21
|
+
zIndex: 1,
|
|
19
22
|
}));
|
|
20
23
|
|
|
21
|
-
export const StyledIconWrapper = styled(
|
|
24
|
+
export const StyledIconWrapper = styled(AnimatedView)(({ theme }) => ({
|
|
22
25
|
paddingHorizontal: theme.__hd__.switch.spaces.selector.iconPadding,
|
|
23
26
|
justifyContent: 'center',
|
|
24
27
|
alignItems: 'center',
|
|
28
|
+
zIndex: 1,
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
export const StyledKnot = styled(AnimatedView)(({ theme }) => ({
|
|
32
|
+
borderRadius: theme.__hd__.switch.radii.selector.default,
|
|
33
|
+
backgroundColor: theme.__hd__.switch.colors.selector.textBackground,
|
|
34
|
+
position: 'absolute',
|
|
35
|
+
top: theme.__hd__.switch.spaces.selector.wrapperPadding,
|
|
36
|
+
bottom: theme.__hd__.switch.spaces.selector.wrapperPadding,
|
|
37
|
+
left: theme.__hd__.switch.spaces.selector.wrapperPadding,
|
|
38
|
+
right: theme.__hd__.switch.spaces.selector.wrapperPadding,
|
|
25
39
|
}));
|
|
@@ -2,15 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Option renders correctly when not selected 1`] = `
|
|
4
4
|
<View
|
|
5
|
+
collapsable={false}
|
|
5
6
|
style={
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
Object {
|
|
8
|
+
"alignItems": "center",
|
|
9
|
+
"justifyContent": "center",
|
|
10
|
+
"paddingHorizontal": 16,
|
|
11
|
+
"transform": Array [
|
|
12
|
+
Object {
|
|
13
|
+
"translateX": 0,
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
"zIndex": 1,
|
|
17
|
+
}
|
|
14
18
|
}
|
|
15
19
|
>
|
|
16
20
|
<View
|
|
@@ -62,17 +66,20 @@ exports[`Option renders correctly when not selected 1`] = `
|
|
|
62
66
|
|
|
63
67
|
exports[`Option renders correctly when selected 1`] = `
|
|
64
68
|
<View
|
|
69
|
+
collapsable={false}
|
|
65
70
|
style={
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
Object {
|
|
72
|
+
"alignItems": "center",
|
|
73
|
+
"borderRadius": 999,
|
|
74
|
+
"flex": 1,
|
|
75
|
+
"justifyContent": "center",
|
|
76
|
+
"transform": Array [
|
|
77
|
+
Object {
|
|
78
|
+
"translateX": 0,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
"zIndex": 1,
|
|
82
|
+
}
|
|
76
83
|
}
|
|
77
84
|
>
|
|
78
85
|
<View
|