@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "7.25.0",
3
+ "version": "7.26.0",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -20,7 +20,7 @@
20
20
  "dependencies": {
21
21
  "@emotion/native": "^11.9.3",
22
22
  "@emotion/react": "^11.9.3",
23
- "@hero-design/colors": "7.25.0",
23
+ "@hero-design/colors": "7.26.0",
24
24
  "date-fns": "^2.16.1",
25
25
  "events": "^3.2.0",
26
26
  "hero-editor": "^1.9.12"
@@ -58,7 +58,7 @@
58
58
  "@types/react-native": "^0.67.7",
59
59
  "@types/react-native-vector-icons": "^6.4.10",
60
60
  "babel-plugin-inline-import": "^3.0.0",
61
- "eslint-config-hd": "7.25.0",
61
+ "eslint-config-hd": "7.26.0",
62
62
  "jest": "^27.3.1",
63
63
  "react": "17.0.2",
64
64
  "react-native": "0.65.1",
@@ -72,7 +72,7 @@
72
72
  "rollup-plugin-copy": "^3.4.0",
73
73
  "rollup-plugin-flow": "^1.1.1",
74
74
  "ts-jest": "^27.0.7",
75
- "prettier-config-hd": "7.25.0",
75
+ "prettier-config-hd": "7.26.0",
76
76
  "rn-7-23-0": "npm:@hero-design/rn@7.23.0"
77
77
  },
78
78
  "prettier": "prettier-config-hd"
