@hero-design/rn 8.92.3 → 8.94.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 (85) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/CHANGELOG.md +16 -0
  3. package/assets/fonts/hero-icons-mobile.ttf +0 -0
  4. package/es/index.js +961 -140
  5. package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
  6. package/lib/index.js +960 -139
  7. package/package.json +1 -1
  8. package/src/components/Badge/Count.tsx +60 -0
  9. package/src/components/Badge/StyledBadge.tsx +33 -2
  10. package/src/components/Badge/__tests__/Count.spec.tsx +38 -0
  11. package/src/components/Badge/__tests__/__snapshots__/Count.spec.tsx.snap +310 -0
  12. package/src/components/Badge/constants.ts +1 -0
  13. package/src/components/Badge/index.tsx +3 -2
  14. package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
  15. package/src/components/Icon/IconList.ts +1 -0
  16. package/src/components/{Empty → StatusScreens/Empty}/StyledEmpty.tsx +11 -2
  17. package/src/components/StatusScreens/Empty/__tests__/__snapshots__/index.spec.tsx.snap +468 -0
  18. package/src/components/{Empty → StatusScreens/Empty}/__tests__/index.spec.tsx +16 -2
  19. package/src/components/StatusScreens/Empty/index.tsx +97 -0
  20. package/src/components/{Error → StatusScreens/Error}/StyledError.tsx +4 -4
  21. package/src/components/{Error → StatusScreens/Error}/__tests__/__snapshots__/index.spec.tsx.snap +300 -0
  22. package/src/components/{Error → StatusScreens/Error}/__tests__/index.spec.tsx +13 -3
  23. package/src/components/{Error → StatusScreens/Error}/index.tsx +39 -7
  24. package/src/components/StatusScreens/StatusIcon/__tests__/index.spec.tsx +31 -0
  25. package/src/components/StatusScreens/StatusIcon/assets/Add.tsx +49 -0
  26. package/src/components/StatusScreens/StatusIcon/assets/Boom.tsx +61 -0
  27. package/src/components/StatusScreens/StatusIcon/assets/Build.tsx +45 -0
  28. package/src/components/StatusScreens/StatusIcon/assets/Clock.tsx +38 -0
  29. package/src/components/StatusScreens/StatusIcon/assets/Confetti.tsx +78 -0
  30. package/src/components/StatusScreens/StatusIcon/assets/Connections.tsx +57 -0
  31. package/src/components/StatusScreens/StatusIcon/assets/Error.tsx +55 -0
  32. package/src/components/StatusScreens/StatusIcon/assets/Info.tsx +35 -0
  33. package/src/components/StatusScreens/StatusIcon/assets/List.tsx +37 -0
  34. package/src/components/StatusScreens/StatusIcon/assets/Location.tsx +37 -0
  35. package/src/components/StatusScreens/StatusIcon/assets/Merge.tsx +59 -0
  36. package/src/components/StatusScreens/StatusIcon/assets/Notifications.tsx +26 -0
  37. package/src/components/StatusScreens/StatusIcon/assets/Search.tsx +36 -0
  38. package/src/components/StatusScreens/StatusIcon/assets/Star.tsx +37 -0
  39. package/src/components/StatusScreens/StatusIcon/assets/Success.tsx +41 -0
  40. package/src/components/StatusScreens/StatusIcon/assets/User.tsx +43 -0
  41. package/src/components/StatusScreens/StatusIcon/index.tsx +63 -0
  42. package/src/components/StatusScreens/StatusIcon/types.ts +5 -0
  43. package/src/components/{Success → StatusScreens/Success}/StyledSuccess.tsx +4 -4
  44. package/src/components/{Success → StatusScreens/Success}/__tests__/__snapshots__/index.spec.tsx.snap +263 -0
  45. package/src/components/{Success → StatusScreens/Success}/__tests__/index.spec.tsx +13 -4
  46. package/src/components/{Success → StatusScreens/Success}/index.tsx +38 -7
  47. package/src/index.ts +3 -3
  48. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +11 -0
  49. package/src/theme/components/badge.ts +26 -1
  50. package/stats/8.94.0/rn-stats.html +4842 -0
  51. package/types/components/Badge/Count.d.ts +27 -0
  52. package/types/components/Badge/StyledBadge.d.ts +14 -4
  53. package/types/components/Badge/constants.d.ts +1 -0
  54. package/types/components/Badge/index.d.ts +1 -0
  55. package/types/components/Icon/IconList.d.ts +1 -1
  56. package/types/components/Icon/index.d.ts +1 -1
  57. package/types/components/{Empty → StatusScreens/Empty}/StyledEmpty.d.ts +9 -3
  58. package/types/components/{Empty → StatusScreens/Empty}/index.d.ts +8 -3
  59. package/types/components/{Error → StatusScreens/Error}/StyledError.d.ts +6 -6
  60. package/types/components/{Error → StatusScreens/Error}/index.d.ts +6 -1
  61. package/types/components/StatusScreens/StatusIcon/assets/Add.d.ts +4 -0
  62. package/types/components/StatusScreens/StatusIcon/assets/Boom.d.ts +4 -0
  63. package/types/components/StatusScreens/StatusIcon/assets/Build.d.ts +4 -0
  64. package/types/components/StatusScreens/StatusIcon/assets/Clock.d.ts +4 -0
  65. package/types/components/StatusScreens/StatusIcon/assets/Confetti.d.ts +4 -0
  66. package/types/components/StatusScreens/StatusIcon/assets/Connections.d.ts +4 -0
  67. package/types/components/StatusScreens/StatusIcon/assets/Error.d.ts +4 -0
  68. package/types/components/StatusScreens/StatusIcon/assets/Info.d.ts +4 -0
  69. package/types/components/StatusScreens/StatusIcon/assets/List.d.ts +4 -0
  70. package/types/components/StatusScreens/StatusIcon/assets/Location.d.ts +4 -0
  71. package/types/components/StatusScreens/StatusIcon/assets/Merge.d.ts +4 -0
  72. package/types/components/StatusScreens/StatusIcon/assets/Notifications.d.ts +4 -0
  73. package/types/components/StatusScreens/StatusIcon/assets/Search.d.ts +4 -0
  74. package/types/components/StatusScreens/StatusIcon/assets/Star.d.ts +4 -0
  75. package/types/components/StatusScreens/StatusIcon/assets/Success.d.ts +4 -0
  76. package/types/components/StatusScreens/StatusIcon/assets/User.d.ts +4 -0
  77. package/types/components/StatusScreens/StatusIcon/index.d.ts +26 -0
  78. package/types/components/StatusScreens/StatusIcon/types.d.ts +5 -0
  79. package/types/components/{Success → StatusScreens/Success}/StyledSuccess.d.ts +5 -5
  80. package/types/components/{Success → StatusScreens/Success}/index.d.ts +6 -1
  81. package/types/components/TextInput/index.d.ts +1 -1
  82. package/types/index.d.ts +3 -3
  83. package/types/theme/components/badge.d.ts +11 -0
  84. package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +0 -218
  85. package/src/components/Empty/index.tsx +0 -73
