@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.
Files changed (144) hide show
  1. package/.turbo/turbo-build.log +9 -9
  2. package/assets/fonts/BeVietnamPro-Bold.ttf +0 -0
  3. package/assets/fonts/{be-vietnam-pro-light.ttf → BeVietnamPro-Light.ttf} +0 -0
  4. package/assets/fonts/{be-vietnam-pro-regular.ttf → BeVietnamPro-Regular.ttf} +0 -0
  5. package/assets/fonts/{be-vietnam-pro-semibold.ttf → BeVietnamPro-SemiBold.ttf} +0 -0
  6. package/assets/fonts/RebondGrotesque-Light.otf +0 -0
  7. package/assets/fonts/RebondGrotesque-Regular.otf +0 -0
  8. package/assets/fonts/RebondGrotesque-SemiBold.otf +0 -0
  9. package/{lib/assets/fonts/hero-icons.ttf → assets/fonts/hero-icons-mobile.ttf} +0 -0
  10. package/es/index.js +9154 -12299
  11. package/jest.config.js +6 -2
  12. package/{assets/fonts/hero-icons.ttf → lib/assets/fonts/hero-icons-mobile.ttf} +0 -0
  13. package/lib/index.js +9154 -12298
  14. package/package.json +4 -4
  15. package/rollup.config.js +1 -1
  16. package/src/components/Accordion/__tests__/__snapshots__/AccordionItem.spec.tsx.snap +8 -0
  17. package/src/components/Accordion/__tests__/__snapshots__/index.spec.tsx.snap +12 -0
  18. package/src/components/Alert/__tests__/__snapshots__/index.spec.tsx.snap +11 -0
  19. package/src/components/Attachment/__tests__/__snapshots__/index.spec.tsx.snap +1 -0
  20. package/src/components/Avatar/{index.tsx → Avatar.tsx} +33 -18
  21. package/src/components/Avatar/AvatarStack/StyledAvatarStack.tsx +29 -0
  22. package/src/components/Avatar/AvatarStack/__tests__/StyledAvatarStack.spec.tsx +33 -0
  23. package/src/components/Avatar/AvatarStack/__tests__/__snapshots__/StyledAvatarStack.spec.tsx.snap +80 -0
  24. package/src/components/Avatar/AvatarStack/__tests__/__snapshots__/index.spec.tsx.snap +552 -0
  25. package/src/components/Avatar/AvatarStack/__tests__/index.spec.tsx +59 -0
  26. package/src/components/Avatar/AvatarStack/index.tsx +61 -0
  27. package/src/components/Avatar/AvatarStack/utils.ts +22 -0
  28. package/src/components/Avatar/StyledAvatar.tsx +6 -25
  29. package/src/components/Avatar/__tests__/StyledAvatar.spec.tsx +3 -19
  30. package/src/components/Avatar/__tests__/__snapshots__/StyledAvatar.spec.tsx.snap +3 -24
  31. package/src/components/Avatar/__tests__/__snapshots__/index.spec.tsx.snap +118 -20
  32. package/src/components/Avatar/__tests__/index.spec.tsx +25 -8
  33. package/src/components/Avatar/index.ts +6 -0
  34. package/src/components/Badge/__tests__/__snapshots__/Status.spec.tsx.snap +1 -0
  35. package/src/components/BottomNavigation/__tests__/__snapshots__/index.spec.tsx.snap +4 -0
  36. package/src/components/BottomSheet/__tests__/__snapshots__/index.spec.tsx.snap +2 -0
  37. package/src/components/Button/UtilityButton/__tests__/__snapshots__/index.spec.tsx.snap +2 -0
  38. package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +11 -0
  39. package/src/components/Calendar/__tests__/__snapshots__/CalendarRowItem.spec.tsx.snap +5 -0
  40. package/src/components/Card/DataCard/__tests__/__snapshots__/StyledDataCard.spec.tsx.snap +1 -1
  41. package/src/components/Card/DataCard/__tests__/__snapshots__/index.spec.tsx.snap +1 -1
  42. package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +4 -0
  43. package/src/components/Checkbox/__tests__/__snapshots__/index.spec.tsx.snap +4 -0
  44. package/src/components/ContentNavigator/__tests__/__snapshots__/StyledContentNavigator.spec.tsx.snap +1 -0
  45. package/src/components/ContentNavigator/__tests__/__snapshots__/index.spec.tsx.snap +2 -0
  46. package/src/components/ContentNavigator/index.tsx +8 -12
  47. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +1 -0
  48. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +3 -0
  49. package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +12 -0
  50. package/src/components/FAB/__tests__/__snapshots__/StyledFAB.spec.tsx.snap +1 -0
  51. package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
  52. package/src/components/Icon/HeroIcon/index.tsx +5 -1
  53. package/src/components/Icon/IconList.ts +11 -0
  54. package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +4 -0
  55. package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +54 -31
  56. package/src/components/List/__tests__/__snapshots__/StyledBasicListItem.spec.tsx.snap +4 -0
  57. package/src/components/List/__tests__/__snapshots__/StyledListItem.spec.tsx.snap +5 -1
  58. package/src/components/Progress/ProgressBar.tsx +19 -2
  59. package/src/components/Progress/ProgressCircle.tsx +30 -9
  60. package/src/components/Progress/StyledProgressBar.tsx +14 -7
  61. package/src/components/Progress/StyledProgressCircle.tsx +35 -24
  62. package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +337 -30
  63. package/src/components/Progress/__tests__/index.spec.js +15 -0
  64. package/src/components/Progress/constants.ts +16 -0
  65. package/src/components/Progress/types.ts +7 -1
  66. package/src/components/Radio/__tests__/__snapshots__/Radio.spec.tsx.snap +2 -0
  67. package/src/components/Radio/__tests__/__snapshots__/RadioGroup.spec.tsx.snap +3 -0
  68. package/src/components/RichTextEditor/RichTextEditor.tsx +1 -1
  69. package/src/components/RichTextEditor/__mocks__/heroEditorApp.ts +2 -0
  70. package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +36 -25
  71. package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +8 -4
  72. package/src/components/RichTextEditor/heroEditorApp.ts +3 -0
  73. package/src/components/SectionHeading/__tests__/__snapshots__/index.spec.tsx.snap +4 -0
  74. package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +1 -0
  75. package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +20 -0
  76. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +51 -0
  77. package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +22 -0
  78. package/src/components/Select/MultiSelect/index.tsx +35 -13
  79. package/src/components/Select/SingleSelect/__tests__/__snapshots__/Option.spec.tsx.snap +1 -0
  80. package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +20 -0
  81. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +46 -0
  82. package/src/components/Select/__tests__/__snapshots__/StyledSelect.spec.tsx.snap +1 -0
  83. package/src/components/Swipeable/__tests__/__snapshots__/SwipeableAction.spec.tsx.snap +3 -0
  84. package/src/components/Swipeable/__tests__/__snapshots__/index.spec.tsx.snap +1 -0
  85. package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/Option.spec.tsx.snap +1 -0
  86. package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/index.spec.tsx.snap +1 -0
  87. package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +2 -0
  88. package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +5 -0
  89. package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +22 -0
  90. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +31 -0
  91. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +1 -0
  92. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +3 -0
  93. package/src/components/Toast/__tests__/__snapshots__/Toast.spec.tsx.snap +13 -0
  94. package/src/components/Toolbar/__tests__/__snapshots__/ToolbarGroup.spec.tsx.snap +6 -0
  95. package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.spec.tsx.snap +6 -0
  96. package/src/components/Typography/Text/StyledText.tsx +6 -2
  97. package/src/components/Typography/Text/__tests__/StyledText.spec.tsx +22 -0
  98. package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +63 -0
  99. package/src/components/Typography/Text/index.tsx +8 -0
  100. package/src/index.ts +2 -1
  101. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +84 -21
  102. package/src/theme/components/avatar.ts +29 -5
  103. package/src/theme/components/badge.ts +1 -1
  104. package/src/theme/components/button.ts +2 -2
  105. package/src/theme/components/empty.ts +2 -2
  106. package/src/theme/components/fab.ts +3 -3
  107. package/src/theme/components/pinInput.ts +2 -2
  108. package/src/theme/components/progress.ts +37 -9
  109. package/src/theme/components/tag.ts +1 -1
  110. package/src/theme/components/typography.ts +1 -7
  111. package/src/theme/global/colors/global.ts +12 -3
  112. package/src/theme/global/colors/types.ts +5 -0
  113. package/src/theme/global/scale.ts +6 -2
  114. package/src/theme/global/typography.ts +23 -5
  115. package/types/components/Avatar/Avatar.d.ts +33 -0
  116. package/types/components/Avatar/AvatarStack/StyledAvatarStack.d.ts +17 -0
  117. package/types/components/Avatar/AvatarStack/index.d.ts +23 -0
  118. package/types/components/Avatar/AvatarStack/utils.d.ts +4 -0
  119. package/types/components/Avatar/StyledAvatar.d.ts +2 -12
  120. package/types/components/Avatar/index.d.ts +6 -25
  121. package/types/components/Icon/IconList.d.ts +1 -1
  122. package/types/components/Icon/index.d.ts +1 -1
  123. package/types/components/Icon/utils.d.ts +1 -1
  124. package/types/components/Progress/ProgressBar.d.ts +1 -1
  125. package/types/components/Progress/ProgressCircle.d.ts +4 -2
  126. package/types/components/Progress/StyledProgressBar.d.ts +2 -0
  127. package/types/components/Progress/StyledProgressCircle.d.ts +2 -0
  128. package/types/components/Progress/constants.d.ts +15 -0
  129. package/types/components/Progress/index.d.ts +1 -1
  130. package/types/components/Progress/types.d.ts +1 -1
  131. package/types/components/RichTextEditor/__mocks__/heroEditorApp.d.ts +2 -0
  132. package/types/components/RichTextEditor/heroEditorApp.d.ts +2 -0
  133. package/types/components/Select/MultiSelect/index.d.ts +4 -1
  134. package/types/components/Typography/Text/StyledText.d.ts +1 -0
  135. package/types/components/Typography/Text/index.d.ts +7 -1
  136. package/types/index.d.ts +2 -2
  137. package/types/theme/components/avatar.d.ts +4 -2
  138. package/types/theme/components/progress.d.ts +30 -9
  139. package/types/theme/components/typography.d.ts +1 -5
  140. package/types/theme/global/colors/types.d.ts +5 -0
  141. package/types/theme/global/index.d.ts +5 -0
  142. package/types/theme/global/scale.d.ts +4 -1
  143. package/types/theme/global/typography.d.ts +9 -2
  144. package/src/components/Icon/HeroIcon/fonts/hero-icons.ttf +0 -0
