@hero-design/rn 7.19.0 → 7.20.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 (171) hide show
  1. package/.eslintrc.json +6 -1
  2. package/.turbo/turbo-build.log +2 -2
  3. package/es/index.js +572 -194
  4. package/lib/index.js +572 -193
  5. package/package.json +4 -4
  6. package/src/components/Alert/StyledAlert.tsx +5 -5
  7. package/src/components/Alert/__tests__/__snapshots__/index.spec.tsx.snap +140 -19
  8. package/src/components/Alert/__tests__/index.spec.tsx +21 -0
  9. package/src/components/Alert/index.tsx +13 -6
  10. package/src/components/Avatar/StyledAvatar.tsx +2 -1
  11. package/src/components/Avatar/index.tsx +2 -1
  12. package/src/components/Box/StyledBox.tsx +54 -0
  13. package/src/components/Box/__tests__/__snapshots__/index.spec.tsx.snap +605 -0
  14. package/src/components/Box/__tests__/helpers.spec.ts +14 -0
  15. package/src/components/Box/__tests__/index.spec.tsx +155 -0
  16. package/src/components/Box/config.ts +201 -0
  17. package/src/components/Box/helpers.ts +10 -0
  18. package/src/components/Box/index.tsx +13 -0
  19. package/src/components/Box/types.ts +38 -0
  20. package/src/components/Calendar/__tests__/index.spec.tsx +13 -17
  21. package/src/components/Card/DataCard/StyledDataCard.tsx +8 -2
  22. package/src/components/Card/DataCard/__tests__/StyledDataCard.spec.tsx +1 -0
  23. package/src/components/Card/DataCard/__tests__/__snapshots__/StyledDataCard.spec.tsx.snap +16 -0
  24. package/src/components/Card/DataCard/index.tsx +1 -1
  25. package/src/components/Card/StyledCard.tsx +12 -19
  26. package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +147 -0
  27. package/src/components/Card/__tests__/index.spec.tsx +18 -0
  28. package/src/components/Card/index.tsx +6 -1
  29. package/src/components/Drawer/DragableDrawer/helpers.ts +3 -4
  30. package/src/components/FAB/ActionGroup/index.tsx +6 -8
  31. package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +4 -8
  32. package/src/components/SectionHeading/__tests__/__snapshots__/StyledHeading.spec.tsx.snap +1 -1
  33. package/src/components/SectionHeading/__tests__/__snapshots__/index.spec.tsx.snap +4 -4
  34. package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +22 -20
  35. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +4 -4
  36. package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +22 -20
  37. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +4 -4
  38. package/src/components/Spinner/AnimatedSpinner.tsx +7 -7
  39. package/src/components/Spinner/StyledSpinner.tsx +24 -19
  40. package/src/components/Spinner/__tests__/AnimatedSpinner.spec.tsx +1 -1
  41. package/src/components/Spinner/__tests__/StyledSpinner.spec.tsx +32 -16
  42. package/src/components/Spinner/__tests__/__snapshots__/AnimatedSpinner.spec.tsx.snap +14 -12
  43. package/src/components/Spinner/__tests__/__snapshots__/StyledSpinner.spec.tsx.snap +273 -31
  44. package/src/components/Spinner/__tests__/__snapshots__/index.spec.tsx.snap +14 -12
  45. package/src/components/Spinner/index.tsx +10 -2
  46. package/src/components/Tabs/ScrollableTabs.tsx +9 -4
  47. package/src/components/Tabs/StyledScrollableTabs.tsx +6 -5
  48. package/src/components/Tabs/StyledTabs.tsx +6 -0
  49. package/src/components/Tabs/TabWithBadge.tsx +68 -0
  50. package/src/components/Tabs/__tests__/ScrollableTabs.spec.tsx +13 -0
  51. package/src/components/Tabs/__tests__/TabWithBadge.spec.tsx +48 -0
  52. package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +205 -43
  53. package/src/components/Tabs/__tests__/__snapshots__/TabWithBadge.spec.tsx.snap +165 -0
  54. package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +135 -34
  55. package/src/components/Tabs/__tests__/index.spec.tsx +12 -0
  56. package/src/components/Tabs/index.tsx +11 -4
  57. package/src/components/Tag/StyledTag.tsx +1 -11
  58. package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +4 -4
  59. package/src/components/Tag/index.tsx +2 -2
  60. package/src/components/TextInput/__tests__/index.spec.tsx +10 -14
  61. package/src/components/Toast/StyledToast.tsx +13 -7
  62. package/src/components/Toast/Toast.tsx +34 -9
  63. package/src/components/Toast/ToastProvider.tsx +15 -12
  64. package/src/components/Toast/__tests__/Toast.spec.tsx +17 -0
  65. package/src/components/Toast/__tests__/__snapshots__/Toast.spec.tsx.snap +299 -19
  66. package/src/components/Toast/types.ts +15 -1
  67. package/src/components/Typography/Text/StyledText.tsx +7 -1
  68. package/src/components/Typography/Text/__tests__/StyledText.spec.tsx +1 -0
  69. package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +22 -0
  70. package/src/components/Typography/Text/index.tsx +7 -1
  71. package/src/index.ts +2 -0
  72. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +76 -23
  73. package/src/theme/components/.eslintrc.json +10 -0
  74. package/src/theme/components/alert.ts +5 -1
  75. package/src/theme/components/avatar.ts +2 -0
  76. package/src/theme/components/card.ts +6 -7
  77. package/src/theme/components/sectionHeading.ts +1 -1
  78. package/src/theme/components/spinner.ts +19 -7
  79. package/src/theme/components/tabs.ts +3 -2
  80. package/src/theme/components/tag.ts +13 -13
  81. package/src/theme/components/toast.ts +17 -3
  82. package/src/theme/components/typography.ts +2 -0
  83. package/src/theme/global/colors/swag.ts +23 -0
  84. package/src/theme/global/colors/types.ts +23 -0
  85. package/src/theme/global/colors/work.ts +5 -0
  86. package/tsconfig.json +4 -15
  87. package/types/components/Accordion/StyledAccordion.d.ts +14 -14
  88. package/types/components/Alert/StyledAlert.d.ts +16 -16
  89. package/types/components/Alert/index.d.ts +1 -1
  90. package/types/components/Avatar/StyledAvatar.d.ts +16 -16
  91. package/types/components/Avatar/index.d.ts +2 -2
  92. package/types/components/Badge/StyledBadge.d.ts +7 -7
  93. package/types/components/BottomNavigation/StyledBottomNavigation.d.ts +21 -21
  94. package/types/components/BottomSheet/Header.d.ts +1 -1
  95. package/types/components/BottomSheet/StyledBottomSheet.d.ts +19 -19
  96. package/types/components/Box/StyledBox.d.ts +15 -0
  97. package/types/components/Box/__tests__/helpers.spec.d.ts +1 -0
  98. package/types/components/Box/__tests__/index.spec.d.ts +1 -0
  99. package/types/components/Box/config.d.ts +170 -0
  100. package/types/components/Box/helpers.d.ts +1 -0
  101. package/types/components/Box/index.d.ts +5 -0
  102. package/types/components/Box/types.d.ts +31 -0
  103. package/types/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +7 -7
  104. package/types/components/Button/StyledButton.d.ts +16 -16
  105. package/types/components/Button/UtilityButton/StyledUtilityButton.d.ts +8 -8
  106. package/types/components/Calendar/StyledCalendar.d.ts +25 -25
  107. package/types/components/Calendar/helpers.d.ts +2 -2
  108. package/types/components/Card/DataCard/StyledDataCard.d.ts +7 -7
  109. package/types/components/Card/DataCard/index.d.ts +1 -1
  110. package/types/components/Card/StyledCard.d.ts +7 -6
  111. package/types/components/Card/index.d.ts +5 -1
  112. package/types/components/Checkbox/StyledCheckbox.d.ts +10 -10
  113. package/types/components/Collapse/StyledCollapse.d.ts +8 -8
  114. package/types/components/ContentNavigator/StyledContentNavigator.d.ts +5 -5
  115. package/types/components/DatePicker/StyledDatePicker.d.ts +3 -3
  116. package/types/components/Divider/StyledDivider.d.ts +5 -5
  117. package/types/components/Drawer/StyledDrawer.d.ts +19 -19
  118. package/types/components/Empty/StyledEmpty.d.ts +12 -12
  119. package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +11 -11
  120. package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +7 -7
  121. package/types/components/FAB/StyledFAB.d.ts +8 -8
  122. package/types/components/Icon/HeroIcon/index.d.ts +3 -3
  123. package/types/components/List/StyledBasicListItem.d.ts +14 -14
  124. package/types/components/List/StyledListItem.d.ts +23 -23
  125. package/types/components/PinInput/StyledPinInput.d.ts +30 -30
  126. package/types/components/Progress/StyledProgressBar.d.ts +5 -5
  127. package/types/components/Progress/StyledProgressCircle.d.ts +18 -18
  128. package/types/components/Radio/StyledRadio.d.ts +9 -9
  129. package/types/components/RichTextEditor/EditorToolbar.d.ts +1 -1
  130. package/types/components/RichTextEditor/MentionList.d.ts +1 -1
  131. package/types/components/RichTextEditor/StyledRichTextEditor.d.ts +6 -6
  132. package/types/components/RichTextEditor/StyledToolbar.d.ts +9 -9
  133. package/types/components/RichTextEditor/index.d.ts +2 -2
  134. package/types/components/SectionHeading/StyledHeading.d.ts +9 -9
  135. package/types/components/Select/MultiSelect/Option.d.ts +1 -1
  136. package/types/components/Select/SingleSelect/Option.d.ts +1 -1
  137. package/types/components/Select/StyledSelect.d.ts +11 -11
  138. package/types/components/Select/helpers.d.ts +1 -1
  139. package/types/components/Spinner/AnimatedSpinner.d.ts +3 -1
  140. package/types/components/Spinner/StyledSpinner.d.ts +14 -12
  141. package/types/components/Spinner/index.d.ts +5 -1
  142. package/types/components/Switch/StyledSwitch.d.ts +5 -5
  143. package/types/components/Tabs/StyledScrollableTabs.d.ts +24 -22
  144. package/types/components/Tabs/StyledTabs.d.ts +26 -20
  145. package/types/components/Tabs/TabWithBadge.d.ts +17 -0
  146. package/types/components/Tabs/__tests__/TabWithBadge.spec.d.ts +1 -0
  147. package/types/components/Tabs/index.d.ts +3 -1
  148. package/types/components/Tag/StyledTag.d.ts +6 -6
  149. package/types/components/Tag/index.d.ts +1 -1
  150. package/types/components/TextInput/StyledTextInput.d.ts +44 -44
  151. package/types/components/TextInput/index.d.ts +5 -5
  152. package/types/components/TimePicker/StyledTimePicker.d.ts +3 -3
  153. package/types/components/Toast/StyledToast.d.ts +19 -18
  154. package/types/components/Toast/types.d.ts +2 -1
  155. package/types/components/Toolbar/StyledToolbar.d.ts +9 -9
  156. package/types/components/Typography/Text/StyledText.d.ts +4 -4
  157. package/types/components/Typography/Text/index.d.ts +1 -1
  158. package/types/index.d.ts +2 -1
  159. package/types/testHelpers/renderWithTheme.d.ts +1 -1
  160. package/types/theme/ThemeSwitcher.d.ts +1 -1
  161. package/types/theme/components/alert.d.ts +5 -1
  162. package/types/theme/components/avatar.d.ts +2 -0
  163. package/types/theme/components/card.d.ts +6 -7
  164. package/types/theme/components/spinner.d.ts +17 -5
  165. package/types/theme/components/tabs.d.ts +1 -0
  166. package/types/theme/components/tag.d.ts +2 -2
  167. package/types/theme/components/toast.d.ts +18 -2
  168. package/types/theme/components/typography.d.ts +2 -0
  169. package/types/theme/global/colors/types.d.ts +17 -0
  170. package/types/theme/global/index.d.ts +17 -0
  171. package/types/utils/hooks.d.ts +1 -1