@@ -335,6 +335,269 @@ exports[`Success renders success screen with custom image element correctly 1`]
335
335
  </View>
336
336
  `;
337
337
 
338
+ exports[`Success renders success screen with icon correctly 1`] = `
339
+ <View
340
+ style={
341
+ {
342
+ "flex": 1,
343
+ }
344
+ }
345
+ >
346
+ <View
347
+ style={
348
+ [
349
+ {
350
+ "backgroundColor": "#f6f6f7",
351
+ "display": "flex",
352
+ "flex": 1,
353
+ "flexDirection": "column",
354
+ },
355
+ undefined,
356
+ ]
357
+ }
358
+ themeVariant="in-page"
359
+ >
360
+ <View
361
+ style={
362
+ [
363
+ {
364
+ "alignItems": "center",
365
+ "display": "flex",
366
+ "flex": 1,
367
+ "flexDirection": "column",
368
+ "justifyContent": "center",
369
+ "padding": 24,
370
+ },
371
+ undefined,
372
+ ]
373
+ }
374
+ >
375
+ <View
376
+ style={
377
+ [
378
+ {
379
+ "alignItems": "center",
380
+ "height": 176,
381
+ "marginBottom": 32,
382
+ "width": 176,
383
+ },
384
+ undefined,
385
+ ]
386
+ }
387
+ >
388
+ <RNSVGSvgView
389
+ align="xMidYMid"
390
+ bbHeight="72"
391
+ bbWidth="72"
392
+ focusable={false}
393
+ height="72"
394
+ meetOrSlice={0}
395
+ minX={0}
396
+ minY={0}
397
+ style={
398
+ [
399
+ {
400
+ "backgroundColor": "transparent",
401
+ "borderWidth": 0,
402
+ },
403
+ {
404
+ "flex": 0,
405
+ "height": 72,
406
+ "width": 72,
407
+ },
408
+ ]
409
+ }
410
+ testID="success-icon"
411
+ vbHeight={72}
412
+ vbWidth={72}
413
+ width="72"
414
+ >
415
+ <RNSVGGroup
416
+ fill={
417
+ {
418
+ "payload": 4278190080,
419
+ "type": 0,
420
+ }
421
+ }
422
+ >
423
+ <RNSVGDefs>
424
+ <RNSVGClipPath
425
+ fill={
426
+ {
427
+ "payload": 4278190080,
428
+ "type": 0,
429
+ }
430
+ }
431
+ name="clip0_19647_1726"
432
+ >
433
+ <RNSVGRect
434
+ fill={
435
+ {
436
+ "payload": 4294967295,
437
+ "type": 0,
438
+ }
439
+ }
440
+ height="72"
441
+ propList={
442
+ [
443
+ "fill",
444
+ ]
445
+ }
446
+ width="71.6316"
447
+ x={0}
448
+ y={0}
449
+ />
450
+ </RNSVGClipPath>
451
+ </RNSVGDefs>
452
+ <RNSVGRect
453
+ fill={
454
+ {
455
+ "payload": 4278190080,
456
+ "type": 0,
457
+ }
458
+ }
459
+ height="60.6316"
460
+ propList={
461
+ [
462
+ "stroke",
463
+ ]
464
+ }
465
+ rx="20"
466
+ stroke={
467
+ {
468
+ "payload": 0,
469
+ "type": 0,
470
+ }
471
+ }
472
+ width="60.6316"
473
+ x={0}
474
+ y="11.3684"
475
+ />
476
+ <RNSVGPath
477
+ clipRule={0}
478
+ d="M53.5235 19.5692L53.5265 19.5662C52.9085 19.6113 52.3367 19.8945 51.934 20.3553L38.3475 35.8072L31.977 29.3614H31.9739C31.5435 28.9306 30.9563 28.6836 30.3383 28.6776C29.7234 28.6716 29.13 28.9065 28.6903 29.3312C27.7834 30.2047 27.768 31.6355 28.6565 32.53L36.776 40.7468C37.228 41.2047 37.8582 41.4547 38.5069 41.4366C39.1587 41.4185 39.7706 41.1324 40.1948 40.6505L55.4381 23.3039V23.3009C56.2713 22.3551 56.1668 20.9214 55.1983 20.1021C54.7341 19.7166 54.1314 19.5238 53.5258 19.569L53.5235 19.5692Z"
479
+ fill={
480
+ {
481
+ "payload": 4282390880,
482
+ "type": 0,
483
+ }
484
+ }
485
+ fillRule={0}
486
+ propList={
487
+ [
488
+ "fill",
489
+ "fillRule",
490
+ ]
491
+ }
492
+ />
493
+ <RNSVGRect
494
+ fill={
495
+ {
496
+ "payload": 0,
497
+ "type": 0,
498
+ }
499
+ }
500
+ height="56.6316"
501
+ propList={
502
+ [
503
+ "fill",
504
+ "stroke",
505
+ "strokeWidth",
506
+ ]
507
+ }
508
+ rx="18"
509
+ stroke={
510
+ {
511
+ "payload": 4282390880,
512
+ "type": 0,
513
+ }
514
+ }
515
+ strokeWidth="4"
516
+ width="56.6316"
517
+ x="13"
518
+ y="2"
519
+ />
520
+ </RNSVGGroup>
521
+ </RNSVGSvgView>
522
+ </View>
523
+ <Text
524
+ allowFontScaling={false}
525
+ style={
526
+ [
527
+ {
528
+ "color": "#001f23",
529
+ "fontFamily": "Saiga-Medium",
530
+ "fontSize": 24,
531
+ "letterSpacing": 0.24,
532
+ "lineHeight": 32,
533
+ },
534
+ [
535
+ {
536
+ "color": "#001f23",
537
+ "marginBottom": 8,
538
+ "textAlign": "center",
539
+ },
540
+ undefined,
541
+ ],
542
+ ]
543
+ }
544
+ themeIntent="body"
545
+ themeLevel="h4"
546
+ themeTypeface="playful"
547
+ >
548
+ Two-Factor Authentication
549
+ </Text>
550
+ <Text
551
+ allowFontScaling={false}
552
+ style={
553
+ [
554
+ {
555
+ "color": "#001f23",
556
+ "fontFamily": "BeVietnamPro-Regular",
557
+ "fontSize": 16,
558
+ "letterSpacing": 0.48,
559
+ "lineHeight": 24,
560
+ },
561
+ [
562
+ {
563
+ "color": "#4d6265",
564
+ "textAlign": "center",
565
+ },
566
+ undefined,
567
+ ],
568
+ ]
569
+ }
570
+ themeIntent="body"
571
+ themeTypeface="neutral"
572
+ themeVariant="regular"
573
+ >
574
+ Protecting your sensitive data is important to us. Verifying your mobile number or using an authenticator app makes it harder for attackers to access personal and sensitive information.
575
+ </Text>
576
+ </View>
577
+ </View>
578
+ <View
579
+ pointerEvents="box-none"
580
+ position="bottom"
581
+ style={
582
+ [
583
+ {
584
+ "bottom": 0,
585
+ "elevation": 9999,
586
+ "flexDirection": "column-reverse",
587
+ "left": 0,
588
+ "paddingHorizontal": 24,
589
+ "paddingVertical": 16,
590
+ "position": "absolute",
591
+ "right": 0,
592
+ "top": 0,
593
+ },
594
+ undefined,
595
+ ]
596
+ }
597
+ />
598
+ </View>
599
+ `;
600
+
338
601
  exports[`Success renders success screen with image correctly 1`] = `