@@ -12,25 +12,12 @@ type ThemeSize =
12
12
  | 'xxxxxlarge';
13
13
  type ThemeIntent = 'primary' | 'info' | 'danger' | 'success' | 'warning';
14
14
 
15
- const StyledPressable = styled(TouchableOpacity)<{
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
- borderColor: theme.__hd__.avatar.colors[themeIntent],
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
- themeIntent: ThemeIntent;
50
- }>(({ themeSize, themeIntent, theme }) => ({
36
+ }>(({ themeSize, theme }) => ({
37
+ fontFamily: theme.__hd__.avatar.fonts.default,
51
38
  fontSize: theme.__hd__.avatar.fontSizes[themeSize],
52
- color: theme.__hd__.avatar.colors[themeIntent],
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
- <StyledPressable themeIntent="primary" themeSize="small" />
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" themeIntent="primary">
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
- "borderColor": "#401960",
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": "#401960",
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 renders correctly 1`] = `
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
- Array [
7
- Object {
8
- "borderColor": "#401960",
9
- "borderRadius": 999,
10
- "borderWidth": 1,
11
- "height": 32,
12
- "overflow": "hidden",
13
- "width": 32,
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": "https://i.pravatar.cc/300",
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 trigger press function correctly 1`] = `
80
+ exports[`Avatar prioritizes source over title 1`] = `
44
81
  <View
45
82
  accessible={true}
46
83
  collapsable={false}
47
- focusable={true}
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
- "borderColor": "#401960",
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
- const source = { uri: 'https://i.pravatar.cc/300' };
8
- const pressFn = jest.fn();
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('renders correctly', () => {
11
- const wrapper = renderWithTheme(<Avatar testID="avatar" source={source} />);
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('trigger press function correctly', () => {
26
+ it('fallbacks to title when there image failed to load', () => {
18
27
  const wrapper = renderWithTheme(
19
- <Avatar testID="avatar" source={source} onPress={pressFn} />
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
  });
@@ -0,0 +1,6 @@
1
+ import Avatar from './Avatar';
2
+ import AvatarStack from './AvatarStack';
3
+ import { useAvatarColors } from './AvatarStack/utils';
4
+
5
+ export default Object.assign(Avatar, { Stack: AvatarStack });
6
+ export { useAvatarColors };
@@ -60,6 +60,7 @@ exports[`Status Badge renders correctly with intent 1`] = `
60
60
  themeFontSize="medium"
61
61
  themeFontWeight="regular"
62
62
  themeIntent="body"
63
+ themeTypeface="neutral"
63
64
  >
64
65
  Activity
65
66
  </Text>
@@ -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>
@@ -5,7 +5,7 @@ exports[`Indicator renders correctly when intent is archived 1`] = `
5
5
  style={
6
6
  Array [
7
7
  Object {
8
- "backgroundColor": "#ccced1",
8
+ "backgroundColor": "#abacaf",
9
9
  "height": "100%",
10
10
  "width": 16,
11
11
  },
@@ -17,7 +17,7 @@ exports[`DataCard renders correctly when intent is archived 1`] = `
17
17
  style={
18
18
  Array [
19
19
  Object {
20
- "backgroundColor": "#ccced1",
20
+ "backgroundColor": "#abacaf",
21
21
  "height": "100%",
22
22
  "width": 16,
23
23
  },
@@ -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>
@@ -163,6 +163,7 @@ exports[`Checkbox renders correctly when disabled is false, withBorder is false
163
163
  themeFontSize="medium"
164
164
  themeFontWeight="regular"
165
165
  themeIntent="body"
166
+ themeTypeface="neutral"
166
167
  >
167
168
  Please agree to our privacy policy
168
169
  </Text>
@@ -242,6 +243,7 @@ exports[`Checkbox renders correctly when disabled is false, withBorder is true 1
242
243
  themeFontSize="medium"
243
244
  themeFontWeight="regular"
244
245
  themeIntent="body"
246
+ themeTypeface="neutral"
245
247
  >
246
248
  Please agree to our privacy policy
247
249
  </Text>
@@ -317,6 +319,7 @@ exports[`Checkbox renders correctly when disabled is true, withBorder is false 1
317
319
  themeFontSize="medium"
318
320
  themeFontWeight="regular"
319
321
  themeIntent="subdued"
322
+ themeTypeface="neutral"
320
323
  >
321
324
  Please agree to our privacy policy
322
325
  </Text>
@@ -396,6 +399,7 @@ exports[`Checkbox renders correctly when disabled is true, withBorder is true 1`
396
399
  themeFontSize="medium"
397
400
  themeFontWeight="regular"
398
401
  themeIntent="subdued"
402
+ themeTypeface="neutral"
399
403
  >
400
404
  Please agree to our privacy policy
401
405
  </Text>
@@ -22,6 +22,7 @@ exports[`Value has correct style 1`] = `
22
22
  themeFontSize="medium"
23
23
  themeFontWeight="regular"
24
24
  themeIntent="body"
25
+ themeTypeface="neutral"
25
26
  >
26
27
  Text
27
28
  </Text>