@@ -178,28 +178,6 @@ exports[`Tabs renders correctly 1`] = `
178
178
  >
179
179
  Work
180
180
  </Text>
181
- <View
182
- collapsable={false}
183
- nativeID="animatedComponent"
184
- style={
185
- Object {
186
- "backgroundColor": "#de350b",
187
- "borderRadius": 999,
188
- "height": 8,
189
- "opacity": 0,
190
- "position": "absolute",
191
- "right": -2,
192
- "top": -2,
193
- "transform": Array [
194
- Object {
195
- "scale": 0.5,
196
- },
197
- ],
198
- "width": 8,
199
- }
200
- }
201
- themeIntent="danger"
202
- />
203
181
  </View>
204
182
  </View>
205
183
  <View
@@ -246,6 +224,59 @@ exports[`Tabs renders correctly 1`] = `
246
224
  >
247
225
  Personal
248
226
  </Text>
227
+ </View>
228
+ </View>
229
+ <View
230
+ accessible={true}
231
+ focusable={true}
232
+ onClick={[Function]}
233
+ onResponderGrant={[Function]}
234
+ onResponderMove={[Function]}
235
+ onResponderRelease={[Function]}
236
+ onResponderTerminate={[Function]}
237
+ onResponderTerminationRequest={[Function]}
238
+ onStartShouldSetResponder={[Function]}
239
+ style={
240
+ Array [
241
+ Object {
242
+ "alignItems": "center",
243
+ "flex": 1,
244
+ "paddingVertical": 8,
245
+ },
246
+ undefined,
247
+ ]
248
+ }
249
+ >
250
+ <View
251
+ style={
252
+ Object {
253
+ "paddingHorizontal": 8,
254
+ }
255
+ }
256
+ testID="deprecated-badge"
257
+ >
258
+ <Text
259
+ numberOfLines={1}
260
+ style={
261
+ Array [
262
+ Object {
263
+ "color": "#001f23",
264
+ "fontFamily": "BeVietnamPro-Regular",
265
+ "fontSize": 14,
266
+ "letterSpacing": 0.42,
267
+ "lineHeight": 22,
268
+ },
269
+ Object {
270
+ "color": "#001f23",
271
+ },
272
+ ]
273
+ }
274
+ themeFontSize="medium"
275
+ themeFontWeight="regular"
276
+ themeIntent="body"
277
+ >
278
+ Home
279
+ </Text>
249
280
  <View