339
602
  <View
340
603
  style={
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import { fireEvent } from '@testing-library/react-native';
3
- import renderWithTheme from '../../../testHelpers/renderWithTheme';
3
+ import renderWithTheme from '../../../../testHelpers/renderWithTheme';
4
4
  import Success from '..';
5
- import Image from '../../Image';
6
- import Portal from '../../Portal';
7
- import Typography from '../../Typography';
5
+ import Image from '../../../Image';
6
+ import Portal from '../../../Portal';
7
+ import Typography from '../../../Typography';
8
8
 
9
9
  const title = `Two-Factor Authentication`;
10
10
  const description = `Protecting your sensitive data is important to us. Verifying your mobile number or using an authenticator app makes it harder for attackers to access personal and sensitive information.`;
@@ -69,6 +69,15 @@ describe('Success', () => {
69
69
  expect(toJSON()).toMatchSnapshot();
70
70
  });
71
71
 
72
+ it('renders success screen with icon correctly', () => {
73
+ const { toJSON, getByTestId } = renderWithTheme(
74
+ <Success title={title} description={description} icon="success" />
75
+ );
76
+
77
+ expect(toJSON()).toMatchSnapshot();
78
+ expect(getByTestId('success-icon')).toBeVisible();
79
+ });
80
+
72
81
  it('renders full screen success page correctly', () => {
73
82
  const { toJSON, getByText, getByTestId } = renderWithTheme(
74
83
  <Portal.Provider>
@@ -16,8 +16,9 @@ import {
16
16
  StyledSuccessButtonPrimary,
17
17
  StyledSuccessModal,
18
18
  } from './StyledSuccess';
19
- import { ImageProps } from '../Image';
20
- import { noop } from '../../utils/functions';
19
+ import { ImageProps } from '../../Image';
20
+ import { noop } from '../../../utils/functions';
21
+ import StatusIcon, { StatusIconName } from '../StatusIcon';
21
22
 
22
23
  export interface SuccessProps extends ViewProps {
23
24
  /**
@@ -59,6 +60,10 @@ export interface SuccessProps extends ViewProps {
59
60
  * Testing id of the component.
60
61
  */
61
62
  testID?: string;
63
+ /**
64
+ * Status icon to be displayed, this will replace the image prop.
65
+ */
66
+ icon?: StatusIconName;
62
67
  }
63
68
 
64
69
  const renderImage = (
@@ -78,6 +83,35 @@ const renderImage = (
78
83
  );
79
84
  };
80
85
 
86
+ const renderImageOrIcon = ({
87
+ image,
88
+ icon,
89
+ }: {
90
+ image?:
91
+ | ReactElement<ImageProps | RNImageProps>
92
+ | ImageSourcePropType
93
+ | string;
94
+ icon?: StatusIconName;
95
+ }) => {
96
+ if (icon) {
97
+ return (
98
+ <StyledSuccessImageContainer>
99
+ <StatusIcon icon={icon} testID="success-icon" />
100
+ </StyledSuccessImageContainer>
101
+ );
102
+ }
103
+
104
+ if (image) {
105
+ return (
106
+ <StyledSuccessImageContainer>
107
+ {renderImage(image)}
108
+ </StyledSuccessImageContainer>
109
+ );
110
+ }
111
+
112
+ return null;
113
+ };
114
+
81
115
  const SuccessPage = ({
82
116
  variant = 'in-page',
83
117
  title,
@@ -88,6 +122,7 @@ const SuccessPage = ({
88
122
  onCtaPress = noop,
89
123
  secondaryCtaText,
90
124
  onSecondaryCtaPress,
125
+ icon,
91
126
  ...nativeProps
92
127
  }: SuccessProps): ReactElement => {
93
128
  const showSecondaryButton = secondaryCtaText && onSecondaryCtaPress;
@@ -99,11 +134,7 @@ const SuccessPage = ({
99
134
  {...nativeProps}
100
135
  >
101
136
  <StyledSuccessContent>
102
- {!!image && (
103
- <StyledSuccessImageContainer>
104
- {renderImage(image)}
105
- </StyledSuccessImageContainer>
106
- )}
137
+ {renderImageOrIcon({ image, icon })}
107
138
  <StyledSuccessTitle level="h4" typeface="playful">
108
139
  {title}
109
140
  </StyledSuccessTitle>
package/src/index.ts CHANGED
@@ -38,8 +38,8 @@ import ContentNavigator from './components/ContentNavigator';
38
38
  import DatePicker from './components/DatePicker';
39
39
  import Divider from './components/Divider';
40
40
  import Drawer from './components/Drawer';
41
- import Empty from './components/Empty';
42
- import Error from './components/Error';
41
+ import Empty from './components/StatusScreens/Empty';
42
+ import Error from './components/StatusScreens/Error';
43
43
  import FAB from './components/FAB';
44
44
  import HeroDesignProvider from './components/HeroDesignProvider';
45
45
  import MapPin from './components/MapPin';
@@ -55,7 +55,7 @@ import Radio from './components/Radio';
55
55
  import SectionHeading from './components/SectionHeading';
56
56
  import Select from './components/Select';
57
57
  import Skeleton from './components/Skeleton';
58
- import Success from './components/Success';
58
+ import Success from './components/StatusScreens/Success';
59
59
  import Switch from './components/Switch';
60
60
  import Tabs from './components/Tabs';
61
61
  import Tag from './components/Tag';
@@ -148,6 +148,7 @@ exports[`theme returns correct theme object 1`] = `
148
148
  "colors": {
149
149
  "archived": "#606065",
150
150
  "border": "#ffffff",
151
+ "countText": "#ffffff",
151
152
  "danger": "#cb300a",
152
153
  "info": "#355bfb",
153
154
  "primary": "#401960",
@@ -156,6 +157,7 @@ exports[`theme returns correct theme object 1`] = `
156
157
  "warning": "#ac5d00",
157
158
  },
158
159
  "fontSizes": {
160
+ "count": 6,
159
161
  "icon": {
160
162
  "medium": 12,
161
163
  "small": 8,
@@ -168,10 +170,18 @@ exports[`theme returns correct theme object 1`] = `
168
170
  "small": "BeVietnamPro-SemiBold",
169
171
  },
170
172
  "lineHeights": {
173
+ "count": 12,
171
174
  "medium": 16,
172
175
  "small": 10,
173
176
  },
177
+ "radii": {
178
+ "count": 999,
179
+ },
174
180
  "sizes": {
181
+ "count": {
182
+ "height": 12,
183
+ "width": 12,
184
+ },
175
185
  "medium": {
176
186
  "height": 24,
177
187
  "minWidth": 24,
@@ -184,6 +194,7 @@ exports[`theme returns correct theme object 1`] = `
184
194
  "statusWidth": 8,
185
195
  },
186
196
  "space": {
197
+ "countPaddingHorizontal": 2,
187
198
  "medium": {
188
199
  "horizontalPadding": 8,
189
200
  },
@@ -1,3 +1,4 @@
1
+ import { Platform } from 'react-native';
1
2
  import type { GlobalTheme } from '../global';
2
3
 
3
4
  const getBadgeTheme = (theme: GlobalTheme) => {
@@ -10,6 +11,7 @@ const getBadgeTheme = (theme: GlobalTheme) => {
10
11
  archived: theme.colors.onArchivedSurface,
11
12
  text: theme.colors.onDarkGlobalSurface,
12
13
  border: theme.colors.defaultGlobalSurface,
14
+ countText: theme.colors.onDarkGlobalSurface,
13
15
  };
14
16
 
15
17
  const fonts = {
@@ -24,11 +26,20 @@ const getBadgeTheme = (theme: GlobalTheme) => {
24
26
  medium: theme.fontSizes.small,
25
27
  small: 8,
26
28
  },
29
+ count: 6,
27
30
  };
28
31
 
29
32
  const lineHeights = {
30
33
  medium: theme.lineHeights.small,
31
34
  small: 10,
35
+ count: Platform.select({
36
+ android: 11, // vertical alignment
37
+ default: 12,
38
+ }),
39
+ };
40
+
41
+ const radii = {
42
+ count: theme.radii.rounded,
32
43
  };
33
44
 
34
45
  const sizes = {
@@ -42,6 +53,10 @@ const getBadgeTheme = (theme: GlobalTheme) => {
42
53
  },
43
54
  statusHeight: theme.sizes.small,
44
55
  statusWidth: theme.sizes.small,
56
+ count: {
57
+ width: theme.sizes.smallMedium,
58
+ height: theme.sizes.smallMedium,
59
+ },
45
60
  };
46
61
 
47
62
  const borderWidths = {
@@ -57,9 +72,19 @@ const getBadgeTheme = (theme: GlobalTheme) => {
57
72
  },
58
73
  statusPositionTop: -theme.space.xxsmall,
59
74
  statusPositionRight: -theme.space.xxsmall,
75
+ countPaddingHorizontal: theme.space.xxsmall,
60
76
  };
61
77
 
62
- return { colors, fonts, fontSizes, sizes, space, lineHeights, borderWidths };
78
+ return {
79
+ colors,
80
+ fonts,
81
+ fontSizes,
82
+ sizes,
83
+ space,
84
+ lineHeights,
85
+ borderWidths,
86
+ radii,
87
+ };
63
88
  };
64
89
 
65
90
  export type BadgeThemeType = ReturnType<typeof getBadgeTheme>;