@hero-design/rn 7.25.0 → 7.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 +9 -9
- package/assets/fonts/BeVietnamPro-Bold.ttf +0 -0
- package/assets/fonts/{be-vietnam-pro-light.ttf → BeVietnamPro-Light.ttf} +0 -0
- package/assets/fonts/{be-vietnam-pro-regular.ttf → BeVietnamPro-Regular.ttf} +0 -0
- package/assets/fonts/{be-vietnam-pro-semibold.ttf → BeVietnamPro-SemiBold.ttf} +0 -0
- package/assets/fonts/RebondGrotesque-Light.otf +0 -0
- package/assets/fonts/RebondGrotesque-Regular.otf +0 -0
- package/assets/fonts/RebondGrotesque-SemiBold.otf +0 -0
- package/{lib/assets/fonts/hero-icons.ttf → assets/fonts/hero-icons-mobile.ttf} +0 -0
- package/es/index.js +9154 -12299
- package/jest.config.js +6 -2
- package/{assets/fonts/hero-icons.ttf → lib/assets/fonts/hero-icons-mobile.ttf} +0 -0
- package/lib/index.js +9154 -12298
- package/package.json +4 -4
- package/rollup.config.js +1 -1
- package/src/components/Accordion/__tests__/__snapshots__/AccordionItem.spec.tsx.snap +8 -0
- package/src/components/Accordion/__tests__/__snapshots__/index.spec.tsx.snap +12 -0
- package/src/components/Alert/__tests__/__snapshots__/index.spec.tsx.snap +11 -0
- package/src/components/Attachment/__tests__/__snapshots__/index.spec.tsx.snap +1 -0
- package/src/components/Avatar/{index.tsx → Avatar.tsx} +33 -18
- package/src/components/Avatar/AvatarStack/StyledAvatarStack.tsx +29 -0
- package/src/components/Avatar/AvatarStack/__tests__/StyledAvatarStack.spec.tsx +33 -0
- package/src/components/Avatar/AvatarStack/__tests__/__snapshots__/StyledAvatarStack.spec.tsx.snap +80 -0
- package/src/components/Avatar/AvatarStack/__tests__/__snapshots__/index.spec.tsx.snap +552 -0
- package/src/components/Avatar/AvatarStack/__tests__/index.spec.tsx +59 -0
- package/src/components/Avatar/AvatarStack/index.tsx +61 -0
- package/src/components/Avatar/AvatarStack/utils.ts +22 -0
- package/src/components/Avatar/StyledAvatar.tsx +6 -25
- package/src/components/Avatar/__tests__/StyledAvatar.spec.tsx +3 -19
- package/src/components/Avatar/__tests__/__snapshots__/StyledAvatar.spec.tsx.snap +3 -24
- package/src/components/Avatar/__tests__/__snapshots__/index.spec.tsx.snap +118 -20
- package/src/components/Avatar/__tests__/index.spec.tsx +25 -8
- package/src/components/Avatar/index.ts +6 -0
- package/src/components/Badge/__tests__/__snapshots__/Status.spec.tsx.snap +1 -0
- package/src/components/BottomNavigation/__tests__/__snapshots__/index.spec.tsx.snap +4 -0
- package/src/components/BottomSheet/__tests__/__snapshots__/index.spec.tsx.snap +2 -0
- package/src/components/Button/UtilityButton/__tests__/__snapshots__/index.spec.tsx.snap +2 -0
- package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +11 -0
- package/src/components/Calendar/__tests__/__snapshots__/CalendarRowItem.spec.tsx.snap +5 -0
- package/src/components/Card/DataCard/__tests__/__snapshots__/StyledDataCard.spec.tsx.snap +1 -1
- package/src/components/Card/DataCard/__tests__/__snapshots__/index.spec.tsx.snap +1 -1
- package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +4 -0
- package/src/components/Checkbox/__tests__/__snapshots__/index.spec.tsx.snap +4 -0
- package/src/components/ContentNavigator/__tests__/__snapshots__/StyledContentNavigator.spec.tsx.snap +1 -0
- package/src/components/ContentNavigator/__tests__/__snapshots__/index.spec.tsx.snap +2 -0
- package/src/components/ContentNavigator/index.tsx +8 -12
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +1 -0
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +3 -0
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +12 -0
- package/src/components/FAB/__tests__/__snapshots__/StyledFAB.spec.tsx.snap +1 -0
- package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
- package/src/components/Icon/HeroIcon/index.tsx +5 -1
- package/src/components/Icon/IconList.ts +11 -0
- package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +4 -0
- package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +54 -31
- package/src/components/List/__tests__/__snapshots__/StyledBasicListItem.spec.tsx.snap +4 -0
- package/src/components/List/__tests__/__snapshots__/StyledListItem.spec.tsx.snap +5 -1
- package/src/components/Progress/ProgressBar.tsx +19 -2
- package/src/components/Progress/ProgressCircle.tsx +30 -9
- package/src/components/Progress/StyledProgressBar.tsx +14 -7
- package/src/components/Progress/StyledProgressCircle.tsx +35 -24
- package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +337 -30
- package/src/components/Progress/__tests__/index.spec.js +15 -0
- package/src/components/Progress/constants.ts +16 -0
- package/src/components/Progress/types.ts +7 -1
- package/src/components/Radio/__tests__/__snapshots__/Radio.spec.tsx.snap +2 -0
- package/src/components/Radio/__tests__/__snapshots__/RadioGroup.spec.tsx.snap +3 -0
- package/src/components/RichTextEditor/RichTextEditor.tsx +1 -1
- package/src/components/RichTextEditor/__mocks__/heroEditorApp.ts +2 -0
- package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +36 -25
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +8 -4
- package/src/components/RichTextEditor/heroEditorApp.ts +3 -0
- package/src/components/SectionHeading/__tests__/__snapshots__/index.spec.tsx.snap +4 -0
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +1 -0
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +20 -0
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +51 -0
- package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +22 -0
- package/src/components/Select/MultiSelect/index.tsx +35 -13
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/Option.spec.tsx.snap +1 -0
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +20 -0
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +46 -0
- package/src/components/Select/__tests__/__snapshots__/StyledSelect.spec.tsx.snap +1 -0
- package/src/components/Swipeable/__tests__/__snapshots__/SwipeableAction.spec.tsx.snap +3 -0
- package/src/components/Swipeable/__tests__/__snapshots__/index.spec.tsx.snap +1 -0
- package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/Option.spec.tsx.snap +1 -0
- package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/index.spec.tsx.snap +1 -0
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +2 -0
- package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +5 -0
- package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +22 -0
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +31 -0
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +1 -0
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +3 -0
- package/src/components/Toast/__tests__/__snapshots__/Toast.spec.tsx.snap +13 -0
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarGroup.spec.tsx.snap +6 -0
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.spec.tsx.snap +6 -0
- package/src/components/Typography/Text/StyledText.tsx +6 -2
- package/src/components/Typography/Text/__tests__/StyledText.spec.tsx +22 -0
- package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +63 -0
- package/src/components/Typography/Text/index.tsx +8 -0
- package/src/index.ts +2 -1
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +84 -21
- package/src/theme/components/avatar.ts +29 -5
- package/src/theme/components/badge.ts +1 -1
- package/src/theme/components/button.ts +2 -2
- package/src/theme/components/empty.ts +2 -2
- package/src/theme/components/fab.ts +3 -3
- package/src/theme/components/pinInput.ts +2 -2
- package/src/theme/components/progress.ts +37 -9
- package/src/theme/components/tag.ts +1 -1
- package/src/theme/components/typography.ts +1 -7
- package/src/theme/global/colors/global.ts +12 -3
- package/src/theme/global/colors/types.ts +5 -0
- package/src/theme/global/scale.ts +6 -2
- package/src/theme/global/typography.ts +23 -5
- package/types/components/Avatar/Avatar.d.ts +33 -0
- package/types/components/Avatar/AvatarStack/StyledAvatarStack.d.ts +17 -0
- package/types/components/Avatar/AvatarStack/index.d.ts +23 -0
- package/types/components/Avatar/AvatarStack/utils.d.ts +4 -0
- package/types/components/Avatar/StyledAvatar.d.ts +2 -12
- package/types/components/Avatar/index.d.ts +6 -25
- 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/Progress/ProgressBar.d.ts +1 -1
- package/types/components/Progress/ProgressCircle.d.ts +4 -2
- package/types/components/Progress/StyledProgressBar.d.ts +2 -0
- package/types/components/Progress/StyledProgressCircle.d.ts +2 -0
- package/types/components/Progress/constants.d.ts +15 -0
- package/types/components/Progress/index.d.ts +1 -1
- package/types/components/Progress/types.d.ts +1 -1
- package/types/components/RichTextEditor/__mocks__/heroEditorApp.d.ts +2 -0
- package/types/components/RichTextEditor/heroEditorApp.d.ts +2 -0
- package/types/components/Select/MultiSelect/index.d.ts +4 -1
- package/types/components/Typography/Text/StyledText.d.ts +1 -0
- package/types/components/Typography/Text/index.d.ts +7 -1
- package/types/index.d.ts +2 -2
- package/types/theme/components/avatar.d.ts +4 -2
- package/types/theme/components/progress.d.ts +30 -9
- package/types/theme/components/typography.d.ts +1 -5
- package/types/theme/global/colors/types.d.ts +5 -0
- package/types/theme/global/index.d.ts +5 -0
- package/types/theme/global/scale.d.ts +4 -1
- package/types/theme/global/typography.d.ts +9 -2
- package/src/components/Icon/HeroIcon/fonts/hero-icons.ttf +0 -0
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`AvatarStack renders correctly by default 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
style={
|
|
6
|
+
Array [
|
|
7
|
+
Object {
|
|
8
|
+
"flexDirection": "row",
|
|
9
|
+
"height": 32,
|
|
10
|
+
"width": 121.6,
|
|
11
|
+
},
|
|
12
|
+
undefined,
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
testID="group-avatar"
|
|
16
|
+
themeAvatarCount={5}
|
|
17
|
+
themeSize="small"
|
|
18
|
+
>
|
|
19
|
+
<View
|
|
20
|
+
accessible={true}
|
|
21
|
+
collapsable={false}
|
|
22
|
+
focusable={false}
|
|
23
|
+
nativeID="animatedComponent"
|
|
24
|
+
onClick={[Function]}
|
|
25
|
+
onResponderGrant={[Function]}
|
|
26
|
+
onResponderMove={[Function]}
|
|
27
|
+
onResponderRelease={[Function]}
|
|
28
|
+
onResponderTerminate={[Function]}
|
|
29
|
+
onResponderTerminationRequest={[Function]}
|
|
30
|
+
onStartShouldSetResponder={[Function]}
|
|
31
|
+
style={
|
|
32
|
+
Object {
|
|
33
|
+
"backgroundColor": "#401960",
|
|
34
|
+
"borderRadius": 999,
|
|
35
|
+
"height": 32,
|
|
36
|
+
"left": 0,
|
|
37
|
+
"opacity": 1,
|
|
38
|
+
"overflow": "hidden",
|
|
39
|
+
"position": "absolute",
|
|
40
|
+
"width": 32,
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
>
|
|
44
|
+
<View
|
|
45
|
+
style={
|
|
46
|
+
Array [
|
|
47
|
+
Object {
|
|
48
|
+
"alignItems": "center",
|
|
49
|
+
"display": "flex",
|
|
50
|
+
"height": "100%",
|
|
51
|
+
"justifyContent": "center",
|
|
52
|
+
"width": "100%",
|
|
53
|
+
},
|
|
54
|
+
undefined,
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
>
|
|
58
|
+
<Text
|
|
59
|
+
style={
|
|
60
|
+
Array [
|
|
61
|
+
Object {
|
|
62
|
+
"color": "#ffffff",
|
|
63
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
64
|
+
"fontSize": 16,
|
|
65
|
+
"overflow": "hidden",
|
|
66
|
+
},
|
|
67
|
+
undefined,
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
themeSize="small"
|
|
71
|
+
>
|
|
72
|
+
TT
|
|
73
|
+
</Text>
|
|
74
|
+
</View>
|
|
75
|
+
</View>
|
|
76
|
+
<View
|
|
77
|
+
accessible={true}
|
|
78
|
+
collapsable={false}
|
|
79
|
+
focusable={false}
|
|
80
|
+
nativeID="animatedComponent"
|
|
81
|
+
onClick={[Function]}
|
|
82
|
+
onResponderGrant={[Function]}
|
|
83
|
+
onResponderMove={[Function]}
|
|
84
|
+
onResponderRelease={[Function]}
|
|
85
|
+
onResponderTerminate={[Function]}
|
|
86
|
+
onResponderTerminationRequest={[Function]}
|
|
87
|
+
onStartShouldSetResponder={[Function]}
|
|
88
|
+
style={
|
|
89
|
+
Object {
|
|
90
|
+
"backgroundColor": "#401960",
|
|
91
|
+
"borderRadius": 999,
|
|
92
|
+
"height": 32,
|
|
93
|
+
"left": 22.4,
|
|
94
|
+
"opacity": 1,
|
|
95
|
+
"overflow": "hidden",
|
|
96
|
+
"position": "absolute",
|
|
97
|
+
"width": 32,
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
>
|
|
101
|
+
<View
|
|
102
|
+
style={
|
|
103
|
+
Array [
|
|
104
|
+
Object {
|
|
105
|
+
"alignItems": "center",
|
|
106
|
+
"display": "flex",
|
|
107
|
+
"height": "100%",
|
|
108
|
+
"justifyContent": "center",
|
|
109
|
+
"width": "100%",
|
|
110
|
+
},
|
|
111
|
+
undefined,
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
>
|
|
115
|
+
<Text
|
|
116
|
+
style={
|
|
117
|
+
Array [
|
|
118
|
+
Object {
|
|
119
|
+
"color": "#ffffff",
|
|
120
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
121
|
+
"fontSize": 16,
|
|
122
|
+
"overflow": "hidden",
|
|
123
|
+
},
|
|
124
|
+
undefined,
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
themeSize="small"
|
|
128
|
+
>
|
|
129
|
+
SS
|
|
130
|
+
</Text>
|
|
131
|
+
</View>
|
|
132
|
+
</View>
|
|
133
|
+
<View
|
|
134
|
+
accessible={true}
|
|
135
|
+
collapsable={false}
|
|
136
|
+
focusable={false}
|
|
137
|
+
nativeID="animatedComponent"
|
|
138
|
+
onClick={[Function]}
|
|
139
|
+
onResponderGrant={[Function]}
|
|
140
|
+
onResponderMove={[Function]}
|
|
141
|
+
onResponderRelease={[Function]}
|
|
142
|
+
onResponderTerminate={[Function]}
|
|
143
|
+
onResponderTerminationRequest={[Function]}
|
|
144
|
+
onStartShouldSetResponder={[Function]}
|
|
145
|
+
style={
|
|
146
|
+
Object {
|
|
147
|
+
"backgroundColor": "#401960",
|
|
148
|
+
"borderRadius": 999,
|
|
149
|
+
"height": 32,
|
|
150
|
+
"left": 44.8,
|
|
151
|
+
"opacity": 1,
|
|
152
|
+
"overflow": "hidden",
|
|
153
|
+
"position": "absolute",
|
|
154
|
+
"width": 32,
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
>
|
|
158
|
+
<View
|
|
159
|
+
style={
|
|
160
|
+
Array [
|
|
161
|
+
Object {
|
|
162
|
+
"alignItems": "center",
|
|
163
|
+
"display": "flex",
|
|
164
|
+
"height": "100%",
|
|
165
|
+
"justifyContent": "center",
|
|
166
|
+
"width": "100%",
|
|
167
|
+
},
|
|
168
|
+
undefined,
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
>
|
|
172
|
+
<Text
|
|
173
|
+
style={
|
|
174
|
+
Array [
|
|
175
|
+
Object {
|
|
176
|
+
"color": "#ffffff",
|
|
177
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
178
|
+
"fontSize": 16,
|
|
179
|
+
"overflow": "hidden",
|
|
180
|
+
},
|
|
181
|
+
undefined,
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
themeSize="small"
|
|
185
|
+
>
|
|
186
|
+
AA
|
|
187
|
+
</Text>
|
|
188
|
+
</View>
|
|
189
|
+
</View>
|
|
190
|
+
<View
|
|
191
|
+
accessible={true}
|
|
192
|
+
collapsable={false}
|
|
193
|
+
focusable={false}
|
|
194
|
+
nativeID="animatedComponent"
|
|
195
|
+
onClick={[Function]}
|
|
196
|
+
onResponderGrant={[Function]}
|
|
197
|
+
onResponderMove={[Function]}
|
|
198
|
+
onResponderRelease={[Function]}
|
|
199
|
+
onResponderTerminate={[Function]}
|
|
200
|
+
onResponderTerminationRequest={[Function]}
|
|
201
|
+
onStartShouldSetResponder={[Function]}
|
|
202
|
+
style={
|
|
203
|
+
Object {
|
|
204
|
+
"backgroundColor": "#401960",
|
|
205
|
+
"borderRadius": 999,
|
|
206
|
+
"height": 32,
|
|
207
|
+
"left": 67.19999999999999,
|
|
208
|
+
"opacity": 1,
|
|
209
|
+
"overflow": "hidden",
|
|
210
|
+
"position": "absolute",
|
|
211
|
+
"width": 32,
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
>
|
|
215
|
+
<View
|
|
216
|
+
style={
|
|
217
|
+
Array [
|
|
218
|
+
Object {
|
|
219
|
+
"alignItems": "center",
|
|
220
|
+
"display": "flex",
|
|
221
|
+
"height": "100%",
|
|
222
|
+
"justifyContent": "center",
|
|
223
|
+
"width": "100%",
|
|
224
|
+
},
|
|
225
|
+
undefined,
|
|
226
|
+
]
|
|
227
|
+
}
|
|
228
|
+
>
|
|
229
|
+
<Text
|
|
230
|
+
style={
|
|
231
|
+
Array [
|
|
232
|
+
Object {
|
|
233
|
+
"color": "#ffffff",
|
|
234
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
235
|
+
"fontSize": 16,
|
|
236
|
+
"overflow": "hidden",
|
|
237
|
+
},
|
|
238
|
+
undefined,
|
|
239
|
+
]
|
|
240
|
+
}
|
|
241
|
+
themeSize="small"
|
|
242
|
+
>
|
|
243
|
+
OO
|
|
244
|
+
</Text>
|
|
245
|
+
</View>
|
|
246
|
+
</View>
|
|
247
|
+
<View
|
|
248
|
+
accessible={true}
|
|
249
|
+
collapsable={false}
|
|
250
|
+
focusable={false}
|
|
251
|
+
nativeID="animatedComponent"
|
|
252
|
+
onClick={[Function]}
|
|
253
|
+
onResponderGrant={[Function]}
|
|
254
|
+
onResponderMove={[Function]}
|
|
255
|
+
onResponderRelease={[Function]}
|
|
256
|
+
onResponderTerminate={[Function]}
|
|
257
|
+
onResponderTerminationRequest={[Function]}
|
|
258
|
+
onStartShouldSetResponder={[Function]}
|
|
259
|
+
style={
|
|
260
|
+
Object {
|
|
261
|
+
"backgroundColor": "#401960",
|
|
262
|
+
"borderRadius": 999,
|
|
263
|
+
"height": 32,
|
|
264
|
+
"left": 89.6,
|
|
265
|
+
"opacity": 1,
|
|
266
|
+
"overflow": "hidden",
|
|
267
|
+
"position": "absolute",
|
|
268
|
+
"width": 32,
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
>
|
|
272
|
+
<View
|
|
273
|
+
style={
|
|
274
|
+
Array [
|
|
275
|
+
Object {
|
|
276
|
+
"alignItems": "center",
|
|
277
|
+
"display": "flex",
|
|
278
|
+
"height": "100%",
|
|
279
|
+
"justifyContent": "center",
|
|
280
|
+
"width": "100%",
|
|
281
|
+
},
|
|
282
|
+
undefined,
|
|
283
|
+
]
|
|
284
|
+
}
|
|
285
|
+
>
|
|
286
|
+
<Text
|
|
287
|
+
style={
|
|
288
|
+
Array [
|
|
289
|
+
Object {
|
|
290
|
+
"color": "#ffffff",
|
|
291
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
292
|
+
"fontSize": 16,
|
|
293
|
+
"overflow": "hidden",
|
|
294
|
+
},
|
|
295
|
+
undefined,
|
|
296
|
+
]
|
|
297
|
+
}
|
|
298
|
+
themeSize="small"
|
|
299
|
+
>
|
|
300
|
+
NA
|
|
301
|
+
</Text>
|
|
302
|
+
</View>
|
|
303
|
+
</View>
|
|
304
|
+
</View>
|
|
305
|
+
`;
|
|
306
|
+
|
|
307
|
+
exports[`AvatarStack renders correctly with custom props 1`] = `
|
|
308
|
+
<View
|
|
309
|
+
style={
|
|
310
|
+
Array [
|
|
311
|
+
Object {
|
|
312
|
+
"flexDirection": "row",
|
|
313
|
+
"height": 40,
|
|
314
|
+
"width": 123.99999999999999,
|
|
315
|
+
},
|
|
316
|
+
undefined,
|
|
317
|
+
]
|
|
318
|
+
}
|
|
319
|
+
testID="group-avatar"
|
|
320
|
+
themeAvatarCount={4}
|
|
321
|
+
themeSize="medium"
|
|
322
|
+
>
|
|
323
|
+
<View
|
|
324
|
+
accessible={true}
|
|
325
|
+
collapsable={false}
|
|
326
|
+
focusable={false}
|
|
327
|
+
nativeID="animatedComponent"
|
|
328
|
+
onClick={[Function]}
|
|
329
|
+
onResponderGrant={[Function]}
|
|
330
|
+
onResponderMove={[Function]}
|
|
331
|
+
onResponderRelease={[Function]}
|
|
332
|
+
onResponderTerminate={[Function]}
|
|
333
|
+
onResponderTerminationRequest={[Function]}
|
|
334
|
+
onStartShouldSetResponder={[Function]}
|
|
335
|
+
style={
|
|
336
|
+
Object {
|
|
337
|
+
"backgroundColor": "#401960",
|
|
338
|
+
"borderRadius": 999,
|
|
339
|
+
"height": 40,
|
|
340
|
+
"left": 0,
|
|
341
|
+
"opacity": 1,
|
|
342
|
+
"overflow": "hidden",
|
|
343
|
+
"position": "absolute",
|
|
344
|
+
"width": 40,
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
>
|
|
348
|
+
<View
|
|
349
|
+
style={
|
|
350
|
+
Array [
|
|
351
|
+
Object {
|
|
352
|
+
"alignItems": "center",
|
|
353
|
+
"display": "flex",
|
|
354
|
+
"height": "100%",
|
|
355
|
+
"justifyContent": "center",
|
|
356
|
+
"width": "100%",
|
|
357
|
+
},
|
|
358
|
+
undefined,
|
|
359
|
+
]
|
|
360
|
+
}
|
|
361
|
+
>
|
|
362
|
+
<Text
|
|
363
|
+
style={
|
|
364
|
+
Array [
|
|
365
|
+
Object {
|
|
366
|
+
"color": "#ffffff",
|
|
367
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
368
|
+
"fontSize": 18,
|
|
369
|
+
"overflow": "hidden",
|
|
370
|
+
},
|
|
371
|
+
undefined,
|
|
372
|
+
]
|
|
373
|
+
}
|
|
374
|
+
themeSize="medium"
|
|
375
|
+
>
|
|
376
|
+
TT
|
|
377
|
+
</Text>
|
|
378
|
+
</View>
|
|
379
|
+
</View>
|
|
380
|
+
<View
|
|
381
|
+
accessible={true}
|
|
382
|
+
collapsable={false}
|
|
383
|
+
focusable={false}
|
|
384
|
+
nativeID="animatedComponent"
|
|
385
|
+
onClick={[Function]}
|
|
386
|
+
onResponderGrant={[Function]}
|
|
387
|
+
onResponderMove={[Function]}
|
|
388
|
+
onResponderRelease={[Function]}
|
|
389
|
+
onResponderTerminate={[Function]}
|
|
390
|
+
onResponderTerminationRequest={[Function]}
|
|
391
|
+
onStartShouldSetResponder={[Function]}
|
|
392
|
+
style={
|
|
393
|
+
Object {
|
|
394
|
+
"backgroundColor": "#401960",
|
|
395
|
+
"borderRadius": 999,
|
|
396
|
+
"height": 40,
|
|
397
|
+
"left": 28,
|
|
398
|
+
"opacity": 1,
|
|
399
|
+
"overflow": "hidden",
|
|
400
|
+
"position": "absolute",
|
|
401
|
+
"width": 40,
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
>
|
|
405
|
+
<View
|
|
406
|
+
style={
|
|
407
|
+
Array [
|
|
408
|
+
Object {
|
|
409
|
+
"alignItems": "center",
|
|
410
|
+
"display": "flex",
|
|
411
|
+
"height": "100%",
|
|
412
|
+
"justifyContent": "center",
|
|
413
|
+
"width": "100%",
|
|
414
|
+
},
|
|
415
|
+
undefined,
|
|
416
|
+
]
|
|
417
|
+
}
|
|
418
|
+
>
|
|
419
|
+
<Text
|
|
420
|
+
style={
|
|
421
|
+
Array [
|
|
422
|
+
Object {
|
|
423
|
+
"color": "#ffffff",
|
|
424
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
425
|
+
"fontSize": 18,
|
|
426
|
+
"overflow": "hidden",
|
|
427
|
+
},
|
|
428
|
+
undefined,
|
|
429
|
+
]
|
|
430
|
+
}
|
|
431
|
+
themeSize="medium"
|
|
432
|
+
>
|
|
433
|
+
SS
|
|
434
|
+
</Text>
|
|
435
|
+
</View>
|
|
436
|
+
</View>
|
|
437
|
+
<View
|
|
438
|
+
accessible={true}
|
|
439
|
+
collapsable={false}
|
|
440
|
+
focusable={false}
|
|
441
|
+
nativeID="animatedComponent"
|
|
442
|
+
onClick={[Function]}
|
|
443
|
+
onResponderGrant={[Function]}
|
|
444
|
+
onResponderMove={[Function]}
|
|
445
|
+
onResponderRelease={[Function]}
|
|
446
|
+
onResponderTerminate={[Function]}
|
|
447
|
+
onResponderTerminationRequest={[Function]}
|
|
448
|
+
onStartShouldSetResponder={[Function]}
|
|
449
|
+
style={
|
|
450
|
+
Object {
|
|
451
|
+
"backgroundColor": "#401960",
|
|
452
|
+
"borderRadius": 999,
|
|
453
|
+
"height": 40,
|
|
454
|
+
"left": 56,
|
|
455
|
+
"opacity": 1,
|
|
456
|
+
"overflow": "hidden",
|
|
457
|
+
"position": "absolute",
|
|
458
|
+
"width": 40,
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
>
|
|
462
|
+
<View
|
|
463
|
+
style={
|
|
464
|
+
Array [
|
|
465
|
+
Object {
|
|
466
|
+
"alignItems": "center",
|
|
467
|
+
"display": "flex",
|
|
468
|
+
"height": "100%",
|
|
469
|
+
"justifyContent": "center",
|
|
470
|
+
"width": "100%",
|
|
471
|
+
},
|
|
472
|
+
undefined,
|
|
473
|
+
]
|
|
474
|
+
}
|
|
475
|
+
>
|
|
476
|
+
<Text
|
|
477
|
+
style={
|
|
478
|
+
Array [
|
|
479
|
+
Object {
|
|
480
|
+
"color": "#ffffff",
|
|
481
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
482
|
+
"fontSize": 18,
|
|
483
|
+
"overflow": "hidden",
|
|
484
|
+
},
|
|
485
|
+
undefined,
|
|
486
|
+
]
|
|
487
|
+
}
|
|
488
|
+
themeSize="medium"
|
|
489
|
+
>
|
|
490
|
+
AA
|
|
491
|
+
</Text>
|
|
492
|
+
</View>
|
|
493
|
+
</View>
|
|
494
|
+
<View
|
|
495
|
+
accessible={true}
|
|
496
|
+
collapsable={false}
|
|
497
|
+
focusable={false}
|
|
498
|
+
nativeID="animatedComponent"
|
|
499
|
+
onClick={[Function]}
|
|
500
|
+
onResponderGrant={[Function]}
|
|
501
|
+
onResponderMove={[Function]}
|
|
502
|
+
onResponderRelease={[Function]}
|
|
503
|
+
onResponderTerminate={[Function]}
|
|
504
|
+
onResponderTerminationRequest={[Function]}
|
|
505
|
+
onStartShouldSetResponder={[Function]}
|
|
506
|
+
style={
|
|
507
|
+
Object {
|
|
508
|
+
"backgroundColor": "#401960",
|
|
509
|
+
"borderRadius": 999,
|
|
510
|
+
"height": 40,
|
|
511
|
+
"left": 84,
|
|
512
|
+
"opacity": 1,
|
|
513
|
+
"overflow": "hidden",
|
|
514
|
+
"position": "absolute",
|
|
515
|
+
"width": 40,
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
>
|
|
519
|
+
<View
|
|
520
|
+
style={
|
|
521
|
+
Array [
|
|
522
|
+
Object {
|
|
523
|
+
"alignItems": "center",
|
|
524
|
+
"display": "flex",
|
|
525
|
+
"height": "100%",
|
|
526
|
+
"justifyContent": "center",
|
|
527
|
+
"width": "100%",
|
|
528
|
+
},
|
|
529
|
+
undefined,
|
|
530
|
+
]
|
|
531
|
+
}
|
|
532
|
+
>
|
|
533
|
+
<Text
|
|
534
|
+
style={
|
|
535
|
+
Array [
|
|
536
|
+
Object {
|
|
537
|
+
"color": "#ffffff",
|
|
538
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
539
|
+
"fontSize": 18,
|
|
540
|
+
"overflow": "hidden",
|
|
541
|
+
},
|
|
542
|
+
undefined,
|
|
543
|
+
]
|
|
544
|
+
}
|
|
545
|
+
themeSize="medium"
|
|
546
|
+
>
|
|
547
|
+
+2
|
|
548
|
+
</Text>
|
|
549
|
+
</View>
|
|
550
|
+
</View>
|
|
551
|
+
</View>
|
|
552
|
+
`;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderWithTheme from '../../../../testHelpers/renderWithTheme';
|
|
3
|
+
import Avatar from '../..';
|
|
4
|
+
import theme from '../../../../theme';
|
|
5
|
+
|
|
6
|
+
beforeAll(() => {
|
|
7
|
+
theme.__hd__.avatar.colors.visualisation = [theme.colors.primary];
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
describe('AvatarStack', () => {
|
|
11
|
+
it('renders correctly by default', () => {
|
|
12
|
+
const wrapper = renderWithTheme(
|
|
13
|
+
<Avatar.Stack testID="group-avatar">
|
|
14
|
+
<Avatar title="TT" />
|
|
15
|
+
<Avatar title="SS" />
|
|
16
|
+
<Avatar title="AA" />
|
|
17
|
+
<Avatar title="OO" />
|
|
18
|
+
<Avatar title="NA" />
|
|
19
|
+
</Avatar.Stack>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
expect(wrapper.queryAllByText('TT')).toHaveLength(1);
|
|
23
|
+
expect(wrapper.queryAllByText('SS')).toHaveLength(1);
|
|
24
|
+
expect(wrapper.queryAllByText('AA')).toHaveLength(1);
|
|
25
|
+
expect(wrapper.queryAllByText('OO')).toHaveLength(1);
|
|
26
|
+
expect(wrapper.queryAllByText('NA')).toHaveLength(1);
|
|
27
|
+
expect(wrapper.getByTestId('group-avatar')).toHaveStyle({
|
|
28
|
+
width: 121.6,
|
|
29
|
+
height: 32,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('renders correctly with custom props', () => {
|
|
36
|
+
const wrapper = renderWithTheme(
|
|
37
|
+
<Avatar.Stack max={3} size="medium" testID="group-avatar">
|
|
38
|
+
<Avatar title="TT" />
|
|
39
|
+
<Avatar title="SS" />
|
|
40
|
+
<Avatar title="AA" />
|
|
41
|
+
<Avatar title="OO" />
|
|
42
|
+
<Avatar title="NA" />
|
|
43
|
+
</Avatar.Stack>
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
expect(wrapper.queryAllByText('TT')).toHaveLength(1);
|
|
47
|
+
expect(wrapper.queryAllByText('SS')).toHaveLength(1);
|
|
48
|
+
expect(wrapper.queryAllByText('AA')).toHaveLength(1);
|
|
49
|
+
expect(wrapper.queryAllByText('+2')).toHaveLength(1);
|
|
50
|
+
expect(wrapper.queryAllByText('OO')).toHaveLength(0);
|
|
51
|
+
expect(wrapper.queryAllByText('NA')).toHaveLength(0);
|
|
52
|
+
expect(wrapper.getByTestId('group-avatar')).toHaveStyle({
|
|
53
|
+
width: 40 * (1 + 0.7 * 3),
|
|
54
|
+
height: 40,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import Avatar, { AvatarProps } from '../Avatar';
|
|
4
|
+
import { StyledAvatar, StyledWrapper } from './StyledAvatarStack';
|
|
5
|
+
import { useAvatarColors } from './utils';
|
|
6
|
+
|
|
7
|
+
export interface AvatarStackProps extends Pick<AvatarProps, 'size'> {
|
|
8
|
+
/**
|
|
9
|
+
* Avatar elements to be rendered.
|
|
10
|
+
*/
|
|
11
|
+
children: ReactElement<Omit<AvatarProps, 'size' | 'style'>>[];
|
|
12
|
+
/**
|
|
13
|
+
* Max avatars to show.
|
|
14
|
+
*/
|
|
15
|
+
max?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Additional style.
|
|
18
|
+
*/
|
|
19
|
+
style?: StyleProp<ViewStyle>;
|
|
20
|
+
/**
|
|
21
|
+
* Testing id of the component.
|
|
22
|
+
*/
|
|
23
|
+
testID?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const AvatarStack = ({
|
|
27
|
+
children,
|
|
28
|
+
max,
|
|
29
|
+
size = 'small',
|
|
30
|
+
style,
|
|
31
|
+
testID,
|
|
32
|
+
}: AvatarStackProps) => {
|
|
33
|
+
const colors = useAvatarColors();
|
|
34
|
+
const avatars = children.slice(0, max);
|
|
35
|
+
if (max !== undefined && children.length - max > 0) {
|
|
36
|
+
const remainingAvatar = (
|
|
37
|
+
<Avatar title={`+${children.length - max}`} size={size} />
|
|
38
|
+
);
|
|
39
|
+
avatars.push(remainingAvatar);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<StyledWrapper
|
|
44
|
+
themeSize={size}
|
|
45
|
+
themeAvatarCount={avatars.length}
|
|
46
|
+
style={style}
|
|
47
|
+
testID={testID}
|
|
48
|
+
>
|
|
49
|
+
{avatars.map((avt, index) => (
|
|
50
|
+
<StyledAvatar
|
|
51
|
+
{...avt.props}
|
|
52
|
+
size={size}
|
|
53
|
+
themeIndex={index}
|
|
54
|
+
style={{ backgroundColor: colors[index % colors.length] }}
|
|
55
|
+
/>
|
|
56
|
+
))}
|
|
57
|
+
</StyledWrapper>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default AvatarStack;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useTheme } from '../../../theme';
|
|
3
|
+
|
|
4
|
+
const shuffleArray = <T>(array: Array<T>): Array<T> =>
|
|
5
|
+
array
|
|
6
|
+
.map((value) => ({ value, sort: Math.random() }))
|
|
7
|
+
.sort((a, b) => a.sort - b.sort)
|
|
8
|
+
.map(({ value }) => value);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Hook that returns a memoized and shuffled array of visualisation colors for Avatar.
|
|
12
|
+
*/
|
|
13
|
+
export const useAvatarColors = () => {
|
|
14
|
+
const theme = useTheme();
|
|
15
|
+
const visualisationColors = theme.__hd__.avatar.colors.visualisation;
|
|
16
|
+
const shuffledColors = useMemo(
|
|
17
|
+
() => shuffleArray(visualisationColors),
|
|
18
|
+
[visualisationColors]
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
return shuffledColors;
|
|
22
|
+
};
|