250
281
  collapsable={false}
251
282
  nativeID="animatedComponent"
@@ -254,13 +285,13 @@ exports[`Tabs renders correctly 1`] = `
254
285
  "backgroundColor": "#de350b",
255
286
  "borderRadius": 999,
256
287
  "height": 8,
257
- "opacity": 0,
288
+ "opacity": 1,
258
289
  "position": "absolute",
259
290
  "right": -2,
260
291
  "top": -2,
261
292
  "transform": Array [
262
293
  Object {
263
- "scale": 0.5,
294
+ "scale": 1,
264
295
  },
265
296
  ],
266
297
  "width": 8,
@@ -291,7 +322,17 @@ exports[`Tabs renders correctly 1`] = `
291
322
  ]
292
323
  }
293
324
  >
294
- <View>
325
+ <View
326
+ style={
327
+ Array [
328
+ Object {
329
+ "alignItems": "center",
330
+ "flexDirection": "row",
331
+ },
332
+ undefined,
333
+ ]
334
+ }
335
+ >
295
336
  <Text
296
337
  numberOfLines={1}
297
338
  style={
@@ -312,30 +353,50 @@ exports[`Tabs renders correctly 1`] = `
312
353
  themeFontWeight="regular"
313
354
  themeIntent="body"
314
355
  >
315
- Home
356
+ Wallet
316
357
  </Text>
317
358
  <View
318
359
  collapsable={false}
319
360
  nativeID="animatedComponent"
320
361
  style={
321
362
  Object {
322
- "backgroundColor": "#de350b",
363
+ "alignItems": "center",
364
+ "backgroundColor": "#4568fb",
323
365
  "borderRadius": 999,
324
- "height": 8,
366
+ "height": 20,
367
+ "justifyContent": "center",
368
+ "marginLeft": 4,
369
+ "minWidth": 20,
325
370
  "opacity": 1,
326
- "position": "absolute",
327
- "right": -2,
328
- "top": -2,
371
+ "paddingHorizontal": 8,
329
372
  "transform": Array [
330
373
  Object {
331
374
  "scale": 1,
332
375
  },
333
376
  ],
334
- "width": 8,
335
377
  }
336
378
  }
337
- themeIntent="danger"
338
- />
379
+ themeIntent="info"
380
+ themePadding="wideContent"
381
+ >
382
+ <Text
383
+ style={
384
+ Array [
385
+ Object {
386
+ "color": "#ffffff",
387
+ "fontFamily": "BeVietnamPro-SemiBold",
388
+ "fontSize": 12,
389
+ "includeFontPadding": false,
390
+ "textAlign": "center",
391
+ "textAlignVertical": "center",
392
+ },
393
+ undefined,
394
+ ]
395
+ }
396
+ >
397
+ 50
398
+ </Text>
399
+ </View>
339
400
  </View>
340
401
  </View>
341
402
  </View>
@@ -487,6 +548,46 @@ exports[`Tabs renders correctly 1`] = `
487
548
  </Text>
488
549
  </View>
489
550
  </View>
551
+ <View
552
+ collapsable={false}
553
+ style={
554
+ Object {
555
+ "bottom": 0,
556
+ "left": 0,
557
+ "position": "absolute",
558
+ "right": 0,
559
+ "top": 0,
560
+ }
561
+ }
562
+ >
563
+ <View
564
+ accessibilityElementsHidden={true}
565
+ collapsable={false}
566
+ importantForAccessibility="no-hide-descendants"
567
+ pointerEvents="none"
568
+ style={
569
+ Array [
570
+ Object {
571
+ "flex": 1,
572
+ },
573
+ Array [
574
+ undefined,
575
+ Object {
576
+ "bottom": 0,
577
+ "left": 0,
578
+ "position": "absolute",
579
+ "right": 0,
580
+ "top": 0,
581
+ },
582
+ ],
583
+ ]
584
+ }
585
+ >
586
+ <Text>
587
+ Wallet Screen
588
+ </Text>
589
+ </View>
590
+ </View>
490
591
  </RNCViewPager>
491
592
  </View>
492
593
  </RNCSafeAreaProvider>
@@ -32,6 +32,15 @@ const TestTabsComponent = (
32
32
  component: <Text>Home Screen</Text>,
33
33
  showBadge: true,
34
34
  },
35
+ {
36
+ key: 'wallet',
37
+ activeItem: 'Wallet',
38
+ component: <Text>Wallet Screen</Text>,
39
+ badge: {
40
+ type: 'counter',
41
+ value: 50,
42
+ },
43
+ },
35
44
  ];
