@hero-design/rn 7.1.3-alpha5 → 7.1.3-alpha8
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/.eslintrc.json +0 -6
- package/.expo/packager-info.json +1 -1
- package/babel.config.js +0 -14
- package/es/index.js +2787 -8941
- package/jest-setup.ts +0 -1
- package/jest.config.js +2 -4
- package/lib/index.js +2822 -8956
- package/package.json +5 -7
- package/playground/components/BottomNavigation.tsx +14 -11
- package/playground/components/Button.tsx +67 -0
- package/playground/components/Card.tsx +141 -107
- package/playground/components/Tabs.tsx +44 -0
- package/playground/index.tsx +13 -7
- package/src/components/Badge/StyledBadge.tsx +19 -21
- package/src/components/Badge/__tests__/Badge.spec.tsx +9 -18
- package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +76 -96
- package/src/components/Badge/index.tsx +1 -1
- package/src/components/BottomNavigation/StyledBottomNavigation.tsx +44 -42
- package/src/components/BottomNavigation/__tests__/__snapshots__/{BottomNavigation.spec.tsx.snap → index.spec.tsx.snap} +130 -96
- package/src/components/BottomNavigation/__tests__/{BottomNavigation.spec.tsx → index.spec.tsx} +4 -4
- package/src/components/BottomNavigation/index.tsx +28 -32
- package/src/components/Button/IconButton.tsx +62 -0
- package/src/components/Button/__tests__/__snapshots__/index.spec.tsx.snap +46 -0
- package/src/components/Button/__tests__/index.spec.tsx +23 -0
- package/src/components/Button/index.tsx +5 -0
- package/src/components/Card/StyledCard.tsx +6 -6
- package/src/components/Card/__tests__/StyledCard.spec.tsx +2 -7
- package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +8 -11
- package/src/components/Card/__tests__/__snapshots__/{Card.spec.tsx.snap → index.spec.tsx.snap} +2 -8
- package/src/components/Card/__tests__/index.spec.tsx +35 -0
- package/src/components/Divider/StyledDivider.tsx +18 -60
- package/src/components/Divider/__tests__/StyledDivider.spec.tsx +5 -10
- package/src/components/Divider/__tests__/__snapshots__/StyledDivider.spec.tsx.snap +106 -70
- package/src/components/Divider/index.tsx +1 -1
- package/src/components/FAB/ActionGroup/ActionItem.tsx +2 -4
- package/src/components/FAB/ActionGroup/StyledActionGroup.tsx +36 -37
- package/src/components/FAB/ActionGroup/StyledActionItem.tsx +26 -24
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +271 -245
- package/src/components/FAB/ActionGroup/__tests__/index.spec.tsx +29 -33
- package/src/components/FAB/ActionGroup/index.tsx +1 -5
- package/src/components/FAB/AnimatedFABIcon.tsx +1 -1
- package/src/components/FAB/FAB.tsx +5 -9
- package/src/components/FAB/StyledFAB.tsx +22 -0
- package/src/components/FAB/__tests__/AnimatedFABIcon.spec.tsx +3 -6
- package/src/components/FAB/__tests__/StyledFAB.spec.tsx +24 -0
- package/src/components/FAB/__tests__/__snapshots__/AnimatedFABIcon.spec.tsx.snap +14 -10
- package/src/components/FAB/__tests__/__snapshots__/StyledFAB.spec.tsx.snap +72 -0
- package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +16 -17
- package/src/components/FAB/__tests__/index.spec.tsx +21 -26
- package/src/components/Icon/HeroIcon/index.tsx +5 -7
- package/src/components/Icon/__tests__/__snapshots__/{Icon.spec.tsx.snap → index.spec.tsx.snap} +21 -12
- package/src/components/Icon/__tests__/index.spec.tsx +25 -0
- package/src/components/Icon/index.tsx +1 -1
- package/src/components/Tabs/StyledTabs.tsx +70 -0
- package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +321 -0
- package/src/components/Tabs/__tests__/index.spec.tsx +79 -0
- package/src/components/Tabs/index.tsx +185 -0
- package/src/components/Typography/Text/StyledText.tsx +19 -64
- package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +90 -63
- package/src/emotion.d.ts +6 -0
- package/src/index.ts +9 -3
- package/src/testHelpers/renderWithTheme.tsx +2 -1
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +70 -48
- package/src/theme/components/badge.ts +10 -9
- package/src/theme/components/bottomNavigation.ts +7 -3
- package/src/theme/components/card.ts +2 -2
- package/src/theme/components/divider.ts +6 -6
- package/src/theme/components/fab.ts +19 -17
- package/src/theme/components/tabs.ts +20 -0
- package/src/theme/components/typography.ts +4 -4
- package/src/theme/global/borders.ts +8 -2
- package/src/theme/global/colors.ts +3 -1
- package/src/theme/global/index.ts +31 -17
- package/src/theme/global/scale.ts +18 -0
- package/src/theme/global/space.ts +23 -13
- package/src/theme/global/typography.ts +71 -27
- package/src/theme/index.ts +29 -13
- package/src/types.ts +7 -0
- package/src/utils/__tests__/scale.spec.ts +3 -3
- package/testUtils/setup.ts +11 -0
- package/tsconfig.json +1 -5
- package/types/playground/components/BottomNavigation.d.ts +2 -2
- package/types/playground/components/Button.d.ts +2 -0
- package/types/playground/components/Tabs.d.ts +2 -0
- package/types/src/components/Badge/StyledBadge.d.ts +16 -5
- package/types/src/components/Badge/index.d.ts +1 -1
- package/types/src/components/BottomNavigation/StyledBottomNavigation.d.ts +44 -9
- package/types/src/components/{Typography/Text/__test__ → BottomNavigation/__tests__}/index.spec.d.ts +0 -0
- package/types/src/components/BottomNavigation/index.d.ts +19 -14
- package/types/src/components/Button/IconButton.d.ts +34 -0
- package/types/{theme → src/components/Button}/__tests__/index.spec.d.ts +0 -0
- package/types/src/components/Button/index.d.ts +4 -0
- package/types/src/components/Card/StyledCard.d.ts +7 -1
- package/types/{components/Card/__tests__/Card.spec.d.ts → src/components/Card/__tests__/index.spec.d.ts} +0 -0
- package/types/src/components/Divider/StyledDivider.d.ts +8 -2
- package/types/src/components/Divider/index.d.ts +1 -1
- package/types/src/components/FAB/ActionGroup/StyledActionGroup.d.ts +25 -7
- package/types/src/components/FAB/ActionGroup/StyledActionItem.d.ts +11 -2
- package/types/src/components/FAB/ActionGroup/index.d.ts +1 -1
- package/types/src/components/FAB/FAB.d.ts +4 -4
- package/types/src/components/FAB/StyledFAB.d.ts +14 -0
- package/types/{components/Card/__tests__/StyledCard.spec.d.ts → src/components/FAB/__tests__/StyledFAB.spec.d.ts} +0 -0
- package/types/src/components/Icon/HeroIcon/index.d.ts +8 -2
- package/types/{components/Divider/__tests__/StyledDivider.spec.d.ts → src/components/Icon/__tests__/index.spec.d.ts} +0 -0
- package/types/src/components/Icon/index.d.ts +1 -1
- package/types/src/components/Icon/utils.d.ts +1 -1
- package/types/src/components/Tabs/StyledTabs.d.ts +55 -0
- package/types/{components/ExampleComponent/__tests__/StyledView.spec.d.ts → src/components/Tabs/__tests__/index.spec.d.ts} +0 -0
- package/types/src/components/Tabs/index.d.ts +45 -0
- package/types/src/components/Typography/Text/StyledText.d.ts +8 -2
- package/types/src/index.d.ts +6 -3
- package/types/src/theme/components/badge.d.ts +8 -7
- package/types/src/theme/components/bottomNavigation.d.ts +8 -2
- package/types/src/theme/components/card.d.ts +2 -2
- package/types/src/theme/components/divider.d.ts +6 -6
- package/types/src/theme/components/fab.d.ts +19 -17
- package/types/src/theme/components/tabs.d.ts +15 -0
- package/types/src/theme/components/typography.d.ts +4 -4
- package/types/src/theme/global/borders.d.ts +4 -3
- package/types/src/theme/global/colors.d.ts +2 -2
- package/types/src/theme/global/index.d.ts +10 -45
- package/types/src/theme/global/scale.d.ts +8 -0
- package/types/src/theme/global/space.d.ts +8 -7
- package/types/src/theme/global/typography.d.ts +9 -16
- package/types/src/theme/index.d.ts +4 -2
- package/types/src/types.d.ts +5 -0
- package/lib/assets/fonts/be-vietnam-pro-light.ttf +0 -0
- package/lib/assets/fonts/be-vietnam-pro-regular.ttf +0 -0
- package/lib/assets/fonts/be-vietnam-pro-semibold.ttf +0 -0
- package/src/components/Card/__tests__/Card.spec.tsx +0 -36
- package/src/components/FAB/StyledFABContainer.tsx +0 -14
- package/src/components/FAB/StyledFABIcon.tsx +0 -9
- package/src/components/FAB/__tests__/StyledFABContainer.spec.tsx +0 -18
- package/src/components/FAB/__tests__/StyledFABIcon.spec.tsx +0 -16
- package/src/components/FAB/__tests__/__snapshots__/StyledFABContainer.spec.tsx.snap +0 -46
- package/src/components/FAB/__tests__/__snapshots__/StyledFABIcon.spec.tsx.snap +0 -21
- package/src/components/Icon/__tests__/Icon.spec.tsx +0 -36
- package/src/styled-components.ts +0 -14
- package/src/styled.d.ts +0 -7
- package/types/components/Card/StyledCard.d.ts +0 -3
- package/types/components/Card/index.d.ts +0 -5
- package/types/components/Divider/StyledDivider.d.ts +0 -7
- package/types/components/Divider/index.d.ts +0 -12
- package/types/components/ExampleComponent/StyledView.d.ts +0 -7
- package/types/components/ExampleComponent/index.d.ts +0 -16
- package/types/index.d.ts +0 -5
- package/types/src/components/BottomNavigation/__tests__/BottomNavigation.spec.d.ts +0 -1
- package/types/src/components/Card/__tests__/Card.spec.d.ts +0 -1
- package/types/src/components/FAB/StyledFABContainer.d.ts +0 -3
- package/types/src/components/FAB/StyledFABIcon.d.ts +0 -3
- package/types/src/components/FAB/__tests__/StyledFABContainer.spec.d.ts +0 -1
- package/types/src/components/FAB/__tests__/StyledFABIcon.spec.d.ts +0 -1
- package/types/src/components/Icon/__tests__/Icon.spec.d.ts +0 -1
- package/types/src/components/Typography/Text/__test__/StyledText.spec.d.ts +0 -1
- package/types/src/styled-components.d.ts +0 -6
- package/types/styled-components.d.ts +0 -6
- package/types/theme/components/card.d.ts +0 -10
- package/types/theme/components/divider.d.ts +0 -17
- package/types/theme/components/exampleComponent.d.ts +0 -14
- package/types/theme/global/borders.d.ts +0 -4
- package/types/theme/global/colors.d.ts +0 -26
- package/types/theme/global/index.d.ts +0 -63
- package/types/theme/global/space.d.ts +0 -12
- package/types/theme/global/typography.d.ts +0 -21
- package/types/theme/index.d.ts +0 -13
|
@@ -14,21 +14,23 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
14
14
|
>
|
|
15
15
|
<View
|
|
16
16
|
style={
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
Array [
|
|
18
|
+
Object {
|
|
19
|
+
"flex": 1,
|
|
20
|
+
"overflow": "hidden",
|
|
21
|
+
},
|
|
22
|
+
undefined,
|
|
23
|
+
]
|
|
23
24
|
}
|
|
24
25
|
>
|
|
25
26
|
<View
|
|
26
27
|
style={
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
Array [
|
|
29
|
+
Object {
|
|
30
|
+
"flex": 1,
|
|
31
|
+
},
|
|
32
|
+
undefined,
|
|
33
|
+
]
|
|
32
34
|
}
|
|
33
35
|
>
|
|
34
36
|
<View
|
|
@@ -38,14 +40,14 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
38
40
|
pointerEvents="auto"
|
|
39
41
|
removeClippedSubviews={false}
|
|
40
42
|
style={
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
Array [
|
|
44
|
+
Object {
|
|
45
|
+
"display": "flex",
|
|
46
|
+
"flex": 1,
|
|
47
|
+
},
|
|
48
|
+
undefined,
|
|
49
|
+
]
|
|
47
50
|
}
|
|
48
|
-
testID="route-screen-home"
|
|
49
51
|
themeVisibility={true}
|
|
50
52
|
>
|
|
51
53
|
<Text>
|
|
@@ -55,21 +57,24 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
55
57
|
</View>
|
|
56
58
|
<View
|
|
57
59
|
style={
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
|
|
60
|
+
Array [
|
|
61
|
+
Object {
|
|
62
|
+
"backgroundColor": "#ffffff",
|
|
63
|
+
"elevation": 10,
|
|
64
|
+
"height": 72,
|
|
65
|
+
"paddingBottom": 0,
|
|
66
|
+
"paddingLeft": 0,
|
|
67
|
+
"paddingRight": 0,
|
|
68
|
+
"shadowColor": "#292a2b",
|
|
69
|
+
"shadowOffset": Object {
|
|
70
|
+
"height": 3,
|
|
71
|
+
"width": 0,
|
|
72
|
+
},
|
|
73
|
+
"shadowOpacity": 0.27,
|
|
74
|
+
"shadowRadius": 4.65,
|
|
69
75
|
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
76
|
+
undefined,
|
|
77
|
+
]
|
|
73
78
|
}
|
|
74
79
|
themeInsets={
|
|
75
80
|
Object {
|
|
@@ -82,14 +87,15 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
82
87
|
>
|
|
83
88
|
<View
|
|
84
89
|
style={
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
Array [
|
|
91
|
+
Object {
|
|
92
|
+
"alignItems": "center",
|
|
93
|
+
"flex": 1,
|
|
94
|
+
"flexDirection": "row",
|
|
95
|
+
"overflow": "hidden",
|
|
96
|
+
},
|
|
97
|
+
undefined,
|
|
98
|
+
]
|
|
93
99
|
}
|
|
94
100
|
>
|
|
95
101
|
<View
|
|
@@ -103,21 +109,25 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
103
109
|
onResponderTerminationRequest={[Function]}
|
|
104
110
|
onStartShouldSetResponder={[Function]}
|
|
105
111
|
style={
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
+
Array [
|
|
113
|
+
Object {
|
|
114
|
+
"alignItems": "center",
|
|
115
|
+
"flex": 1,
|
|
116
|
+
},
|
|
117
|
+
undefined,
|
|
118
|
+
]
|
|
112
119
|
}
|
|
113
120
|
>
|
|
114
121
|
<HeroIcon
|
|
115
122
|
name="home"
|
|
116
123
|
style={
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
124
|
+
Array [
|
|
125
|
+
Object {
|
|
126
|
+
"color": "#7622d7",
|
|
127
|
+
"fontSize": 24,
|
|
128
|
+
},
|
|
129
|
+
undefined,
|
|
130
|
+
]
|
|
121
131
|
}
|
|
122
132
|
testID="hero-icon-home"
|
|
123
133
|
themeIntent="primary"
|
|
@@ -129,14 +139,17 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
129
139
|
Array [
|
|
130
140
|
Object {
|
|
131
141
|
"color": "#7622d7",
|
|
132
|
-
"fontFamily": "
|
|
142
|
+
"fontFamily": "BeVietnamPro-SemiBold",
|
|
133
143
|
"fontSize": 12,
|
|
134
144
|
"letterSpacing": 0.36,
|
|
135
145
|
"lineHeight": 20,
|
|
136
146
|
},
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
147
|
+
Array [
|
|
148
|
+
Object {
|
|
149
|
+
"marginTop": 4,
|
|
150
|
+
},
|
|
151
|
+
undefined,
|
|
152
|
+
],
|
|
140
153
|
]
|
|
141
154
|
}
|
|
142
155
|
themeFontSize="small"
|
|
@@ -157,21 +170,25 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
157
170
|
onResponderTerminationRequest={[Function]}
|
|
158
171
|
onStartShouldSetResponder={[Function]}
|
|
159
172
|
style={
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
173
|
+
Array [
|
|
174
|
+
Object {
|
|
175
|
+
"alignItems": "center",
|
|
176
|
+
"flex": 1,
|
|
177
|
+
},
|
|
178
|
+
undefined,
|
|
179
|
+
]
|
|
166
180
|
}
|
|
167
181
|
>
|
|
168
182
|
<HeroIcon
|
|
169
183
|
name="speaker-outlined"
|
|
170
184
|
style={
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
185
|
+
Array [
|
|
186
|
+
Object {
|
|
187
|
+
"color": "#292a2b",
|
|
188
|
+
"fontSize": 24,
|
|
189
|
+
},
|
|
190
|
+
undefined,
|
|
191
|
+
]
|
|
175
192
|
}
|
|
176
193
|
testID="hero-icon-speaker-outlined"
|
|
177
194
|
themeIntent="text"
|
|
@@ -183,14 +200,17 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
183
200
|
Array [
|
|
184
201
|
Object {
|
|
185
202
|
"color": "#292a2b",
|
|
186
|
-
"fontFamily": "
|
|
203
|
+
"fontFamily": "BeVietnamPro-SemiBold",
|
|
187
204
|
"fontSize": 12,
|
|
188
205
|
"letterSpacing": 0.36,
|
|
189
206
|
"lineHeight": 20,
|
|
190
207
|
},
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
208
|
+
Array [
|
|
209
|
+
Object {
|
|
210
|
+
"marginTop": 4,
|
|
211
|
+
},
|
|
212
|
+
undefined,
|
|
213
|
+
],
|
|
194
214
|
]
|
|
195
215
|
}
|
|
196
216
|
themeFontSize="small"
|
|
@@ -211,21 +231,25 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
211
231
|
onResponderTerminationRequest={[Function]}
|
|
212
232
|
onStartShouldSetResponder={[Function]}
|
|
213
233
|
style={
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
234
|
+
Array [
|
|
235
|
+
Object {
|
|
236
|
+
"alignItems": "center",
|
|
237
|
+
"flex": 1,
|
|
238
|
+
},
|
|
239
|
+
undefined,
|
|
240
|
+
]
|
|
220
241
|
}
|
|
221
242
|
>
|
|
222
243
|
<HeroIcon
|
|
223
244
|
name="bell-outlined"
|
|
224
245
|
style={
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
246
|
+
Array [
|
|
247
|
+
Object {
|
|
248
|
+
"color": "#292a2b",
|
|
249
|
+
"fontSize": 24,
|
|
250
|
+
},
|
|
251
|
+
undefined,
|
|
252
|
+
]
|
|
229
253
|
}
|
|
230
254
|
testID="hero-icon-bell-outlined"
|
|
231
255
|
themeIntent="text"
|
|
@@ -237,14 +261,17 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
237
261
|
Array [
|
|
238
262
|
Object {
|
|
239
263
|
"color": "#292a2b",
|
|
240
|
-
"fontFamily": "
|
|
264
|
+
"fontFamily": "BeVietnamPro-SemiBold",
|
|
241
265
|
"fontSize": 12,
|
|
242
266
|
"letterSpacing": 0.36,
|
|
243
267
|
"lineHeight": 20,
|
|
244
268
|
},
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
269
|
+
Array [
|
|
270
|
+
Object {
|
|
271
|
+
"marginTop": 4,
|
|
272
|
+
},
|
|
273
|
+
undefined,
|
|
274
|
+
],
|
|
248
275
|
]
|
|
249
276
|
}
|
|
250
277
|
themeFontSize="small"
|
|
@@ -265,21 +292,25 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
265
292
|
onResponderTerminationRequest={[Function]}
|
|
266
293
|
onStartShouldSetResponder={[Function]}
|
|
267
294
|
style={
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
295
|
+
Array [
|
|
296
|
+
Object {
|
|
297
|
+
"alignItems": "center",
|
|
298
|
+
"flex": 1,
|
|
299
|
+
},
|
|
300
|
+
undefined,
|
|
301
|
+
]
|
|
274
302
|
}
|
|
275
303
|
>
|
|
276
304
|
<HeroIcon
|
|
277
305
|
name="user-outlined"
|
|
278
306
|
style={
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
307
|
+
Array [
|
|
308
|
+
Object {
|
|
309
|
+
"color": "#292a2b",
|
|
310
|
+
"fontSize": 24,
|
|
311
|
+
},
|
|
312
|
+
undefined,
|
|
313
|
+
]
|
|
283
314
|
}
|
|
284
315
|
testID="hero-icon-user-outlined"
|
|
285
316
|
themeIntent="text"
|
|
@@ -291,14 +322,17 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
291
322
|
Array [
|
|
292
323
|
Object {
|
|
293
324
|
"color": "#292a2b",
|
|
294
|
-
"fontFamily": "
|
|
325
|
+
"fontFamily": "BeVietnamPro-SemiBold",
|
|
295
326
|
"fontSize": 12,
|
|
296
327
|
"letterSpacing": 0.36,
|
|
297
328
|
"lineHeight": 20,
|
|
298
329
|
},
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
330
|
+
Array [
|
|
331
|
+
Object {
|
|
332
|
+
"marginTop": 4,
|
|
333
|
+
},
|
|
334
|
+
undefined,
|
|
335
|
+
],
|
|
302
336
|
]
|
|
303
337
|
}
|
|
304
338
|
themeFontSize="small"
|
package/src/components/BottomNavigation/__tests__/{BottomNavigation.spec.tsx → index.spec.tsx}
RENAMED
|
@@ -3,16 +3,16 @@ import { Text } from 'react-native';
|
|
|
3
3
|
import { fireEvent } from '@testing-library/react-native';
|
|
4
4
|
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
5
5
|
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
6
|
-
import BottomNavigation, {
|
|
6
|
+
import BottomNavigation, { BottomNavigationTabType } from '..';
|
|
7
7
|
|
|
8
8
|
const TestComponent = (
|
|
9
9
|
props: Omit<
|
|
10
10
|
ComponentProps<typeof BottomNavigation>,
|
|
11
|
-
'selectedTabKey' | '
|
|
11
|
+
'selectedTabKey' | 'onTabPress' | 'tabs'
|
|
12
12
|
>
|
|
13
13
|
) => {
|
|
14
14
|
const [selectedTabKey, setSelectedTabKey] = React.useState('home');
|
|
15
|
-
const tabs:
|
|
15
|
+
const tabs: BottomNavigationTabType[] = [
|
|
16
16
|
{
|
|
17
17
|
key: 'home',
|
|
18
18
|
title: 'Home',
|
|
@@ -50,7 +50,7 @@ const TestComponent = (
|
|
|
50
50
|
{...props}
|
|
51
51
|
tabs={tabs}
|
|
52
52
|
selectedTabKey={selectedTabKey}
|
|
53
|
-
|
|
53
|
+
onTabPress={newTabKey => setSelectedTabKey(newTabKey)}
|
|
54
54
|
/>
|
|
55
55
|
</SafeAreaProvider>
|
|
56
56
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
TouchableWithoutFeedback,
|
|
4
4
|
StyleProp,
|
|
@@ -6,10 +6,8 @@ import {
|
|
|
6
6
|
ViewProps,
|
|
7
7
|
} from 'react-native';
|
|
8
8
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
9
|
-
import {
|
|
10
|
-
import Icon from '../Icon';
|
|
9
|
+
import Icon, { IconName } from '../Icon';
|
|
11
10
|
import { isHeroIcon } from '../Icon/utils';
|
|
12
|
-
import Typography from '../Typography';
|
|
13
11
|
import {
|
|
14
12
|
BottomBar,
|
|
15
13
|
BottomBarItem,
|
|
@@ -17,25 +15,23 @@ import {
|
|
|
17
15
|
BottomNavigationContainer,
|
|
18
16
|
BottomNavigationTab,
|
|
19
17
|
ContentWrapper,
|
|
18
|
+
StyledBottomBarText,
|
|
20
19
|
} from './StyledBottomNavigation';
|
|
21
20
|
import { isIOS } from '../../utils/helpers';
|
|
22
21
|
|
|
23
|
-
type
|
|
24
|
-
|
|
25
|
-
export type Tab<V> = {
|
|
26
|
-
key: V;
|
|
22
|
+
export type BottomNavigationTabType = {
|
|
23
|
+
key: string;
|
|
27
24
|
title?: string;
|
|
28
|
-
icon:
|
|
25
|
+
icon: IconName;
|
|
29
26
|
component: ReactNode;
|
|
30
27
|
testID?: string;
|
|
31
28
|
};
|
|
32
29
|
|
|
33
|
-
interface
|
|
34
|
-
extends ViewProps {
|
|
30
|
+
interface BottomNavigationProps extends ViewProps {
|
|
35
31
|
/**
|
|
36
|
-
* Callback which is called on tab
|
|
32
|
+
* Callback which is called on tab press, receiving key of upcoming active Tab.
|
|
37
33
|
*/
|
|
38
|
-
|
|
34
|
+
onTabPress: (key: string) => void;
|
|
39
35
|
/**
|
|
40
36
|
* Whether inactive tabs should be removed and unmounted in React.
|
|
41
37
|
* Defaults to `false`.
|
|
@@ -44,13 +40,19 @@ interface BottomNavigationType<V extends string | number, T extends Tab<V>>
|
|
|
44
40
|
/**
|
|
45
41
|
* Current selected tab key.
|
|
46
42
|
*/
|
|
47
|
-
selectedTabKey:
|
|
43
|
+
selectedTabKey: string;
|
|
48
44
|
/**
|
|
49
|
-
* List of
|
|
45
|
+
* List of Tabs to be rendered. Each Tab must have an unique key.
|
|
50
46
|
*/
|
|
51
|
-
tabs:
|
|
47
|
+
tabs: {
|
|
48
|
+
key: string;
|
|
49
|
+
title?: string;
|
|
50
|
+
icon: IconName;
|
|
51
|
+
component: ReactNode;
|
|
52
|
+
testID?: string;
|
|
53
|
+
}[];
|
|
52
54
|
/**
|
|
53
|
-
*
|
|
55
|
+
* Additional style.
|
|
54
56
|
*/
|
|
55
57
|
style?: StyleProp<ViewStyle>;
|
|
56
58
|
/**
|
|
@@ -59,19 +61,18 @@ interface BottomNavigationType<V extends string | number, T extends Tab<V>>
|
|
|
59
61
|
testID?: string;
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
const getInactiveIcon = (icon:
|
|
64
|
+
const getInactiveIcon = (icon: IconName): IconName => {
|
|
63
65
|
const inactiveIcon = `${icon}-outlined`;
|
|
64
66
|
return isHeroIcon(inactiveIcon) ? inactiveIcon : icon;
|
|
65
67
|
};
|
|
66
68
|
|
|
67
|
-
const BottomNavigation =
|
|
68
|
-
|
|
69
|
+
const BottomNavigation = ({
|
|
70
|
+
onTabPress,
|
|
69
71
|
renderActiveTabOnly = false,
|
|
70
72
|
selectedTabKey,
|
|
71
73
|
tabs,
|
|
72
74
|
...nativeProps
|
|
73
|
-
}:
|
|
74
|
-
const theme = useTheme();
|
|
75
|
+
}: BottomNavigationProps): JSX.Element => {
|
|
75
76
|
const insets = useSafeAreaInsets();
|
|
76
77
|
|
|
77
78
|
/**
|
|
@@ -88,7 +89,7 @@ const BottomNavigation = <V extends string | number, T extends Tab<V>>({
|
|
|
88
89
|
<BottomNavigationContainer {...nativeProps}>
|
|
89
90
|
<ContentWrapper>
|
|
90
91
|
{tabs.map(tab => {
|
|
91
|
-
const { key, component } = tab;
|
|
92
|
+
const { key, component, testID } = tab;
|
|
92
93
|
const active = selectedTabKey === key;
|
|
93
94
|
|
|
94
95
|
if (renderActiveTabOnly && !active) {
|
|
@@ -103,7 +104,7 @@ const BottomNavigation = <V extends string | number, T extends Tab<V>>({
|
|
|
103
104
|
return (
|
|
104
105
|
<BottomNavigationTab
|
|
105
106
|
key={key}
|
|
106
|
-
testID={`route-screen-${
|
|
107
|
+
testID={testID ? `route-screen-${testID}` : undefined}
|
|
107
108
|
pointerEvents={active ? 'auto' : 'none'}
|
|
108
109
|
accessibilityElementsHidden={!active}
|
|
109
110
|
importantForAccessibility={
|
|
@@ -132,11 +133,7 @@ const BottomNavigation = <V extends string | number, T extends Tab<V>>({
|
|
|
132
133
|
return (
|
|
133
134
|
<TouchableWithoutFeedback
|
|
134
135
|
key={key}
|
|
135
|
-
onPress={() =>
|
|
136
|
-
if (key !== selectedTabKey) {
|
|
137
|
-
onChange(key);
|
|
138
|
-
}
|
|
139
|
-
}}
|
|
136
|
+
onPress={() => onTabPress(key)}
|
|
140
137
|
testID={testID}
|
|
141
138
|
>
|
|
142
139
|
<BottomBarItem>
|
|
@@ -146,15 +143,14 @@ const BottomNavigation = <V extends string | number, T extends Tab<V>>({
|
|
|
146
143
|
testID={`hero-icon-${icon}`}
|
|
147
144
|
/>
|
|
148
145
|
{title && (
|
|
149
|
-
<
|
|
146
|
+
<StyledBottomBarText
|
|
150
147
|
fontSize="small"
|
|
151
148
|
fontWeight="semi-bold"
|
|
152
149
|
intent={active ? 'primary' : 'body'}
|
|
153
|
-
style={{ marginTop: theme.space.xsmall }}
|
|
154
150
|
numberOfLines={1}
|
|
155
151
|
>
|
|
156
152
|
{title}
|
|
157
|
-
</
|
|
153
|
+
</StyledBottomBarText>
|
|
158
154
|
)}
|
|
159
155
|
</BottomBarItem>
|
|
160
156
|
</TouchableWithoutFeedback>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
StyleProp,
|
|
5
|
+
ViewStyle,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
TouchableOpacityProps,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
|
|
10
|
+
import Icon, { IconProps, IconName } from '../Icon';
|
|
11
|
+
|
|
12
|
+
export interface IconButtonProps {
|
|
13
|
+
/**
|
|
14
|
+
* Set how far you can touch from the button.
|
|
15
|
+
*/
|
|
16
|
+
hitSlop?: TouchableOpacityProps['hitSlop'];
|
|
17
|
+
/**
|
|
18
|
+
* Name of the Icon.
|
|
19
|
+
*/
|
|
20
|
+
icon: IconName;
|
|
21
|
+
/**
|
|
22
|
+
* Intent of the Icon.
|
|
23
|
+
*/
|
|
24
|
+
intent?: IconProps['intent'];
|
|
25
|
+
/**
|
|
26
|
+
* Set the handler to handle press event.
|
|
27
|
+
*/
|
|
28
|
+
onPress: () => void;
|
|
29
|
+
/**
|
|
30
|
+
* Size of the Icon.
|
|
31
|
+
*/
|
|
32
|
+
size?: IconProps['size'];
|
|
33
|
+
/**
|
|
34
|
+
* Additional style.
|
|
35
|
+
*/
|
|
36
|
+
style?: StyleProp<ViewStyle>;
|
|
37
|
+
/**
|
|
38
|
+
* Testing id of component.
|
|
39
|
+
*/
|
|
40
|
+
testID?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const IconButton = ({
|
|
44
|
+
hitSlop,
|
|
45
|
+
onPress,
|
|
46
|
+
icon,
|
|
47
|
+
testID,
|
|
48
|
+
style,
|
|
49
|
+
size,
|
|
50
|
+
intent,
|
|
51
|
+
}: IconButtonProps) => (
|
|
52
|
+
<TouchableOpacity
|
|
53
|
+
style={style}
|
|
54
|
+
onPress={onPress}
|
|
55
|
+
testID={testID}
|
|
56
|
+
hitSlop={hitSlop}
|
|
57
|
+
>
|
|
58
|
+
<Icon icon={icon} size={size} intent={intent} />
|
|
59
|
+
</TouchableOpacity>
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
export default IconButton;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`IconButton renders correctly 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
accessible={true}
|
|
6
|
+
collapsable={false}
|
|
7
|
+
focusable={true}
|
|
8
|
+
hitSlop={
|
|
9
|
+
Object {
|
|
10
|
+
"bottom": 4,
|
|
11
|
+
"left": 6,
|
|
12
|
+
"right": 6,
|
|
13
|
+
"top": 4,
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
nativeID="animatedComponent"
|
|
17
|
+
onClick={[Function]}
|
|
18
|
+
onResponderGrant={[Function]}
|
|
19
|
+
onResponderMove={[Function]}
|
|
20
|
+
onResponderRelease={[Function]}
|
|
21
|
+
onResponderTerminate={[Function]}
|
|
22
|
+
onResponderTerminationRequest={[Function]}
|
|
23
|
+
onStartShouldSetResponder={[Function]}
|
|
24
|
+
style={
|
|
25
|
+
Object {
|
|
26
|
+
"opacity": 1,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
testID="icon-btn"
|
|
30
|
+
>
|
|
31
|
+
<HeroIcon
|
|
32
|
+
name="home"
|
|
33
|
+
style={
|
|
34
|
+
Array [
|
|
35
|
+
Object {
|
|
36
|
+
"color": "#292a2b",
|
|
37
|
+
"fontSize": 24,
|
|
38
|
+
},
|
|
39
|
+
undefined,
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
themeIntent="text"
|
|
43
|
+
themeSize="medium"
|
|
44
|
+
/>
|
|
45
|
+
</View>
|
|
46
|
+
`;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { fireEvent } from '@testing-library/react-native';
|
|
3
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
4
|
+
|
|
5
|
+
import Button from '..';
|
|
6
|
+
|
|
7
|
+
describe('IconButton', () => {
|
|
8
|
+
it('renders correctly', () => {
|
|
9
|
+
const onPress = jest.fn();
|
|
10
|
+
const { toJSON, getByTestId } = renderWithTheme(
|
|
11
|
+
<Button.Icon
|
|
12
|
+
icon="home"
|
|
13
|
+
onPress={onPress}
|
|
14
|
+
testID="icon-btn"
|
|
15
|
+
hitSlop={{ top: 4, bottom: 4, right: 6, left: 6 }}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
fireEvent.press(getByTestId('icon-btn'));
|
|
20
|
+
expect(onPress).toBeCalledTimes(1);
|
|
21
|
+
expect(toJSON()).toMatchSnapshot();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { View } from 'react-native';
|
|
2
|
-
import styled from '
|
|
2
|
+
import styled from '@emotion/native';
|
|
3
3
|
|
|
4
|
-
const StyledCard = styled(View)
|
|
5
|
-
|
|
6
|
-
padding:
|
|
7
|
-
overflow: hidden
|
|
8
|
-
|
|
4
|
+
const StyledCard = styled(View)(({ theme }) => ({
|
|
5
|
+
borderRadius: theme.__hd__.card.radii.default,
|
|
6
|
+
padding: theme.__hd__.card.padding.default,
|
|
7
|
+
overflow: 'hidden',
|
|
8
|
+
}));
|
|
9
9
|
|
|
10
10
|
export { StyledCard };
|