@hero-design/rn 7.25.1 → 7.27.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/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/es/index.js +9212 -12310
- package/jest.config.js +6 -2
- package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/lib/index.js +9212 -12309
- package/package.json +4 -4
- 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/Accordion/index.tsx +1 -1
- 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/Card/index.tsx +18 -7
- 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/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/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 +40 -15
- 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/SingleSelect/index.tsx +5 -2
- package/src/components/Select/__tests__/__snapshots__/StyledSelect.spec.tsx.snap +1 -0
- package/src/components/Select/types.ts +15 -6
- 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/ScrollableTabs.tsx +2 -0
- package/src/components/Tabs/__tests__/ScrollableTabs.spec.tsx +1 -1
- 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/Tabs/__tests__/index.spec.tsx +1 -1
- package/src/components/Tabs/index.tsx +7 -0
- package/src/components/Tag/StyledTag.tsx +42 -11
- package/src/components/Tag/__tests__/Tag.spec.tsx +28 -0
- package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +135 -0
- package/src/components/Tag/index.tsx +15 -3
- 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 +86 -22
- 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 +2 -1
- package/src/theme/components/toolbar.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/src/utils/hooks.ts +18 -1
- 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/Card/index.d.ts +1 -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/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 +5 -2
- package/types/components/Select/SingleSelect/index.d.ts +1 -1
- package/types/components/Select/index.d.ts +1 -1
- package/types/components/Select/types.d.ts +15 -3
- package/types/components/Tabs/ScrollableTabs.d.ts +1 -1
- package/types/components/Tabs/index.d.ts +7 -2
- package/types/components/Tag/StyledTag.d.ts +3 -0
- package/types/components/Tag/index.d.ts +7 -2
- 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/tag.d.ts +1 -0
- 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/types/utils/hooks.d.ts +2 -0
- package/src/components/Accordion/utils.tsx +0 -11
- package/types/components/Accordion/utils.d.ts +0 -1
|
@@ -12,25 +12,12 @@ type ThemeSize =
|
|
|
12
12
|
| 'xxxxxlarge';
|
|
13
13
|
type ThemeIntent = 'primary' | 'info' | 'danger' | 'success' | 'warning';
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const StyledWrapper = styled(TouchableOpacity)<{
|
|
16
16
|
themeSize: ThemeSize;
|
|
17
17
|
themeIntent: ThemeIntent;
|
|
18
18
|
}>(({ themeSize, themeIntent, theme }) => ({
|
|
19
|
-
borderWidth: theme.__hd__.avatar.borderWidths.default,
|
|
20
19
|
borderRadius: theme.__hd__.avatar.radii.rounded,
|
|
21
|
-
|
|
22
|
-
width: theme.__hd__.avatar.sizes[themeSize],
|
|
23
|
-
height: theme.__hd__.avatar.sizes[themeSize],
|
|
24
|
-
overflow: 'hidden',
|
|
25
|
-
}));
|
|
26
|
-
|
|
27
|
-
const StyledView = styled(View)<{
|
|
28
|
-
themeSize: ThemeSize;
|
|
29
|
-
themeIntent: ThemeIntent;
|
|
30
|
-
}>(({ themeSize, themeIntent, theme }) => ({
|
|
31
|
-
borderWidth: theme.__hd__.avatar.borderWidths.default,
|
|
32
|
-
borderRadius: theme.__hd__.avatar.radii.rounded,
|
|
33
|
-
borderColor: theme.__hd__.avatar.colors[themeIntent],
|
|
20
|
+
backgroundColor: theme.__hd__.avatar.colors[themeIntent],
|
|
34
21
|
width: theme.__hd__.avatar.sizes[themeSize],
|
|
35
22
|
height: theme.__hd__.avatar.sizes[themeSize],
|
|
36
23
|
overflow: 'hidden',
|
|
@@ -46,10 +33,10 @@ const StyledTextWrapper = styled(View)(() => ({
|
|
|
46
33
|
|
|
47
34
|
const StyledText = styled(Text)<{
|
|
48
35
|
themeSize: ThemeSize;
|
|
49
|
-
|
|
50
|
-
|
|
36
|
+
}>(({ themeSize, theme }) => ({
|
|
37
|
+
fontFamily: theme.__hd__.avatar.fonts.default,
|
|
51
38
|
fontSize: theme.__hd__.avatar.fontSizes[themeSize],
|
|
52
|
-
color: theme.__hd__.avatar.colors
|
|
39
|
+
color: theme.__hd__.avatar.colors.text,
|
|
53
40
|
overflow: 'hidden',
|
|
54
41
|
}));
|
|
55
42
|
|
|
@@ -60,10 +47,4 @@ const StyledImage = styled(Image)<{
|
|
|
60
47
|
height: theme.__hd__.avatar.sizes[themeSize],
|
|
61
48
|
}));
|
|
62
49
|
|
|
63
|
-
export {
|
|
64
|
-
StyledPressable,
|
|
65
|
-
StyledView,
|
|
66
|
-
StyledImage,
|
|
67
|
-
StyledTextWrapper,
|
|
68
|
-
StyledText,
|
|
69
|
-
};
|
|
50
|
+
export { StyledWrapper, StyledImage, StyledTextWrapper, StyledText };
|
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
3
|
-
import {
|
|
4
|
-
StyledView,
|
|
5
|
-
StyledPressable,
|
|
6
|
-
StyledImage,
|
|
7
|
-
StyledText,
|
|
8
|
-
} from '../StyledAvatar';
|
|
3
|
+
import { StyledWrapper, StyledImage, StyledText } from '../StyledAvatar';
|
|
9
4
|
|
|
10
5
|
describe('StyledPressable', () => {
|
|
11
6
|
it('renders correct style', () => {
|
|
12
7
|
const { toJSON } = renderWithTheme(
|
|
13
|
-
<
|
|
14
|
-
);
|
|
15
|
-
expect(toJSON()).toMatchSnapshot();
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
describe('StyledView', () => {
|
|
20
|
-
it('renders correct style', () => {
|
|
21
|
-
const { toJSON } = renderWithTheme(
|
|
22
|
-
<StyledView themeIntent="primary" themeSize="small" />
|
|
8
|
+
<StyledWrapper themeIntent="primary" themeSize="small" />
|
|
23
9
|
);
|
|
24
10
|
expect(toJSON()).toMatchSnapshot();
|
|
25
11
|
});
|
|
@@ -29,9 +15,7 @@ describe('StyledText', () => {
|
|
|
29
15
|
it('renders correct style', () => {
|
|
30
16
|
const text = 'MD';
|
|
31
17
|
const { toJSON } = renderWithTheme(
|
|
32
|
-
<StyledText themeSize="small"
|
|
33
|
-
{text}
|
|
34
|
-
</StyledText>
|
|
18
|
+
<StyledText themeSize="small">{text}</StyledText>
|
|
35
19
|
);
|
|
36
20
|
expect(toJSON()).toMatchSnapshot();
|
|
37
21
|
});
|
|
@@ -35,9 +35,8 @@ exports[`StyledPressable renders correct style 1`] = `
|
|
|
35
35
|
onStartShouldSetResponder={[Function]}
|
|
36
36
|
style={
|
|
37
37
|
Object {
|
|
38
|
-
"
|
|
38
|
+
"backgroundColor": "#401960",
|
|
39
39
|
"borderRadius": 999,
|
|
40
|
-
"borderWidth": 1,
|
|
41
40
|
"height": 32,
|
|
42
41
|
"opacity": 1,
|
|
43
42
|
"overflow": "hidden",
|
|
@@ -52,36 +51,16 @@ exports[`StyledText renders correct style 1`] = `
|
|
|
52
51
|
style={
|
|
53
52
|
Array [
|
|
54
53
|
Object {
|
|
55
|
-
"color": "#
|
|
54
|
+
"color": "#ffffff",
|
|
55
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
56
56
|
"fontSize": 16,
|
|
57
57
|
"overflow": "hidden",
|
|
58
58
|
},
|
|
59
59
|
undefined,
|
|
60
60
|
]
|
|
61
61
|
}
|
|
62
|
-
themeIntent="primary"
|
|
63
62
|
themeSize="small"
|
|
64
63
|
>
|
|
65
64
|
MD
|
|
66
65
|
</Text>
|
|
67
66
|
`;
|
|
68
|
-
|
|
69
|
-
exports[`StyledView renders correct style 1`] = `
|
|
70
|
-
<View
|
|
71
|
-
style={
|
|
72
|
-
Array [
|
|
73
|
-
Object {
|
|
74
|
-
"borderColor": "#401960",
|
|
75
|
-
"borderRadius": 999,
|
|
76
|
-
"borderWidth": 1,
|
|
77
|
-
"height": 32,
|
|
78
|
-
"overflow": "hidden",
|
|
79
|
-
"width": 32,
|
|
80
|
-
},
|
|
81
|
-
undefined,
|
|
82
|
-
]
|
|
83
|
-
}
|
|
84
|
-
themeIntent="primary"
|
|
85
|
-
themeSize="small"
|
|
86
|
-
/>
|
|
87
|
-
`;
|
|
@@ -1,29 +1,65 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`Avatar
|
|
3
|
+
exports[`Avatar fallbacks to title when there image failed to load 1`] = `
|
|
4
4
|
<View
|
|
5
|
+
accessible={true}
|
|
6
|
+
focusable={false}
|
|
7
|
+
onClick={[Function]}
|
|
8
|
+
onResponderGrant={[Function]}
|
|
9
|
+
onResponderMove={[Function]}
|
|
10
|
+
onResponderRelease={[Function]}
|
|
11
|
+
onResponderTerminate={[Function]}
|
|
12
|
+
onResponderTerminationRequest={[Function]}
|
|
13
|
+
onStartShouldSetResponder={[Function]}
|
|
5
14
|
style={
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
15
|
-
undefined,
|
|
16
|
-
]
|
|
15
|
+
Object {
|
|
16
|
+
"backgroundColor": "#401960",
|
|
17
|
+
"borderRadius": 999,
|
|
18
|
+
"height": 32,
|
|
19
|
+
"opacity": 1,
|
|
20
|
+
"overflow": "hidden",
|
|
21
|
+
"width": 32,
|
|
22
|
+
}
|
|
17
23
|
}
|
|
18
|
-
testID="avatar"
|
|
19
|
-
themeIntent="primary"
|
|
20
|
-
themeSize="small"
|
|
21
24
|
>
|
|
25
|
+
<View
|
|
26
|
+
style={
|
|
27
|
+
Array [
|
|
28
|
+
Object {
|
|
29
|
+
"alignItems": "center",
|
|
30
|
+
"display": "flex",
|
|
31
|
+
"height": "100%",
|
|
32
|
+
"justifyContent": "center",
|
|
33
|
+
"width": "100%",
|
|
34
|
+
},
|
|
35
|
+
undefined,
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
>
|
|
39
|
+
<Text
|
|
40
|
+
style={
|
|
41
|
+
Array [
|
|
42
|
+
Object {
|
|
43
|
+
"color": "#ffffff",
|
|
44
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
45
|
+
"fontSize": 16,
|
|
46
|
+
"overflow": "hidden",
|
|
47
|
+
},
|
|
48
|
+
undefined,
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
themeSize="small"
|
|
52
|
+
>
|
|
53
|
+
TT
|
|
54
|
+
</Text>
|
|
55
|
+
</View>
|
|
22
56
|
<Image
|
|
57
|
+
onError={[Function]}
|
|
58
|
+
onLoad={[Function]}
|
|
23
59
|
resizeMode="cover"
|
|
24
60
|
source={
|
|
25
61
|
Object {
|
|
26
|
-
"uri": "
|
|
62
|
+
"uri": "error URI",
|
|
27
63
|
}
|
|
28
64
|
}
|
|
29
65
|
style={
|
|
@@ -35,16 +71,17 @@ exports[`Avatar renders correctly 1`] = `
|
|
|
35
71
|
undefined,
|
|
36
72
|
]
|
|
37
73
|
}
|
|
74
|
+
testID="avatar-image"
|
|
38
75
|
themeSize="small"
|
|
39
76
|
/>
|
|
40
77
|
</View>
|
|
41
78
|
`;
|
|
42
79
|
|
|
43
|
-
exports[`Avatar
|
|
80
|
+
exports[`Avatar prioritizes source over title 1`] = `
|
|
44
81
|
<View
|
|
45
82
|
accessible={true}
|
|
46
83
|
collapsable={false}
|
|
47
|
-
focusable={
|
|
84
|
+
focusable={false}
|
|
48
85
|
nativeID="animatedComponent"
|
|
49
86
|
onClick={[Function]}
|
|
50
87
|
onResponderGrant={[Function]}
|
|
@@ -55,9 +92,8 @@ exports[`Avatar trigger press function correctly 1`] = `
|
|
|
55
92
|
onStartShouldSetResponder={[Function]}
|
|
56
93
|
style={
|
|
57
94
|
Object {
|
|
58
|
-
"
|
|
95
|
+
"backgroundColor": "#401960",
|
|
59
96
|
"borderRadius": 999,
|
|
60
|
-
"borderWidth": 1,
|
|
61
97
|
"height": 32,
|
|
62
98
|
"opacity": 1,
|
|
63
99
|
"overflow": "hidden",
|
|
@@ -67,6 +103,8 @@ exports[`Avatar trigger press function correctly 1`] = `
|
|
|
67
103
|
testID="avatar"
|
|
68
104
|
>
|
|
69
105
|
<Image
|
|
106
|
+
onError={[Function]}
|
|
107
|
+
onLoad={[Function]}
|
|
70
108
|
resizeMode="cover"
|
|
71
109
|
source={
|
|
72
110
|
Object {
|
|
@@ -82,7 +120,67 @@ exports[`Avatar trigger press function correctly 1`] = `
|
|
|
82
120
|
undefined,
|
|
83
121
|
]
|
|
84
122
|
}
|
|
123
|
+
testID="avatar-image"
|
|
85
124
|
themeSize="small"
|
|
86
125
|
/>
|
|
87
126
|
</View>
|
|
88
127
|
`;
|
|
128
|
+
|
|
129
|
+
exports[`Avatar shows title when there is no source 1`] = `
|
|
130
|
+
<View
|
|
131
|
+
accessible={true}
|
|
132
|
+
collapsable={false}
|
|
133
|
+
focusable={false}
|
|
134
|
+
nativeID="animatedComponent"
|
|
135
|
+
onClick={[Function]}
|
|
136
|
+
onResponderGrant={[Function]}
|
|
137
|
+
onResponderMove={[Function]}
|
|
138
|
+
onResponderRelease={[Function]}
|
|
139
|
+
onResponderTerminate={[Function]}
|
|
140
|
+
onResponderTerminationRequest={[Function]}
|
|
141
|
+
onStartShouldSetResponder={[Function]}
|
|
142
|
+
style={
|
|
143
|
+
Object {
|
|
144
|
+
"backgroundColor": "#401960",
|
|
145
|
+
"borderRadius": 999,
|
|
146
|
+
"height": 32,
|
|
147
|
+
"opacity": 1,
|
|
148
|
+
"overflow": "hidden",
|
|
149
|
+
"width": 32,
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
testID="avatar"
|
|
153
|
+
>
|
|
154
|
+
<View
|
|
155
|
+
style={
|
|
156
|
+
Array [
|
|
157
|
+
Object {
|
|
158
|
+
"alignItems": "center",
|
|
159
|
+
"display": "flex",
|
|
160
|
+
"height": "100%",
|
|
161
|
+
"justifyContent": "center",
|
|
162
|
+
"width": "100%",
|
|
163
|
+
},
|
|
164
|
+
undefined,
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
>
|
|
168
|
+
<Text
|
|
169
|
+
style={
|
|
170
|
+
Array [
|
|
171
|
+
Object {
|
|
172
|
+
"color": "#ffffff",
|
|
173
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
174
|
+
"fontSize": 16,
|
|
175
|
+
"overflow": "hidden",
|
|
176
|
+
},
|
|
177
|
+
undefined,
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
themeSize="small"
|
|
181
|
+
>
|
|
182
|
+
TT
|
|
183
|
+
</Text>
|
|
184
|
+
</View>
|
|
185
|
+
</View>
|
|
186
|
+
`;
|
|
@@ -4,23 +4,40 @@ import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
|
4
4
|
import Avatar from '..';
|
|
5
5
|
|
|
6
6
|
describe('Avatar', () => {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
it('prioritizes source over title', () => {
|
|
8
|
+
const wrapper = renderWithTheme(
|
|
9
|
+
<Avatar
|
|
10
|
+
testID="avatar"
|
|
11
|
+
source={{ uri: 'https://i.pravatar.cc/300' }}
|
|
12
|
+
title="TT"
|
|
13
|
+
/>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
17
|
+
});
|
|
9
18
|
|
|
10
|
-
it('
|
|
11
|
-
const wrapper = renderWithTheme(<Avatar testID="avatar"
|
|
12
|
-
expect(wrapper.queryAllByTestId('avatar')).toHaveLength(1);
|
|
19
|
+
it('shows title when there is no source', () => {
|
|
20
|
+
const wrapper = renderWithTheme(<Avatar testID="avatar" title="TT" />);
|
|
13
21
|
|
|
22
|
+
expect(wrapper.queryAllByText('TT')).toHaveLength(1);
|
|
14
23
|
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
15
24
|
});
|
|
16
25
|
|
|
17
|
-
it('
|
|
26
|
+
it('fallbacks to title when there image failed to load', () => {
|
|
18
27
|
const wrapper = renderWithTheme(
|
|
19
|
-
<Avatar
|
|
28
|
+
<Avatar source={{ uri: 'error URI' }} title="TT" />
|
|
20
29
|
);
|
|
21
|
-
fireEvent.press(wrapper.getByTestId('avatar'));
|
|
22
30
|
|
|
31
|
+
fireEvent(wrapper.getByTestId('avatar-image'), 'error');
|
|
32
|
+
expect(wrapper.queryAllByText('TT')).toHaveLength(1);
|
|
23
33
|
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('triggers press function correctly', () => {
|
|
37
|
+
const pressFn = jest.fn();
|
|
38
|
+
const wrapper = renderWithTheme(<Avatar title="TT" onPress={pressFn} />);
|
|
39
|
+
|
|
40
|
+
fireEvent.press(wrapper.getByText('TT'));
|
|
24
41
|
expect(pressFn).toBeCalled();
|
|
25
42
|
});
|
|
26
43
|
});
|
|
@@ -155,6 +155,7 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
155
155
|
themeFontSize="small"
|
|
156
156
|
themeFontWeight="semi-bold"
|
|
157
157
|
themeIntent="primary"
|
|
158
|
+
themeTypeface="neutral"
|
|
158
159
|
>
|
|
159
160
|
Home
|
|
160
161
|
</Text>
|
|
@@ -216,6 +217,7 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
216
217
|
themeFontSize="small"
|
|
217
218
|
themeFontWeight="semi-bold"
|
|
218
219
|
themeIntent="body"
|
|
220
|
+
themeTypeface="neutral"
|
|
219
221
|
>
|
|
220
222
|
Feed
|
|
221
223
|
</Text>
|
|
@@ -277,6 +279,7 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
277
279
|
themeFontSize="small"
|
|
278
280
|
themeFontWeight="semi-bold"
|
|
279
281
|
themeIntent="body"
|
|
282
|
+
themeTypeface="neutral"
|
|
280
283
|
>
|
|
281
284
|
Alerts
|
|
282
285
|
</Text>
|
|
@@ -338,6 +341,7 @@ exports[`BottomNavigation renders correctly 1`] = `
|
|
|
338
341
|
themeFontSize="small"
|
|
339
342
|
themeFontWeight="semi-bold"
|
|
340
343
|
themeIntent="body"
|
|
344
|
+
themeTypeface="neutral"
|
|
341
345
|
>
|
|
342
346
|
Profile
|
|
343
347
|
</Text>
|
|
@@ -135,6 +135,7 @@ exports[`BottomSheet renders correctly with close state 1`] = `
|
|
|
135
135
|
themeFontSize="large"
|
|
136
136
|
themeFontWeight="semi-bold"
|
|
137
137
|
themeIntent="body"
|
|
138
|
+
themeTypeface="neutral"
|
|
138
139
|
>
|
|
139
140
|
Title
|
|
140
141
|
</Text>
|
|
@@ -417,6 +418,7 @@ exports[`BottomSheet renders correctly with open state 1`] = `
|
|
|
417
418
|
themeFontSize="large"
|
|
418
419
|
themeFontWeight="semi-bold"
|
|
419
420
|
themeIntent="body"
|
|
421
|
+
themeTypeface="neutral"
|
|
420
422
|
>
|
|
421
423
|
Title
|
|
422
424
|
</Text>
|
|
@@ -77,6 +77,7 @@ exports[`UtilityButton snapshot has intent primary style 1`] = `
|
|
|
77
77
|
themeFontSize="medium"
|
|
78
78
|
themeFontWeight="regular"
|
|
79
79
|
themeIntent="body"
|
|
80
|
+
themeTypeface="neutral"
|
|
80
81
|
>
|
|
81
82
|
Settings
|
|
82
83
|
</Text>
|
|
@@ -160,6 +161,7 @@ exports[`UtilityButton snapshot has intent text style 1`] = `
|
|
|
160
161
|
themeFontSize="medium"
|
|
161
162
|
themeFontWeight="regular"
|
|
162
163
|
themeIntent="body"
|
|
164
|
+
themeTypeface="neutral"
|
|
163
165
|
>
|
|
164
166
|
Settings
|
|
165
167
|
</Text>
|
|
@@ -668,6 +668,7 @@ exports[`StyledButtonText has basic-transparent style 1`] = `
|
|
|
668
668
|
themeFontSize="medium"
|
|
669
669
|
themeFontWeight="regular"
|
|
670
670
|
themeIntent="body"
|
|
671
|
+
themeTypeface="neutral"
|
|
671
672
|
themeVariant="basic-transparent"
|
|
672
673
|
>
|
|
673
674
|
Example
|
|
@@ -701,6 +702,7 @@ exports[`StyledButtonText has filled-danger style 1`] = `
|
|
|
701
702
|
themeFontSize="medium"
|
|
702
703
|
themeFontWeight="regular"
|
|
703
704
|
themeIntent="body"
|
|
705
|
+
themeTypeface="neutral"
|
|
704
706
|
themeVariant="filled-danger"
|
|
705
707
|
>
|
|
706
708
|
Example
|
|
@@ -734,6 +736,7 @@ exports[`StyledButtonText has filled-primary style 1`] = `
|
|
|
734
736
|
themeFontSize="medium"
|
|
735
737
|
themeFontWeight="regular"
|
|
736
738
|
themeIntent="body"
|
|
739
|
+
themeTypeface="neutral"
|
|
737
740
|
themeVariant="filled-primary"
|
|
738
741
|
>
|
|
739
742
|
Example
|
|
@@ -767,6 +770,7 @@ exports[`StyledButtonText has filled-secondary style 1`] = `
|
|
|
767
770
|
themeFontSize="medium"
|
|
768
771
|
themeFontWeight="regular"
|
|
769
772
|
themeIntent="body"
|
|
773
|
+
themeTypeface="neutral"
|
|
770
774
|
themeVariant="filled-secondary"
|
|
771
775
|
>
|
|
772
776
|
Example
|
|
@@ -800,6 +804,7 @@ exports[`StyledButtonText has outlined-danger style 1`] = `
|
|
|
800
804
|
themeFontSize="medium"
|
|
801
805
|
themeFontWeight="regular"
|
|
802
806
|
themeIntent="body"
|
|
807
|
+
themeTypeface="neutral"
|
|
803
808
|
themeVariant="outlined-danger"
|
|
804
809
|
>
|
|
805
810
|
Example
|
|
@@ -833,6 +838,7 @@ exports[`StyledButtonText has outlined-primary style 1`] = `
|
|
|
833
838
|
themeFontSize="medium"
|
|
834
839
|
themeFontWeight="regular"
|
|
835
840
|
themeIntent="body"
|
|
841
|
+
themeTypeface="neutral"
|
|
836
842
|
themeVariant="outlined-primary"
|
|
837
843
|
>
|
|
838
844
|
Example
|
|
@@ -866,6 +872,7 @@ exports[`StyledButtonText has outlined-secondary style 1`] = `
|
|
|
866
872
|
themeFontSize="medium"
|
|
867
873
|
themeFontWeight="regular"
|
|
868
874
|
themeIntent="body"
|
|
875
|
+
themeTypeface="neutral"
|
|
869
876
|
themeVariant="outlined-secondary"
|
|
870
877
|
>
|
|
871
878
|
Example
|
|
@@ -899,6 +906,7 @@ exports[`StyledButtonText has text-danger style 1`] = `
|
|
|
899
906
|
themeFontSize="medium"
|
|
900
907
|
themeFontWeight="regular"
|
|
901
908
|
themeIntent="body"
|
|
909
|
+
themeTypeface="neutral"
|
|
902
910
|
themeVariant="text-danger"
|
|
903
911
|
>
|
|
904
912
|
Example
|
|
@@ -932,6 +940,7 @@ exports[`StyledButtonText has text-primary style 1`] = `
|
|
|
932
940
|
themeFontSize="medium"
|
|
933
941
|
themeFontWeight="regular"
|
|
934
942
|
themeIntent="body"
|
|
943
|
+
themeTypeface="neutral"
|
|
935
944
|
themeVariant="text-primary"
|
|
936
945
|
>
|
|
937
946
|
Example
|
|
@@ -965,6 +974,7 @@ exports[`StyledButtonText has text-secondary style 1`] = `
|
|
|
965
974
|
themeFontSize="medium"
|
|
966
975
|
themeFontWeight="regular"
|
|
967
976
|
themeIntent="body"
|
|
977
|
+
themeTypeface="neutral"
|
|
968
978
|
themeVariant="text-secondary"
|
|
969
979
|
>
|
|
970
980
|
Example
|
|
@@ -999,6 +1009,7 @@ exports[`StyledButtonText renders disabled correctly 1`] = `
|
|
|
999
1009
|
themeFontSize="medium"
|
|
1000
1010
|
themeFontWeight="regular"
|
|
1001
1011
|
themeIntent="body"
|
|
1012
|
+
themeTypeface="neutral"
|
|
1002
1013
|
themeVariant="filled-primary"
|
|
1003
1014
|
>
|
|
1004
1015
|
Example
|
|
@@ -58,6 +58,7 @@ exports[`CalendarRowItem renders correctly 1`] = `
|
|
|
58
58
|
themeFontSize="medium"
|
|
59
59
|
themeFontWeight="regular"
|
|
60
60
|
themeIntent="body"
|
|
61
|
+
themeTypeface="neutral"
|
|
61
62
|
>
|
|
62
63
|
10
|
|
63
64
|
</Text>
|
|
@@ -140,6 +141,7 @@ exports[`CalendarRowItem renders correctly 2`] = `
|
|
|
140
141
|
themeFontSize="medium"
|
|
141
142
|
themeFontWeight="regular"
|
|
142
143
|
themeIntent="subdued"
|
|
144
|
+
themeTypeface="neutral"
|
|
143
145
|
>
|
|
144
146
|
10
|
|
145
147
|
</Text>
|
|
@@ -222,6 +224,7 @@ exports[`CalendarRowItem renders correctly when is current date 1`] = `
|
|
|
222
224
|
themeFontSize="medium"
|
|
223
225
|
themeFontWeight="regular"
|
|
224
226
|
themeIntent="inverted"
|
|
227
|
+
themeTypeface="neutral"
|
|
225
228
|
>
|
|
226
229
|
10
|
|
227
230
|
</Text>
|
|
@@ -304,6 +307,7 @@ exports[`CalendarRowItem renders correctly when selected, and is current date eq
|
|
|
304
307
|
themeFontSize="medium"
|
|
305
308
|
themeFontWeight="regular"
|
|
306
309
|
themeIntent="inverted"
|
|
310
|
+
themeTypeface="neutral"
|
|
307
311
|
>
|
|
308
312
|
10
|
|
309
313
|
</Text>
|
|
@@ -386,6 +390,7 @@ exports[`CalendarRowItem renders correctly when selected, and is current date eq
|
|
|
386
390
|
themeFontSize="medium"
|
|
387
391
|
themeFontWeight="regular"
|
|
388
392
|
themeIntent="inverted"
|
|
393
|
+
themeTypeface="neutral"
|
|
389
394
|
>
|
|
390
395
|
10
|
|
391
396
|
</Text>
|
|
@@ -31,6 +31,7 @@ exports[`Card renders correctly when intent is info 1`] = `
|
|
|
31
31
|
themeFontSize="medium"
|
|
32
32
|
themeFontWeight="regular"
|
|
33
33
|
themeIntent="body"
|
|
34
|
+
themeTypeface="neutral"
|
|
34
35
|
>
|
|
35
36
|
Card Content
|
|
36
37
|
</Text>
|
|
@@ -68,6 +69,7 @@ exports[`Card renders correctly when intent is primary 1`] = `
|
|
|
68
69
|
themeFontSize="medium"
|
|
69
70
|
themeFontWeight="regular"
|
|
70
71
|
themeIntent="body"
|
|
72
|
+
themeTypeface="neutral"
|
|
71
73
|
>
|
|
72
74
|
Card Content
|
|
73
75
|
</Text>
|
|
@@ -105,6 +107,7 @@ exports[`Card renders correctly when intent is success 1`] = `
|
|
|
105
107
|
themeFontSize="medium"
|
|
106
108
|
themeFontWeight="regular"
|
|
107
109
|
themeIntent="body"
|
|
110
|
+
themeTypeface="neutral"
|
|
108
111
|
>
|
|
109
112
|
Card Content
|
|
110
113
|
</Text>
|
|
@@ -140,6 +143,7 @@ exports[`Card renders correctly when intent is undefined 1`] = `
|
|
|
140
143
|
themeFontSize="medium"
|
|
141
144
|
themeFontWeight="regular"
|
|
142
145
|
themeIntent="body"
|
|
146
|
+
themeTypeface="neutral"
|
|
143
147
|
>
|
|
144
148
|
Card Content
|
|
145
149
|
</Text>
|
|
@@ -3,6 +3,7 @@ import type { ReactNode } from 'react';
|
|
|
3
3
|
import type { StyleProp, ViewStyle, ViewProps } from 'react-native';
|
|
4
4
|
import DataCard from './DataCard';
|
|
5
5
|
import { StyledCard, LeftDataCard } from './StyledCard';
|
|
6
|
+
import { useDeprecation } from '../../utils/hooks';
|
|
6
7
|
|
|
7
8
|
interface CardProps extends ViewProps {
|
|
8
9
|
/**
|
|
@@ -30,16 +31,26 @@ interface CardProps extends ViewProps {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
const Card = ({
|
|
33
|
-
variant
|
|
34
|
+
variant: _variant,
|
|
34
35
|
intent,
|
|
35
36
|
children,
|
|
36
37
|
...nativeProps
|
|
37
|
-
}: CardProps): JSX.Element =>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
}: CardProps): JSX.Element => {
|
|
39
|
+
const variant: CardProps['variant'] =
|
|
40
|
+
_variant === undefined ? 'basic' : _variant;
|
|
41
|
+
|
|
42
|
+
useDeprecation(
|
|
43
|
+
"Card's variant prop is deprecated and will be removed in the next major release.\nPlease remove it or use Card.Data instead.",
|
|
44
|
+
_variant !== undefined
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<StyledCard {...nativeProps} themeVariant={variant} themeIntent={intent}>
|
|
49
|
+
{variant === 'data' && <LeftDataCard testID="data-card-indicator" />}
|
|
50
|
+
{children}
|
|
51
|
+
</StyledCard>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
43
54
|
|
|
44
55
|
export default Object.assign(Card, {
|
|
45
56
|
Data: DataCard,
|