package/rollup.config.js CHANGED
@@ -47,7 +47,7 @@ export default {
47
47
  copy({
48
48
  targets: [
49
49
  {
50
- src: 'assets/fonts/hero-icons.ttf',
50
+ src: 'assets/fonts/hero-icons-mobile.ttf',
51
51
  dest: 'lib/assets/fonts',
52
52
  },
53
53
  ],
@@ -50,6 +50,7 @@ exports[`AccordionItem renders correctly when header is an element 1`] = `
50
50
  themeFontSize="medium"
51
51
  themeFontWeight="regular"
52
52
  themeIntent="body"
53
+ themeTypeface="neutral"
53
54
  >
54
55
  Accordion header
55
56
  </Text>
@@ -123,6 +124,7 @@ exports[`AccordionItem renders correctly when header is an element 1`] = `
123
124
  themeFontSize="medium"
124
125
  themeFontWeight="regular"
125
126
  themeIntent="body"
127
+ themeTypeface="neutral"
126
128
  >
127
129
  Accordion content
128
130
  </Text>
@@ -182,6 +184,7 @@ exports[`AccordionItem renders correctly when header is string 1`] = `
182
184
  themeFontSize="large"
183
185
  themeFontWeight="semi-bold"
184
186
  themeIntent="body"
187
+ themeTypeface="neutral"
185
188
  >
186
189
  Accordion header
187
190
  </Text>
@@ -255,6 +258,7 @@ exports[`AccordionItem renders correctly when header is string 1`] = `
255
258
  themeFontSize="medium"
256
259
  themeFontWeight="regular"
257
260
  themeIntent="body"
261
+ themeTypeface="neutral"
258
262
  >
259
263
  Accordion content
260
264
  </Text>
@@ -314,6 +318,7 @@ exports[`AccordionItem renders correctly when open 1`] = `
314
318
  themeFontSize="large"
315
319
  themeFontWeight="semi-bold"
316
320
  themeIntent="body"
321
+ themeTypeface="neutral"
317
322
  >
318
323
  Accordion header
319
324
  </Text>
@@ -387,6 +392,7 @@ exports[`AccordionItem renders correctly when open 1`] = `
387
392
  themeFontSize="medium"
388
393
  themeFontWeight="regular"
389
394
  themeIntent="body"
395
+ themeTypeface="neutral"
390
396
  >
391
397
  Accordion content
392
398
  </Text>
@@ -446,6 +452,7 @@ exports[`AccordionItem renders correctly when variant is card 1`] = `
446
452
  themeFontSize="large"
447
453
  themeFontWeight="semi-bold"
448
454
  themeIntent="body"
455
+ themeTypeface="neutral"
449
456
  >
450
457
  Accordion header
451
458
  </Text>
@@ -519,6 +526,7 @@ exports[`AccordionItem renders correctly when variant is card 1`] = `
519
526
  themeFontSize="medium"
520
527
  themeFontWeight="regular"
521
528
  themeIntent="body"
529
+ themeTypeface="neutral"
522
530
  >
523
531
  Accordion content
524
532
  </Text>
@@ -58,6 +58,7 @@ exports[`Accordion allows fully controlled 1`] = `
58
58
  themeFontSize="large"
59
59
  themeFontWeight="semi-bold"
60
60
  themeIntent="body"
61
+ themeTypeface="neutral"
61
62
  >
62
63
  Accordion header 1
63
64
  </Text>
@@ -131,6 +132,7 @@ exports[`Accordion allows fully controlled 1`] = `
131
132
  themeFontSize="medium"
132
133
  themeFontWeight="regular"
133
134
  themeIntent="body"
135
+ themeTypeface="neutral"
134
136
  >
135
137
  Accordion content 1
136
138
  </Text>
@@ -187,6 +189,7 @@ exports[`Accordion allows fully controlled 1`] = `
187
189
  themeFontSize="large"
188
190
  themeFontWeight="semi-bold"
189
191
  themeIntent="body"
192
+ themeTypeface="neutral"
190
193
  >
191
194
  Accordion header 2
192
195
  </Text>
@@ -260,6 +263,7 @@ exports[`Accordion allows fully controlled 1`] = `
260
263
  themeFontSize="medium"
261
264
  themeFontWeight="regular"
262
265
  themeIntent="body"
266
+ themeTypeface="neutral"
263
267
  >
264
268
  Accordion content 2
265
269
  </Text>
@@ -328,6 +332,7 @@ exports[`Accordion renders correctly 1`] = `
328
332
  themeFontSize="large"
329
333
  themeFontWeight="semi-bold"
330
334
  themeIntent="body"
335
+ themeTypeface="neutral"
331
336
  >
332
337
  Accordion header 1
333
338
  </Text>
@@ -401,6 +406,7 @@ exports[`Accordion renders correctly 1`] = `
401
406
  themeFontSize="medium"
402
407
  themeFontWeight="regular"
403
408
  themeIntent="body"
409
+ themeTypeface="neutral"
404
410
  >
405
411
  Accordion content 1
406
412
  </Text>
@@ -457,6 +463,7 @@ exports[`Accordion renders correctly 1`] = `
457
463
  themeFontSize="large"
458
464
  themeFontWeight="semi-bold"
459
465
  themeIntent="body"
466
+ themeTypeface="neutral"
460
467
  >
461
468
  Accordion header 2
462
469
  </Text>
@@ -530,6 +537,7 @@ exports[`Accordion renders correctly 1`] = `
530
537
  themeFontSize="medium"
531
538
  themeFontWeight="regular"
532
539
  themeIntent="body"
540
+ themeTypeface="neutral"
533
541
  >
534
542
  Accordion content 2
535
543
  </Text>
@@ -598,6 +606,7 @@ exports[`Accordion renders correctly when variant is card 1`] = `
598
606
  themeFontSize="large"
599
607
  themeFontWeight="semi-bold"
600
608
  themeIntent="body"
609
+ themeTypeface="neutral"
601
610
  >
602
611
  Accordion header 1
603
612
  </Text>
@@ -671,6 +680,7 @@ exports[`Accordion renders correctly when variant is card 1`] = `
671
680
  themeFontSize="medium"
672
681
  themeFontWeight="regular"
673
682
  themeIntent="body"
683
+ themeTypeface="neutral"
674
684
  >
675
685
  Accordion content 1
676
686
  </Text>
@@ -738,6 +748,7 @@ exports[`Accordion renders correctly when variant is card 1`] = `
738
748
  themeFontSize="large"
739
749
  themeFontWeight="semi-bold"
740
750
  themeIntent="body"
751
+ themeTypeface="neutral"
741
752
  >
742
753
  Accordion header 2
743
754
  </Text>
@@ -811,6 +822,7 @@ exports[`Accordion renders correctly when variant is card 1`] = `
811
822
  themeFontSize="medium"
812
823
  themeFontWeight="regular"
813
824
  themeIntent="body"
825
+ themeTypeface="neutral"
814
826
  >
815
827
  Accordion content 2
816
828
  </Text>
@@ -85,6 +85,7 @@ exports[`Alert Icon render custom icon correctly 1`] = `
85
85
  themeFontSize="medium"
86
86
  themeFontWeight="regular"
87
87
  themeIntent="body"
88
+ themeTypeface="neutral"
88
89
  >
89
90
  Content
90
91
  </Text>
@@ -178,6 +179,7 @@ exports[`Alert renders correctly when intent is error 1`] = `
178
179
  themeFontSize="medium"
179
180
  themeFontWeight="semi-bold"
180
181
  themeIntent="body"
182
+ themeTypeface="neutral"
181
183
  >
182
184
  Title
183
185
  </Text>
@@ -197,6 +199,7 @@ exports[`Alert renders correctly when intent is error 1`] = `
197
199
  themeFontSize="medium"
198
200
  themeFontWeight="regular"
199
201
  themeIntent="body"
202
+ themeTypeface="neutral"
200
203
  >
201
204
  Content
202
205
  </Text>
@@ -326,6 +329,7 @@ exports[`Alert renders correctly when intent is info 1`] = `
326
329
  themeFontSize="medium"
327
330
  themeFontWeight="semi-bold"
328
331
  themeIntent="body"
332
+ themeTypeface="neutral"
329
333
  >
330
334
  Title
331
335
  </Text>
@@ -345,6 +349,7 @@ exports[`Alert renders correctly when intent is info 1`] = `
345
349
  themeFontSize="medium"
346
350
  themeFontWeight="regular"
347
351
  themeIntent="body"
352
+ themeTypeface="neutral"
348
353
  >
349
354
  Content
350
355
  </Text>
@@ -447,6 +452,7 @@ exports[`Alert renders correctly when intent is notification 1`] = `
447
452
  themeFontSize="medium"
448
453
  themeFontWeight="semi-bold"
449
454
  themeIntent="body"
455
+ themeTypeface="neutral"
450
456
  >
451
457
  Title
452
458
  </Text>
@@ -466,6 +472,7 @@ exports[`Alert renders correctly when intent is notification 1`] = `
466
472
  themeFontSize="medium"
467
473
  themeFontWeight="regular"
468
474
  themeIntent="body"
475
+ themeTypeface="neutral"
469
476
  >
470
477
  Content
471
478
  </Text>
@@ -595,6 +602,7 @@ exports[`Alert renders correctly when intent is success 1`] = `
595
602
  themeFontSize="medium"
596
603
  themeFontWeight="semi-bold"
597
604
  themeIntent="body"
605
+ themeTypeface="neutral"
598
606
  >
599
607
  Title
600
608
  </Text>
@@ -614,6 +622,7 @@ exports[`Alert renders correctly when intent is success 1`] = `
614
622
  themeFontSize="medium"
615
623
  themeFontWeight="regular"
616
624
  themeIntent="body"
625
+ themeTypeface="neutral"
617
626
  >
618
627
  Content
619
628
  </Text>
@@ -743,6 +752,7 @@ exports[`Alert renders correctly when intent is warning 1`] = `
743
752
  themeFontSize="medium"
744
753
  themeFontWeight="semi-bold"
745
754
  themeIntent="body"
755
+ themeTypeface="neutral"
746
756
  >
747
757
  Title
748
758
  </Text>
@@ -762,6 +772,7 @@ exports[`Alert renders correctly when intent is warning 1`] = `
762
772
  themeFontSize="medium"
763
773
  themeFontWeight="regular"
764
774
  themeIntent="body"
775
+ themeTypeface="neutral"
765
776
  >
766
777
  Content
767
778
  </Text>
@@ -77,6 +77,7 @@ exports[`Attachment renders correctly 1`] = `
77
77
  themeFontSize="medium"
78
78
  themeFontWeight="regular"
79
79
  themeIntent="body"
80
+ themeTypeface="neutral"
80
81
  >
81
82
  Screenshot.png
82
83
  </Text>
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import type {
3
3
  ImageSourcePropType,
4
4
  StyleProp,
@@ -7,24 +7,31 @@ import type {
7
7
  } from 'react-native';
8
8
  import {
9
9
  StyledImage,
10
- StyledPressable,
10
+ StyledWrapper,
11
11
  StyledText,
12
12
  StyledTextWrapper,
13
- StyledView,
14
13
  } from './StyledAvatar';
15
14
 
16
- interface AvatarProps extends ViewProps {
17
- /** Callback function when pressing component. */
15
+ export interface AvatarProps extends ViewProps {
16
+ /**
17
+ * Callback function when pressing component.
18
+ */
18
19
  onPress?: () => void;
19
- /** Image source to be displayed on avatar. */
20
+ /**
21
+ * Image source to be displayed on avatar.
22
+ */
20
23
  source?: ImageSourcePropType;
21
- /** Renders title in the placeholder. */
24
+ /**
25
+ * Renders title in the placeholder.
26
+ */
22
27
  title?: string;
23
28
  /**
24
29
  * Intent of the Icon.
25
30
  */
26
31
  intent?: 'primary' | 'info' | 'danger' | 'success' | 'warning';
27
- /** Size of the avatar. */
32
+ /**
33
+ * Size of the avatar.
34
+ */
28
35
  size?:
29
36
  | 'small'
30
37
  | 'medium'
@@ -53,27 +60,35 @@ const Avatar = ({
53
60
  size = 'small',
54
61
  intent = 'primary',
55
62
  }: AvatarProps) => {
56
- const Wrapper = onPress ? StyledPressable : StyledView;
57
- return title !== undefined || source !== undefined ? (
58
- <Wrapper
63
+ const [hasImageError, setHasImageError] = useState(false);
64
+
65
+ if (title === undefined && source === undefined) return null;
66
+ return (
67
+ <StyledWrapper
59
68
  testID={testID}
60
69
  onPress={onPress}
70
+ disabled={onPress === undefined}
61
71
  themeIntent={intent}
62
72
  themeSize={size}
63
73
  style={style}
64
74
  >
65
- {title !== undefined && source === undefined && (
75
+ {(source === undefined || hasImageError) && (
66
76
  <StyledTextWrapper>
67
- <StyledText themeIntent={intent} themeSize={size}>
68
- {title}
69
- </StyledText>
77
+ <StyledText themeSize={size}>{title}</StyledText>
70
78
  </StyledTextWrapper>
71
79
  )}
72
80
  {source !== undefined && (
73
- <StyledImage resizeMode="cover" source={source} themeSize={size} />
81
+ <StyledImage
82
+ resizeMode="cover"
83
+ source={source}
84
+ themeSize={size}
85
+ onLoad={() => setHasImageError(false)}
86
+ onError={() => setHasImageError(true)}
87
+ testID="avatar-image"
88
+ />
74
89
  )}
75
- </Wrapper>
76
- ) : null;
90
+ </StyledWrapper>
91
+ );
77
92
  };
78
93
 
79
94
  export default Avatar;
@@ -0,0 +1,29 @@
1
+ import styled from '@emotion/native';
2
+ import { View } from 'react-native';
3
+ import Avatar, { AvatarProps } from '../Avatar';
4
+
5
+ const VISIBLE_RATIO = 0.7;
6
+
7
+ export const StyledWrapper = styled(View)<{
8
+ themeSize: Required<AvatarProps>['size'];
9
+ themeAvatarCount: number;
10
+ }>(({ theme, themeSize, themeAvatarCount }) => {
11
+ const avatarSize = theme.__hd__.avatar.sizes[themeSize];
12
+
13
+ return {
14
+ flexDirection: 'row',
15
+ height: avatarSize,
16
+ width: avatarSize * (1 + VISIBLE_RATIO * (themeAvatarCount - 1)),
17
+ };
18
+ });
19
+
20
+ export const StyledAvatar = styled(Avatar)<{
21
+ themeIndex: number;
22
+ }>(({ theme, themeIndex, size = 'small' }) => {
23
+ const avatarSize = theme.__hd__.avatar.sizes[size];
24
+
25
+ return {
26
+ position: 'absolute',
27
+ left: avatarSize * VISIBLE_RATIO * themeIndex,
28
+ };
29
+ });
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import renderWithTheme from '../../../../testHelpers/renderWithTheme';
3
+ import { StyledWrapper, StyledAvatar } from '../StyledAvatarStack';
4
+ import theme from '../../../../theme';
5
+
6
+ beforeAll(() => {
7
+ theme.__hd__.avatar.colors.visualisation = [theme.colors.primary];
8
+ });
9
+
10
+ describe('StyledWrapper', () => {
11
+ it('renders correctly', () => {
12
+ const wrapper = renderWithTheme(
13
+ <StyledWrapper themeSize="large" themeAvatarCount={4} testID="wrapper" />
14
+ );
15
+
16
+ expect(wrapper.getByTestId('wrapper')).toHaveStyle({
17
+ height: 48,
18
+ width: 48 * (1 + 0.7 * 3),
19
+ });
20
+ expect(wrapper.toJSON()).toMatchSnapshot();
21
+ });
22
+ });
23
+
24
+ describe('StyledAvatar', () => {
25
+ it('renders correctly', () => {
26
+ const wrapper = renderWithTheme(
27
+ <StyledAvatar themeIndex={2} size="medium" title="AA" testID="avatar" />
28
+ );
29
+
30
+ expect(wrapper.getByTestId('avatar')).toHaveStyle({ left: 56 });
31
+ expect(wrapper.toJSON()).toMatchSnapshot();
32
+ });
33
+ });
@@ -0,0 +1,80 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`StyledAvatar renders correctly 1`] = `
4
+ <View
5
+ accessible={true}
6
+ collapsable={false}
7
+ focusable={false}
8
+ nativeID="animatedComponent"
9
+ onClick={[Function]}
10
+ onResponderGrant={[Function]}
11
+ onResponderMove={[Function]}
12
+ onResponderRelease={[Function]}
13
+ onResponderTerminate={[Function]}
14
+ onResponderTerminationRequest={[Function]}
15
+ onStartShouldSetResponder={[Function]}
16
+ style={
17
+ Object {
18
+ "backgroundColor": "#401960",
19
+ "borderRadius": 999,
20
+ "height": 40,
21
+ "left": 56,
22
+ "opacity": 1,
23
+ "overflow": "hidden",
24
+ "position": "absolute",
25
+ "width": 40,
26
+ }
27
+ }
28
+ testID="avatar"
29
+ >
30
+ <View
31
+ style={
32
+ Array [
33
+ Object {
34
+ "alignItems": "center",
35
+ "display": "flex",
36
+ "height": "100%",
37
+ "justifyContent": "center",
38
+ "width": "100%",
39
+ },
40
+ undefined,
41
+ ]
42
+ }
43
+ >
44
+ <Text
45
+ style={
46
+ Array [
47
+ Object {
48
+ "color": "#ffffff",
49
+ "fontFamily": "BeVietnamPro-Regular",
50
+ "fontSize": 18,
51
+ "overflow": "hidden",
52
+ },
53
+ undefined,
54
+ ]
55
+ }
56
+ themeSize="medium"
57
+ >
58
+ AA
59
+ </Text>
60
+ </View>
61
+ </View>
62
+ `;
63
+
64
+ exports[`StyledWrapper renders correctly 1`] = `
65
+ <View
66
+ style={
67
+ Array [
68
+ Object {
69
+ "flexDirection": "row",
70
+ "height": 48,
71
+ "width": 148.79999999999998,
72
+ },
73
+ undefined,
74
+ ]
75
+ }
76
+ testID="wrapper"
77
+ themeAvatarCount={4}
78
+ themeSize="large"
79
+ />
80
+ `;