36
45
 
37
46
  return (
@@ -71,6 +80,9 @@ describe('Tabs', () => {
71
80
  expect(getByText('Home Screen')).toBeDefined();
72
81
  fireEvent.press(getByText('Move to Work'));
73
82
  expect(getByText('Work Screen')).toBeDefined();
83
+ fireEvent.press(getByText('Wallet'));
84
+ expect(getByText('Wallet Screen')).toBeDefined();
85
+ expect(getByText('50')).toBeDefined();
74
86
  });
75
87
 
76
88
  it('renders correctly with lazy preloaded', () => {
@@ -15,10 +15,11 @@ import {
15
15
  TabScreen,
16
16
  HeaderTab,
17
17
  } from './StyledTabs';
18
- import Badge from '../Badge';
19
18
  import ActiveTabIndicator from './ActiveTabIndicator';
20
19
  import ScrollableTabs from './ScrollableTabs';
21
- import type { IconName } from '../Icon';
20
+ import TabWithBadge from './TabWithBadge';
21
+ import type { BadgeConfigType } from './TabWithBadge';
22
+ import { IconName } from '../Icon';
22
23
 
23
24
  export type ItemType =
24
25
  | string
@@ -32,6 +33,7 @@ export type TabType = {
32
33
  component: ReactNode;
33
34
  testID?: string;
34
35
  showBadge?: boolean;
36
+ badge?: BadgeConfigType;
35
37
  };
36
38
 
37
39
  export interface TabsProps extends ViewProps {
@@ -136,7 +138,8 @@ const Tabs = ({
136
138
  testID,
137
139
  activeItem,
138
140
  inactiveItem: originalInactiveItem,
139
- showBadge = false,
141
+ showBadge,
142
+ badge,
140
143
  } = tab;
141
144
 
142
145
  const active = selectedTabKey === key;
@@ -156,7 +159,11 @@ const Tabs = ({
156
159
  testID={testID}
157
160
  >
158
161
  <HeaderTabItem>
159
- <Badge.Status visible={showBadge}>{tabItem}</Badge.Status>
162
+ <TabWithBadge
163
+ showBadge={showBadge}
164
+ config={badge}
165
+ tabItem={tabItem}
166
+ />
160
167
  </HeaderTabItem>
161
168
  </TouchableWithoutFeedback>
162
169
  );
@@ -1,16 +1,6 @@
1
1
  import { View, Text } from 'react-native';
2
2
  import styled from '@emotion/native';
3
3
 
4
- const BACKGROUND_INTENTS = {
5
- default: 'defaultBackground',
6
- primary: 'primaryBackground',
7
- info: 'infoBackground',
8
- success: 'successBackground',
9
- warning: 'warningBackground',
10
- danger: 'dangerBackground',
11
- archived: 'archivedBackground',
12
- } as const;
13
-
14
4
  type ThemeIntent =
15
5
  | 'default'
16
6
  | 'primary'
@@ -27,7 +17,7 @@ const StyledView = styled(View)<{ themeIntent: ThemeIntent }>(
27
17
  paddingVertical: theme.__hd__.tag.space.verticalPadding,
28
18
  paddingHorizontal: theme.__hd__.tag.space.horizontalPadding,
29
19
  borderColor: theme.__hd__.tag.colors[themeIntent],
30
- backgroundColor: theme.__hd__.tag.colors[BACKGROUND_INTENTS[themeIntent]],
20
+ backgroundColor: theme.__hd__.tag.colors[`${themeIntent}Background`],
31
21
  })
32
22
  );
33
23
 
@@ -43,8 +43,8 @@ exports[`Tag has archived style when intent is primary 1`] = `
43
43
  style={
44
44
  Array [
45
45
  Object {
46
- "backgroundColor": "#f3e6f6",
47
- "borderColor": "#8505a2",
46
+ "backgroundColor": undefined,
47
+ "borderColor": "#001f23",
48
48
  "borderRadius": 4,
49
49
  "borderWidth": 1,
50
50
  "paddingHorizontal": 8,
@@ -59,7 +59,7 @@ exports[`Tag has archived style when intent is primary 1`] = `
59
59
  style={
60
60
  Array [
61
61
  Object {
62
- "color": "#8505a2",
62
+ "color": "#001f23",
63
63
  "fontFamily": "BeVietnamPro-SemiBold",
64
64
  "fontSize": 12,
65
65
  "includeFontPadding": false,
@@ -233,7 +233,7 @@ exports[`Tag has warning style when intent is warning 1`] = `
233
233
  style={
234
234
  Array [
235
235
  Object {
236
- "backgroundColor": "#ebf4ff",
236
+ "backgroundColor": "#fff6eb",
237
237
  "borderColor": "#ffa234",
238
238
  "borderRadius": 4,
239
239
  "borderWidth": 1,
@@ -11,8 +11,8 @@ interface TagProps extends ViewProps {
11
11
  * Visual intent color to apply to Tag.
12
12
  */
13
13
  intent?:
14
- | 'default'
15
14
  | 'primary'
15
+ | 'default' // Will be deprecated in the future
16
16
  | 'info'
17
17
  | 'success'
18
18
  | 'warning'
@@ -30,7 +30,7 @@ interface TagProps extends ViewProps {
30
30
 
31
31
  const Tag = ({
32
32
  content,
33
- intent = 'default',
33
+ intent = 'primary',
34
34
  style,
35
35
  testID,
36
36
  ...nativeProps
@@ -259,20 +259,16 @@ describe('TextInput', () => {
259
259
 
260
260
  describe('disabled', () => {
261
261
  it('renders correctly', () => {
262
- const {
263
- toJSON,
264
- queryAllByTestId,
265
- queryAllByText,
266
- getByTestId,
267
- } = renderWithTheme(
268
- <TextInput
269
- label="Amount (AUD)"
270
- required
271
- disabled
272
- value="100"
273
- testID="disabled-text-input"
274
- />
275
- );
262
+ const { toJSON, queryAllByTestId, queryAllByText, getByTestId } =
263
+ renderWithTheme(
264
+ <TextInput
265
+ label="Amount (AUD)"
266
+ required
267
+ disabled
268
+ value="100"
269
+ testID="disabled-text-input"
270
+ />
271
+ );
276
272
 
277
273
  expect(toJSON()).toMatchSnapshot();
278
274
  expect(queryAllByText('Amount (AUD)')).toHaveLength(1);
@@ -2,12 +2,13 @@ import styled from '@emotion/native';
2
2
  import { Animated, StyleSheet, TouchableOpacity, View } from 'react-native';
3
3
  import type { ComponentProps } from 'react';
4
4
  import type { ViewProps } from 'react-native';
5
+ import { IntentType } from './types';
5
6
 
6
7
  const ToastContainerWrapper = styled(View)<{ position: 'top' | 'bottom' }>(
7
8
  ({ theme, position }) => ({
8
9
  ...StyleSheet.absoluteFillObject,
9
- paddingHorizontal: theme.__hd__.toast.space.largePadding,
10
- paddingVertical: theme.__hd__.toast.space.mediumPadding,
10
+ paddingHorizontal: theme.__hd__.toast.space.wrapperVerticalPadding,
11
+ paddingVertical: theme.__hd__.toast.space.wrapperHorizontalPadding,
11
12
  flexDirection: position === 'bottom' ? 'column-reverse' : 'column',
12
13
  elevation: 9999,
13
14
  })
@@ -15,27 +16,32 @@ const ToastContainerWrapper = styled(View)<{ position: 'top' | 'bottom' }>(
15
16
 
16
17
  const Container = styled(Animated.View)<{
17
18
  themeVariant: 'default' | 'round';
18
- themeIntent: 'success' | 'info' | 'warning' | 'error';
19
+ themeIntent: IntentType;
19
20
  }>(({ theme, themeVariant, themeIntent }) => ({
20
21
  borderRadius: themeVariant === 'round' ? theme.__hd__.toast.radii.default : 0,
21
22
  backgroundColor: theme.__hd__.toast.colors[themeIntent],
22
23
  minHeight: theme.__hd__.toast.sizes.height,
23
24
  flexDirection: 'row',
25
+ shadowColor: theme.__hd__.toast.colors.shadow,
26
+ shadowOffset: theme.__hd__.toast.shadows.offset,
27
+ shadowRadius: theme.__hd__.toast.shadows.radius,
28
+ shadowOpacity: theme.__hd__.toast.shadows.opacity,
29
+ elevation: theme.__hd__.toast.shadows.elevation,
24
30
  }));
25
31
 
26
32
  const IconContainer = styled(View)<ViewProps>(({ theme }) => ({
27
33
  alignItems: 'center',
28
- paddingLeft: theme.__hd__.toast.space.mediumPadding,
34
+ paddingLeft: theme.__hd__.toast.space.iconLeftPadding,
29
35
  }));
30
36
 
31
37
  const TextContainer = styled(View)<ViewProps>(({ theme }) => ({
32
- paddingHorizontal: theme.__hd__.toast.space.mediumPadding,
38
+ paddingHorizontal: theme.__hd__.toast.space.textHorizontalPadding,
33
39
  flex: 1,
34
40
  }));
35
41
 
36
42
  const ContentContainer = styled(View)<{ showDivider: boolean }>(
37
43
  ({ theme, showDivider }) => ({
38
- paddingVertical: theme.__hd__.toast.space.mediumPadding,
44
+ paddingVertical: theme.__hd__.toast.space.contentVerticalPadding,
39
45
  flex: 1,
40
46
  borderRightWidth: showDivider ? theme.__hd__.toast.borderWidths.base : 0,
41
47
  borderColor: theme.__hd__.toast.colors.divider,
@@ -46,7 +52,7 @@ const ContentContainer = styled(View)<{ showDivider: boolean }>(
46
52
  const CTAWrapper = styled(TouchableOpacity)<
47
53
  ComponentProps<typeof TouchableOpacity>
48
54
  >(({ theme }) => ({
49
- paddingHorizontal: theme.__hd__.alert.space.padding,
55
+ paddingHorizontal: theme.__hd__.toast.space.ctaPadding,
50
56
  justifyContent: 'center',
51
57
  }));
52
58
 
@@ -11,11 +11,9 @@ import {
11
11
  } from './StyledToast';
12
12
  import { useToastConfig } from './ToastContext';
13
13
  import type { IconName } from '../Icon';
14
- import type { ToastProps } from './types';
14
+ import type { IntentType, ToastProps } from './types';
15
15
 
16
- const getIntentIcon = (
17
- intent: 'success' | 'info' | 'warning' | 'error'
18
- ): IconName => {
16
+ const getIntentIcon = (intent: IntentType): IconName | undefined => {
19
17
  switch (intent) {
20
18
  case 'success':
21
19
  return 'circle-ok';
@@ -25,9 +23,28 @@ const getIntentIcon = (
25
23
  return 'circle-info';
26
24
  case 'error':
27
25
  return 'circle-warning';
26
+ default:
27
+ return undefined;
28
28
  }
29
29
  };
30
30
 
31
+ const ToastIcon = ({
32
+ themeIntent,
33
+ icon,
34
+ }: {
35
+ icon?: IconName;
36
+ themeIntent: IntentType;
37
+ }) =>
38
+ icon ? (
39
+ <IconContainer testID="toast-left-icon">
40
+ <Icon
41
+ icon={icon}
42
+ size="small"
43
+ intent={themeIntent === 'snackbar' ? 'text-inverted' : 'text'}
44
+ />
45
+ </IconContainer>
46
+ ) : null;
47
+
31
48
  const Toast = ({
32
49
  content,
33
50
  icon,
@@ -88,13 +105,18 @@ const Toast = ({
88
105
  >
89
106
  <ContentContainer showDivider={!!actionLabel}>
90
107
  {icon !== null ? (
91
- <IconContainer testID="toast-left-icon">
92
- <Icon icon={icon || getIntentIcon(intent)} size="small" />
93
- </IconContainer>
108
+ <ToastIcon
109
+ themeIntent={intent}
110
+ icon={icon || getIntentIcon(intent)}
111
+ />
94
112
  ) : null}
95
113
  <TextContainer>
96
114
  {typeof content === 'string' ? (
97
- <Typography.Text>{content}</Typography.Text>
115
+ <Typography.Text
116
+ intent={intent === 'snackbar' ? 'inverted' : 'body'}
117
+ >
118
+ {content}
119
+ </Typography.Text>
98
120
  ) : (
99
121
  content
100
122
  )}
@@ -109,7 +131,10 @@ const Toast = ({
109
131
  }}
110
132
  >
111
133
  {typeof actionLabel === 'string' ? (
112
- <Typography.Text fontWeight="semi-bold">
134
+ <Typography.Text
135
+ fontWeight="semi-bold"
136
+ intent={intent === 'snackbar' ? 'inverted' : 'body'}
137
+ >
113
138
  {actionLabel}
114
139
  </Typography.Text>
115
140
  ) : (
@@ -1,4 +1,5 @@
1
1
  import React, { useEffect, useRef, useState, useMemo } from 'react';
2
+ import { View } from 'react-native';
2
3
 
3
4
  import type { ReactNode } from 'react';
4
5
  import ToastContainer from './ToastContainer';
@@ -29,21 +30,23 @@ const ToastProvider = ({
29
30
  }
30
31
  }, []);
31
32
 
32
- const config = useMemo(() => ({ displayType, position }), [
33
- displayType,
34
- position,
35
- ]);
33
+ const config = useMemo(
34
+ () => ({ displayType, position }),
35
+ [displayType, position]
36
+ );
36
37
 
37
38
  return (
38
39
  <ToastContext.Provider value={refState}>
39
- {children}
40
- <ToastConfigContext.Provider value={config}>
41
- <ToastContainer
42
- ref={toastRef}
43
- displayType={displayType}
44
- position={position}
45
- />
46
- </ToastConfigContext.Provider>
40
+ <View style={{ flex: 1 }}>
41
+ {children}
42
+ <ToastConfigContext.Provider value={config}>
43
+ <ToastContainer
44
+ ref={toastRef}
45
+ displayType={displayType}
46
+ position={position}
47
+ />
48
+ </ToastConfigContext.Provider>
49
+ </View>
47
50
  </ToastContext.Provider>
48
51
  );
49
52
  };
@@ -23,9 +23,26 @@ describe('Toast', () => {
23
23
  expect(toJSON()).toMatchSnapshot();
24
24
  expect(getByText('Toast Content')).toBeDefined();
25
25
  expect(getByText('Action')).toBeDefined();
26
+ // Default icon
26
27
  expect(getByTestId('toast-left-icon')).toBeDefined();
27
28
  });
28
29
 
30
+ it.each`
31
+ intent
32
+ ${'notification'}
33
+ ${'snackbar'}
34
+ `('renders correctly when intent is $intent', ({ intent }) => {
35
+ const { getByText, queryByTestId, toJSON } = renderWithTheme(
36
+ <Toast content="Toast Content" actionLabel="Action" intent={intent} />
37
+ );
38
+
39
+ expect(toJSON()).toMatchSnapshot();
40
+ expect(getByText('Toast Content')).toBeDefined();
41
+ expect(getByText('Action')).toBeDefined();
42
+ // No default icon
43
+ expect(queryByTestId('toast-left-icon')).toBeNull();
44
+ });
45
+
29
46
  describe('Icon', () => {
30
47
  it('not render icon when icon prop is null', () => {
31
48
  const { queryByTestId } = renderWithTheme(