@ledgerhq/lumen-ui-rnative 0.1.51 → 0.1.53

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 (123) hide show
  1. package/dist/module/index.js +1 -1
  2. package/dist/module/index.js.map +1 -1
  3. package/dist/module/lib/Components/Avatar/Avatar.figma.js +3 -6
  4. package/dist/module/lib/Components/Avatar/Avatar.figma.js.map +1 -1
  5. package/dist/module/lib/Components/Avatar/Avatar.js +92 -39
  6. package/dist/module/lib/Components/Avatar/Avatar.js.map +1 -1
  7. package/dist/module/lib/Components/Avatar/Avatar.mdx +36 -191
  8. package/dist/module/lib/Components/Avatar/Avatar.stories.js +80 -125
  9. package/dist/module/lib/Components/Avatar/Avatar.stories.js.map +1 -1
  10. package/dist/module/lib/Components/Avatar/Avatar.test.js +56 -45
  11. package/dist/module/lib/Components/Avatar/Avatar.test.js.map +1 -1
  12. package/dist/module/lib/Components/Avatar/index.js +1 -0
  13. package/dist/module/lib/Components/Avatar/index.js.map +1 -1
  14. package/dist/module/lib/Components/Avatar/resolveAvatarColor.js +18 -0
  15. package/dist/module/lib/Components/Avatar/resolveAvatarColor.js.map +1 -0
  16. package/dist/module/lib/Components/AvatarButton/AvatarButton.js +77 -0
  17. package/dist/module/lib/Components/AvatarButton/AvatarButton.js.map +1 -0
  18. package/dist/module/lib/Components/AvatarButton/AvatarButton.mdx +62 -0
  19. package/dist/module/lib/Components/AvatarButton/AvatarButton.stories.js +59 -0
  20. package/dist/module/lib/Components/AvatarButton/AvatarButton.stories.js.map +1 -0
  21. package/dist/module/lib/Components/AvatarButton/AvatarButton.test.js +100 -0
  22. package/dist/module/lib/Components/AvatarButton/AvatarButton.test.js.map +1 -0
  23. package/dist/module/lib/Components/AvatarButton/index.js +5 -0
  24. package/dist/module/lib/Components/AvatarButton/index.js.map +1 -0
  25. package/dist/module/lib/Components/AvatarButton/types.js +4 -0
  26. package/dist/module/lib/Components/AvatarButton/types.js.map +1 -0
  27. package/dist/module/lib/Components/BottomSheet/BottomSheet.js +4 -1
  28. package/dist/module/lib/Components/BottomSheet/BottomSheet.js.map +1 -1
  29. package/dist/module/lib/Components/BottomSheet/BottomSheet.mdx +133 -2
  30. package/dist/module/lib/Components/BottomSheet/BottomSheet.stories.js +114 -7
  31. package/dist/module/lib/Components/BottomSheet/BottomSheet.stories.js.map +1 -1
  32. package/dist/module/lib/Components/BottomSheet/BottomSheet.test.js +150 -1
  33. package/dist/module/lib/Components/BottomSheet/BottomSheet.test.js.map +1 -1
  34. package/dist/module/lib/Components/BottomSheet/BottomSheetContent.js +35 -0
  35. package/dist/module/lib/Components/BottomSheet/BottomSheetContent.js.map +1 -0
  36. package/dist/module/lib/Components/BottomSheet/BottomSheetFooter.js +43 -0
  37. package/dist/module/lib/Components/BottomSheet/BottomSheetFooter.js.map +1 -0
  38. package/dist/module/lib/Components/BottomSheet/Scrollables.js +18 -3
  39. package/dist/module/lib/Components/BottomSheet/Scrollables.js.map +1 -1
  40. package/dist/module/lib/Components/BottomSheet/index.js +2 -0
  41. package/dist/module/lib/Components/BottomSheet/index.js.map +1 -1
  42. package/dist/module/lib/Components/DotIndicator/getDotIndicatorProps.js +16 -1
  43. package/dist/module/lib/Components/DotIndicator/getDotIndicatorProps.js.map +1 -1
  44. package/dist/module/lib/Components/DotIndicator/getDotIndicatorProps.test.js +16 -0
  45. package/dist/module/lib/Components/DotIndicator/getDotIndicatorProps.test.js.map +1 -1
  46. package/dist/module/lib/Components/MediaBanner/MediaBanner.js +55 -37
  47. package/dist/module/lib/Components/MediaBanner/MediaBanner.js.map +1 -1
  48. package/dist/module/lib/Components/MediaBanner/MediaBanner.mdx +25 -3
  49. package/dist/module/lib/Components/MediaBanner/MediaBanner.stories.js +23 -0
  50. package/dist/module/lib/Components/MediaBanner/MediaBanner.stories.js.map +1 -1
  51. package/dist/module/lib/Components/MediaBanner/MediaBanner.test.js +17 -0
  52. package/dist/module/lib/Components/MediaBanner/MediaBanner.test.js.map +1 -1
  53. package/dist/module/lib/Components/index.js +1 -0
  54. package/dist/module/lib/Components/index.js.map +1 -1
  55. package/dist/typescript/src/index.d.ts +1 -1
  56. package/dist/typescript/src/index.d.ts.map +1 -1
  57. package/dist/typescript/src/lib/Components/Avatar/Avatar.d.ts +3 -3
  58. package/dist/typescript/src/lib/Components/Avatar/Avatar.d.ts.map +1 -1
  59. package/dist/typescript/src/lib/Components/Avatar/index.d.ts +1 -0
  60. package/dist/typescript/src/lib/Components/Avatar/index.d.ts.map +1 -1
  61. package/dist/typescript/src/lib/Components/Avatar/resolveAvatarColor.d.ts +8 -0
  62. package/dist/typescript/src/lib/Components/Avatar/resolveAvatarColor.d.ts.map +1 -0
  63. package/dist/typescript/src/lib/Components/Avatar/types.d.ts +22 -7
  64. package/dist/typescript/src/lib/Components/Avatar/types.d.ts.map +1 -1
  65. package/dist/typescript/src/lib/Components/AvatarButton/AvatarButton.d.ts +13 -0
  66. package/dist/typescript/src/lib/Components/AvatarButton/AvatarButton.d.ts.map +1 -0
  67. package/dist/typescript/src/lib/Components/AvatarButton/index.d.ts +3 -0
  68. package/dist/typescript/src/lib/Components/AvatarButton/index.d.ts.map +1 -0
  69. package/dist/typescript/src/lib/Components/AvatarButton/types.d.ts +11 -0
  70. package/dist/typescript/src/lib/Components/AvatarButton/types.d.ts.map +1 -0
  71. package/dist/typescript/src/lib/Components/BottomSheet/BottomSheet.d.ts +8 -1
  72. package/dist/typescript/src/lib/Components/BottomSheet/BottomSheet.d.ts.map +1 -1
  73. package/dist/typescript/src/lib/Components/BottomSheet/BottomSheetContent.d.ts +3 -0
  74. package/dist/typescript/src/lib/Components/BottomSheet/BottomSheetContent.d.ts.map +1 -0
  75. package/dist/typescript/src/lib/Components/BottomSheet/BottomSheetFooter.d.ts +3 -0
  76. package/dist/typescript/src/lib/Components/BottomSheet/BottomSheetFooter.d.ts.map +1 -0
  77. package/dist/typescript/src/lib/Components/BottomSheet/Scrollables.d.ts +1 -0
  78. package/dist/typescript/src/lib/Components/BottomSheet/Scrollables.d.ts.map +1 -1
  79. package/dist/typescript/src/lib/Components/BottomSheet/index.d.ts +2 -0
  80. package/dist/typescript/src/lib/Components/BottomSheet/index.d.ts.map +1 -1
  81. package/dist/typescript/src/lib/Components/BottomSheet/types.d.ts +2 -0
  82. package/dist/typescript/src/lib/Components/BottomSheet/types.d.ts.map +1 -1
  83. package/dist/typescript/src/lib/Components/DotIndicator/getDotIndicatorProps.d.ts +32 -0
  84. package/dist/typescript/src/lib/Components/DotIndicator/getDotIndicatorProps.d.ts.map +1 -1
  85. package/dist/typescript/src/lib/Components/MediaBanner/MediaBanner.d.ts +1 -1
  86. package/dist/typescript/src/lib/Components/MediaBanner/MediaBanner.d.ts.map +1 -1
  87. package/dist/typescript/src/lib/Components/MediaBanner/types.d.ts +1 -1
  88. package/dist/typescript/src/lib/Components/MediaBanner/types.d.ts.map +1 -1
  89. package/dist/typescript/src/lib/Components/index.d.ts +1 -0
  90. package/dist/typescript/src/lib/Components/index.d.ts.map +1 -1
  91. package/package.json +3 -3
  92. package/src/index.ts +1 -1
  93. package/src/lib/Components/Avatar/Avatar.figma.tsx +2 -5
  94. package/src/lib/Components/Avatar/Avatar.mdx +36 -191
  95. package/src/lib/Components/Avatar/Avatar.stories.tsx +58 -83
  96. package/src/lib/Components/Avatar/Avatar.test.tsx +58 -58
  97. package/src/lib/Components/Avatar/Avatar.tsx +100 -32
  98. package/src/lib/Components/Avatar/index.ts +1 -0
  99. package/src/lib/Components/Avatar/resolveAvatarColor.ts +19 -0
  100. package/src/lib/Components/Avatar/types.ts +23 -7
  101. package/src/lib/Components/AvatarButton/AvatarButton.mdx +62 -0
  102. package/src/lib/Components/AvatarButton/AvatarButton.stories.tsx +58 -0
  103. package/src/lib/Components/AvatarButton/AvatarButton.test.tsx +92 -0
  104. package/src/lib/Components/AvatarButton/AvatarButton.tsx +77 -0
  105. package/src/lib/Components/AvatarButton/index.ts +2 -0
  106. package/src/lib/Components/AvatarButton/types.ts +15 -0
  107. package/src/lib/Components/BottomSheet/BottomSheet.mdx +133 -2
  108. package/src/lib/Components/BottomSheet/BottomSheet.stories.tsx +111 -5
  109. package/src/lib/Components/BottomSheet/BottomSheet.test.tsx +140 -0
  110. package/src/lib/Components/BottomSheet/BottomSheet.tsx +25 -9
  111. package/src/lib/Components/BottomSheet/BottomSheetContent.tsx +44 -0
  112. package/src/lib/Components/BottomSheet/BottomSheetFooter.tsx +47 -0
  113. package/src/lib/Components/BottomSheet/Scrollables.tsx +25 -12
  114. package/src/lib/Components/BottomSheet/index.ts +2 -0
  115. package/src/lib/Components/BottomSheet/types.ts +2 -1
  116. package/src/lib/Components/DotIndicator/getDotIndicatorProps.test.ts +16 -0
  117. package/src/lib/Components/DotIndicator/getDotIndicatorProps.ts +6 -2
  118. package/src/lib/Components/MediaBanner/MediaBanner.mdx +25 -3
  119. package/src/lib/Components/MediaBanner/MediaBanner.stories.tsx +25 -0
  120. package/src/lib/Components/MediaBanner/MediaBanner.test.tsx +18 -0
  121. package/src/lib/Components/MediaBanner/MediaBanner.tsx +54 -32
  122. package/src/lib/Components/MediaBanner/types.ts +1 -1
  123. package/src/lib/Components/index.ts +1 -0
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  export { Languages } from "./i18n/index.js";
4
- export { RuntimeConstants } from "./lib/utils/index.js";
4
+ export { RuntimeConstants, useControllableState } from "./lib/utils/index.js";
5
5
  export { useTheme, useStyleSheet } from "./styles/index.js";
6
6
  export * from "./lib/Components/index.js";
7
7
  export * from "./lib/Animations/index.js";
@@ -1 +1 @@
1
- {"version":3,"names":["Languages","RuntimeConstants","useTheme","useStyleSheet"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SAA+BA,SAAS,QAAQ,iBAAQ;AACxD,SAASC,gBAAgB,QAAQ,sBAAa;AAC9C,SAASC,QAAQ,EAAEC,aAAa,QAAQ,mBAAU;AAClD,cAAc,2BAAkB;AAChC,cAAc,2BAAkB;AAChC,cAAc,wBAAe","ignoreList":[]}
1
+ {"version":3,"names":["Languages","RuntimeConstants","useControllableState","useTheme","useStyleSheet"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SAA+BA,SAAS,QAAQ,iBAAQ;AACxD,SAASC,gBAAgB,EAAEC,oBAAoB,QAAQ,sBAAa;AACpE,SAASC,QAAQ,EAAEC,aAAa,QAAQ,mBAAU;AAClD,cAAc,2BAAkB;AAChC,cAAc,2BAAkB;AAChC,cAAc,wBAAe","ignoreList":[]}
@@ -7,22 +7,19 @@ import { jsx as _jsx } from "react/jsx-runtime";
7
7
  figma.connect(Avatar, 'https://www.figma.com/design/JxaLVMTWirCpU0rsbZ30k7?node-id=11097-8', {
8
8
  imports: ["import { Avatar, DotIndicator, getDotIndicatorProps } from '@ledgerhq/lumen-ui-rnative'"],
9
9
  props: {
10
- appearance: figma.enum('appearance', {
11
- gray: 'gray',
12
- transparent: 'transparent'
13
- }),
14
10
  size: figma.enum('size', {
11
+ xs: 'xs',
15
12
  sm: 'sm',
16
13
  md: 'md',
17
14
  lg: 'lg',
18
- xl: 'xl'
15
+ xl: 'xl',
16
+ '2xl': '2xl'
19
17
  }),
20
18
  showNotification: figma.boolean('show-notification')
21
19
  },
22
20
  example: props => {
23
21
  const avatar = /*#__PURE__*/_jsx(Avatar, {
24
22
  src: "https://example-image.com",
25
- appearance: props.appearance,
26
23
  size: props.size,
27
24
  alt: "John Doe's Avatar"
28
25
  });
@@ -1 +1 @@
1
- {"version":3,"names":["figma","DotIndicator","getDotIndicatorProps","Avatar","jsx","_jsx","connect","imports","props","appearance","enum","gray","transparent","size","sm","md","lg","xl","showNotification","boolean","example","avatar","src","alt","children"],"sourceRoot":"../../../../../src","sources":["lib/Components/Avatar/Avatar.figma.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,qBAAqB;AACvC,SAASC,YAAY,EAAEC,oBAAoB,QAAQ,0BAAiB;AACpE,SAASC,MAAM,QAAQ,aAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAElCL,KAAK,CAACM,OAAO,CACXH,MAAM,EACN,qEAAqE,EACrE;EACEI,OAAO,EAAE,CACP,yFAAyF,CAC1F;EACDC,KAAK,EAAE;IACLC,UAAU,EAAET,KAAK,CAACU,IAAI,CAAC,YAAY,EAAE;MACnCC,IAAI,EAAE,MAAM;MACZC,WAAW,EAAE;IACf,CAAC,CAAC;IACFC,IAAI,EAAEb,KAAK,CAACU,IAAI,CAAC,MAAM,EAAE;MACvBI,EAAE,EAAE,IAAI;MACRC,EAAE,EAAE,IAAI;MACRC,EAAE,EAAE,IAAI;MACRC,EAAE,EAAE;IACN,CAAC,CAAC;IACFC,gBAAgB,EAAElB,KAAK,CAACmB,OAAO,CAAC,mBAAmB;EACrD,CAAC;EACDC,OAAO,EAAGZ,KAAK,IAAK;IAClB,MAAMa,MAAM,gBACVhB,IAAA,CAACF,MAAM;MACLmB,GAAG,EAAC,2BAA2B;MAC/Bb,UAAU,EAAED,KAAK,CAACC,UAAW;MAC7BI,IAAI,EAAEL,KAAK,CAACK,IAAK;MACjBU,GAAG,EAAC;IAAmB,CACxB,CACF;IAED,OAAOf,KAAK,CAACU,gBAAgB,KAC1BV,KAAK,CAACK,IAAI,KAAK,IAAI,IAAIL,KAAK,CAACK,IAAI,KAAK,IAAI,CAAC,gBAC5CR,IAAA,CAACJ,YAAY;MAAA,GAAKC,oBAAoB,CAAC,QAAQ,EAAEM,KAAK,CAACK,IAAI,CAAC;MAAAW,QAAA,EACzDH;IAAM,CACK,CAAC,GAEfA,MACD;EACH;AACF,CACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["figma","DotIndicator","getDotIndicatorProps","Avatar","jsx","_jsx","connect","imports","props","size","enum","xs","sm","md","lg","xl","showNotification","boolean","example","avatar","src","alt","children"],"sourceRoot":"../../../../../src","sources":["lib/Components/Avatar/Avatar.figma.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,qBAAqB;AACvC,SAASC,YAAY,EAAEC,oBAAoB,QAAQ,0BAAiB;AACpE,SAASC,MAAM,QAAQ,aAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAElCL,KAAK,CAACM,OAAO,CACXH,MAAM,EACN,qEAAqE,EACrE;EACEI,OAAO,EAAE,CACP,yFAAyF,CAC1F;EACDC,KAAK,EAAE;IACLC,IAAI,EAAET,KAAK,CAACU,IAAI,CAAC,MAAM,EAAE;MACvBC,EAAE,EAAE,IAAI;MACRC,EAAE,EAAE,IAAI;MACRC,EAAE,EAAE,IAAI;MACRC,EAAE,EAAE,IAAI;MACRC,EAAE,EAAE,IAAI;MACR,KAAK,EAAE;IACT,CAAC,CAAC;IACFC,gBAAgB,EAAEhB,KAAK,CAACiB,OAAO,CAAC,mBAAmB;EACrD,CAAC;EACDC,OAAO,EAAGV,KAAK,IAAK;IAClB,MAAMW,MAAM,gBACVd,IAAA,CAACF,MAAM;MACLiB,GAAG,EAAC,2BAA2B;MAC/BX,IAAI,EAAED,KAAK,CAACC,IAAK;MACjBY,GAAG,EAAC;IAAmB,CACxB,CACF;IAED,OAAOb,KAAK,CAACQ,gBAAgB,KAC1BR,KAAK,CAACC,IAAI,KAAK,IAAI,IAAID,KAAK,CAACC,IAAI,KAAK,IAAI,CAAC,gBAC5CJ,IAAA,CAACJ,YAAY;MAAA,GAAKC,oBAAoB,CAAC,QAAQ,EAAEM,KAAK,CAACC,IAAI,CAAC;MAAAa,QAAA,EACzDH;IAAM,CACK,CAAC,GAEfA,MACD;EACH;AACF,CACF,CAAC","ignoreList":[]}
@@ -1,71 +1,117 @@
1
1
  "use strict";
2
2
 
3
3
  import { useEffect, useState } from 'react';
4
- import { Image, StyleSheet } from 'react-native';
4
+ import { Image, StyleSheet, Text, View } from 'react-native';
5
5
  import { useCommonTranslation } from "../../../i18n/index.js";
6
6
  import { useStyleSheet } from "../../../styles/index.js";
7
7
  import { User } from "../../Symbols/index.js";
8
8
  import { Box } from "../Utility/index.js";
9
- import { jsx as _jsx } from "react/jsx-runtime";
10
- const fallbackSizes = {
9
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
+ const fallbackIconSizes = {
11
+ xs: 12,
11
12
  sm: 16,
12
13
  md: 24,
13
14
  lg: 32,
14
- xl: 40
15
+ xl: 40,
16
+ '2xl': 56
15
17
  };
16
18
  const useStyles = ({
17
- appearance,
18
- size
19
+ size,
20
+ fallbackColor,
21
+ shouldFallback,
22
+ appearance
19
23
  }) => {
20
24
  return useStyleSheet(t => {
21
- const backgroundColors = {
22
- gray: t.colors.bg.muted,
23
- transparent: t.colors.bg.mutedTransparent
24
- };
25
25
  const sizeMap = {
26
+ xs: {
27
+ size: t.sizes.s24
28
+ },
26
29
  sm: {
27
- size: t.sizes.s40,
28
- padding: t.spacings.s4
30
+ size: t.sizes.s40
29
31
  },
30
32
  md: {
31
- size: t.sizes.s48,
32
- padding: t.spacings.s4
33
+ size: t.sizes.s48
33
34
  },
34
35
  lg: {
35
- size: t.sizes.s56,
36
- padding: t.spacings.s4
36
+ size: t.sizes.s56
37
37
  },
38
38
  xl: {
39
- size: t.sizes.s72,
40
- padding: t.spacings.s4
39
+ size: t.sizes.s72
40
+ },
41
+ '2xl': {
42
+ size: t.sizes.s128
41
43
  }
42
44
  };
45
+ const fallbackTextTypography = {
46
+ xs: t.typographies.body4SemiBold,
47
+ sm: t.typographies.body1SemiBold,
48
+ md: t.typographies.heading5SemiBold,
49
+ lg: t.typographies.heading4SemiBold,
50
+ xl: t.typographies.heading2SemiBold,
51
+ '2xl': t.typographies.heading1SemiBold
52
+ };
43
53
  return {
44
54
  root: {
45
55
  position: 'relative',
46
56
  width: sizeMap[size].size,
47
57
  height: sizeMap[size].size,
48
58
  borderRadius: 9999,
49
- backgroundColor: backgroundColors[appearance],
59
+ overflow: 'hidden',
60
+ backgroundColor: shouldFallback && fallbackColor ? fallbackColor : t.colors.bg.baseTransparentHover,
50
61
  alignItems: 'center',
51
- justifyContent: 'center',
52
- padding: sizeMap[size].padding
62
+ justifyContent: 'center'
63
+ },
64
+ fallbackText: {
65
+ ...fallbackTextTypography[size],
66
+ color: fallbackColor ? t.colors.text.black : t.colors.text.base
53
67
  },
54
68
  image: {
55
- width: '100%',
56
- height: '100%',
57
- overflow: 'hidden',
58
- borderRadius: 9999
69
+ position: 'absolute',
70
+ top: 0,
71
+ left: 0,
72
+ right: 0,
73
+ bottom: 0
74
+ },
75
+ insetBorder: {
76
+ position: 'absolute',
77
+ top: 0,
78
+ left: 0,
79
+ right: 0,
80
+ bottom: 0,
81
+ borderRadius: 9999,
82
+ ...(appearance === 'thin' && {
83
+ borderWidth: 1,
84
+ borderColor: t.colors.border.icon
85
+ }),
86
+ ...(appearance === 'thick' && {
87
+ borderWidth: 2,
88
+ borderColor: t.colors.border.mutedSubtleTransparent
89
+ })
59
90
  }
60
91
  };
61
- }, [appearance, size]);
92
+ }, [size, fallbackColor, shouldFallback, appearance]);
62
93
  };
94
+ const FallbackContent = ({
95
+ size,
96
+ fallbackText,
97
+ fallbackColor,
98
+ styles
99
+ }) => fallbackText ? /*#__PURE__*/_jsx(Text, {
100
+ style: styles.fallbackText,
101
+ selectable: false,
102
+ children: fallbackText
103
+ }) : /*#__PURE__*/_jsx(User, {
104
+ size: fallbackIconSizes[size],
105
+ color: fallbackColor ? 'black' : 'base',
106
+ accessible: false,
107
+ testID: "avatar-fallback-icon"
108
+ });
63
109
 
64
110
  /**
65
111
  * A circular avatar component that displays a user image or fallback icon.
66
112
  *
67
- * When the image fails to load or no src is provided, displays a User icon fallback.
68
- * Supports an optional notification indicator.
113
+ * When the image fails to load or no src is provided, displays either the
114
+ * `fallbackText` (e.g. initials) or a User icon fallback.
69
115
  *
70
116
  * @see {@link https://ldls-react-native.vercel.app/?path=/docs/rnative-avatar--docs Storybook}
71
117
  *
@@ -78,9 +124,11 @@ export const Avatar = ({
78
124
  lx,
79
125
  style,
80
126
  src,
81
- alt = 'avatar',
82
- appearance = 'transparent',
127
+ alt,
83
128
  size = 'md',
129
+ fallbackText,
130
+ fallbackColor,
131
+ appearance,
84
132
  ref,
85
133
  ...props
86
134
  }) => {
@@ -90,24 +138,27 @@ export const Avatar = ({
90
138
  const [error, setError] = useState(false);
91
139
  const shouldFallback = !src || error;
92
140
  const styles = useStyles({
93
- appearance,
94
- size
141
+ size,
142
+ fallbackColor,
143
+ shouldFallback,
144
+ appearance
95
145
  });
96
146
  const resolvedAlt = alt || t('components.avatar.defaultAriaLabel');
97
147
  useEffect(() => {
98
148
  setError(false);
99
149
  }, [src]);
100
- const avatarContent = /*#__PURE__*/_jsx(Box, {
150
+ return /*#__PURE__*/_jsxs(Box, {
101
151
  ref: ref,
102
152
  lx: lx,
103
153
  style: StyleSheet.flatten([styles.root, style]),
104
154
  accessibilityRole: "image",
105
155
  accessibilityLabel: resolvedAlt,
106
156
  ...props,
107
- children: shouldFallback ? /*#__PURE__*/_jsx(User, {
108
- size: fallbackSizes[size],
109
- accessible: false,
110
- testID: "avatar-fallback-icon"
157
+ children: [shouldFallback ? /*#__PURE__*/_jsx(FallbackContent, {
158
+ size: size,
159
+ fallbackText: fallbackText,
160
+ fallbackColor: fallbackColor,
161
+ styles: styles
111
162
  }) : /*#__PURE__*/_jsx(Image, {
112
163
  source: {
113
164
  uri: src
@@ -116,8 +167,10 @@ export const Avatar = ({
116
167
  accessible: false,
117
168
  onError: () => setError(true),
118
169
  testID: "avatar-image"
119
- })
170
+ }), appearance && /*#__PURE__*/_jsx(View, {
171
+ style: styles.insetBorder,
172
+ pointerEvents: "none"
173
+ })]
120
174
  });
121
- return avatarContent;
122
175
  };
123
176
  //# sourceMappingURL=Avatar.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useState","Image","StyleSheet","useCommonTranslation","useStyleSheet","User","Box","jsx","_jsx","fallbackSizes","sm","md","lg","xl","useStyles","appearance","size","t","backgroundColors","gray","colors","bg","muted","transparent","mutedTransparent","sizeMap","sizes","s40","padding","spacings","s4","s48","s56","s72","root","position","width","height","borderRadius","backgroundColor","alignItems","justifyContent","image","overflow","Avatar","lx","style","src","alt","ref","props","error","setError","shouldFallback","styles","resolvedAlt","avatarContent","flatten","accessibilityRole","accessibilityLabel","children","accessible","testID","source","uri","onError"],"sourceRoot":"../../../../../src","sources":["lib/Components/Avatar/Avatar.tsx"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,KAAK,EAAEC,UAAU,QAAQ,cAAc;AAChD,SAASC,oBAAoB,QAAQ,wBAAe;AACpD,SAASC,aAAa,QAAQ,0BAAiB;AAC/C,SAASC,IAAI,QAAQ,wBAAe;AACpC,SAASC,GAAG,QAAQ,qBAAY;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAMjC,MAAMC,aAAa,GAAG;EACpBC,EAAE,EAAE,EAAE;EACNC,EAAE,EAAE,EAAE;EACNC,EAAE,EAAE,EAAE;EACNC,EAAE,EAAE;AACN,CAAU;AAEV,MAAMC,SAAS,GAAGA,CAAC;EACjBC,UAAU;EACVC;AAIF,CAAC,KAAK;EACJ,OAAOZ,aAAa,CACjBa,CAAC,IAAK;IACL,MAAMC,gBAA4C,GAAG;MACnDC,IAAI,EAAEF,CAAC,CAACG,MAAM,CAACC,EAAE,CAACC,KAAK;MACvBC,WAAW,EAAEN,CAAC,CAACG,MAAM,CAACC,EAAE,CAACG;IAC3B,CAAC;IAED,MAAMC,OAAO,GAAG;MACdf,EAAE,EAAE;QAAEM,IAAI,EAAEC,CAAC,CAACS,KAAK,CAACC,GAAG;QAAEC,OAAO,EAAEX,CAAC,CAACY,QAAQ,CAACC;MAAG,CAAC;MACjDnB,EAAE,EAAE;QAAEK,IAAI,EAAEC,CAAC,CAACS,KAAK,CAACK,GAAG;QAAEH,OAAO,EAAEX,CAAC,CAACY,QAAQ,CAACC;MAAG,CAAC;MACjDlB,EAAE,EAAE;QAAEI,IAAI,EAAEC,CAAC,CAACS,KAAK,CAACM,GAAG;QAAEJ,OAAO,EAAEX,CAAC,CAACY,QAAQ,CAACC;MAAG,CAAC;M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,WAAW,GAAGP,GAAG,IAAI/B,CAAC,CAAC,oCAAoC,CAAC;EAElElB,SAAS,CAAC,MAAM;IACdqD,QAAQ,CAAC,KAAK,CAAC;EACjB,CAAC,EAAE,CAACL,GAAG,CAAC,CAAC;EAET,MAAMS,aAAa,gBACjBhD,IAAA,CAACF,GAAG;IACF2C,GAAG,EAAEA,GAAI;IACTJ,EAAE,EAAEA,EAAG;IACPC,KAAK,EAAE5C,UAAU,CAACuD,OAAO,CAAC,CAACH,MAAM,CAACpB,IAAI,EAAEY,KAAK,CAAC,CAAE;IAChDY,iBAAiB,EAAC,OAAO;IACzBC,kBAAkB,EAAEJ,WAAY;IAAA,GAC5BL,KAAK;IAAAU,QAAA,EAERP,cAAc,gBACb7C,IAAA,CAACH,IAAI;MACHW,IAAI,EAAEP,aAAa,CAACO,IAAI,CAAE;MAC1B6C,UAAU,EAAE,KAAM;MAClBC,MAAM,EAAC;IAAsB,CAC9B,CAAC,gBAEFtD,IAAA,CAACP,KAAK;MACJ8D,MAAM,EAAE;QAAEC,GAAG,EAAEjB;MAAI,CAAE;MACrBD,KAAK,EAAEQ,MAAM,CAACZ,KAAM;MACpBmB,UAAU,EAAE,KAAM;MAClBI,OAAO,EAAEA,CAAA,KAAMb,QAAQ,CAAC,IAAI,CAAE;MAC9BU,MAAM,EAAC;IAAc,CACtB;EACF,CACE,CACN;EAED,OAAON,aAAa;AACtB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useEffect","useState","Image","StyleSheet","Text","View","useCommonTranslation","useStyleSheet","User","Box","jsx","_jsx","jsxs","_jsxs","fallbackIconSizes","xs","sm","md","lg","xl","useStyles","size","fallbackColor","shouldFallback","appearance","t","sizeMap","sizes","s24","s40","s48","s56","s72","s128","fallbackTextTypography","typographies","body4SemiBold","body1SemiBold","heading5SemiBold","heading4SemiBold","heading2SemiBold","heading1SemiBold","root","position","width","height","borderRadius","overflow","backgroundColor","colors","bg","baseTransparentHover","alignItems","justifyContent","fallbackText","color","text","black","base","image","top","left","right","bottom","insetBorder","borderWidth","borderColor","border","icon","mutedSubtleTransparent","FallbackContent","styles","style","selectable","children","accessible","testID","Avatar","lx","src","alt","ref","props","error","setError","resolvedAlt","flatten","accessibilityRole","accessibilityLabel","source","uri","onError","pointerEvents"],"sourceRoot":"../../../../../src","sources":["lib/Components/Avatar/Avatar.tsx"],"mappings":";;AACA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,KAAK,EAAEC,UAAU,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAC5D,SAASC,oBAAoB,QAAQ,wBAAe;AACpD,SAASC,aAAa,QAAQ,0BAAiB;AAC/C,SAASC,IAAI,QAAQ,wBAAe;AAEpC,SAASC,GAAG,QAAQ,qBAAY;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAKjC,MAAMC,iBAAyC,GAAG;EAChDC,EAAE,EAAE,EAAE;EACNC,EAAE,EAAE,EAAE;EACNC,EAAE,EAAE,EAAE;EACNC,EAAE,EAAE,EAAE;EACNC,EAAE,EAAE,EAAE;EACN,KAAK,EAAE;AACT,CAAC;AAED,MAAMC,SAAS,GAAGA,CAAC;EACjBC,IAAI;EACJC,aAAa;EACbC,cAAc;EACdC;AAMF,CAAC,KAAK;EACJ,OAAOjB,aAAa,CACjBkB,CAAC,IAAK;IACL,MAAMC,OAAuC,GAAG;MAC9CX,EAAE,EAAE;QAAEM,IAAI,EAAEI,CAAC,CAACE,KAAK,CAACC;MAAI,CAAC;MACzBZ,EAAE,EAAE;QAAEK,IAAI,EAAEI,CAAC,CAACE,KAAK,CAACE;MAAI,CAAC;MACzBZ,EAAE,EAAE;QAAEI,IAAI,EAAEI,CAAC,CAACE,KAAK,CAACG;MAAI,CAAC;MACzBZ,EAAE,EAAE;QAAEG,IAAI,EAAEI,CAAC,CAACE,KAAK,CAACI;MAAI,CAAC;MACzBZ,EAAE,EAAE;QAAEE,IAAI,EAAEI,CAAC,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,CACpE,CAAC;AAEV,CAAC","ignoreList":[]}
@@ -13,7 +13,7 @@ import { Box } from '../Utility';
13
13
 
14
14
  ## Introduction
15
15
 
16
- The Avatar component displays a circular user profile image with automatic fallback to a User icon when the image is unavailable or fails to load. It supports an optional notification indicator and four size variants. This React Native implementation ensures consistent behavior across mobile platforms while maintaining design system coherence.
16
+ The Avatar component displays a circular user profile image with automatic fallback (initials or a User icon) when the image is unavailable or fails to load. It supports an optional notification indicator and six size variants.
17
17
 
18
18
  > View in [Figma](https://www.figma.com/design/JxaLVMTWirCpU0rsbZ30k7/2.-Components-Library?node-id=10546-614&p=f&m=dev).
19
19
 
@@ -23,7 +23,7 @@ The Avatar component displays a circular user profile image with automatic fallb
23
23
 
24
24
  - **Image/Fallback Icon**: The circular user image or User icon fallback displayed when image is unavailable
25
25
  - **Notification Indicator (optional)**: A red dot positioned at the top-right corner to indicate notifications
26
- - **Container**: Rounded full background with muted styling
26
+ - **Container**: Rounded-full container with a subtle bordered background, or a solid `fallbackColor` when showing a fallback
27
27
 
28
28
  ## Properties
29
29
 
@@ -34,27 +34,26 @@ The Avatar component displays a circular user profile image with automatic fallb
34
34
 
35
35
  ### Size
36
36
 
37
- Avatars come in four different sizes:
37
+ Avatars come in six sizes: `xs`, `sm`, `md`, `lg`, `xl`, and `2xl`.
38
38
 
39
39
  <Canvas of={AvatarStories.SizeShowcase} />
40
40
 
41
- ### Appearance
41
+ ### Fallback
42
42
 
43
- The `appearance` prop controls the background color of the avatar container.
43
+ When no image is shown, the Avatar renders a fallback. Provide `fallbackText` for initials, and pass a `fallbackColor` to give each user a stable background color.
44
44
 
45
- - **`gray`**: Uses a muted gray background
46
- - **`transparent`**: Uses a semi-transparent muted background — default
45
+ <Canvas of={AvatarStories.FallbackShowcase} />
47
46
 
48
- <Canvas of={AvatarStories.AppearanceShowcase} />
47
+ ### Appearance
49
48
 
50
- ### States
49
+ Use `appearance` to display an inset ring around the avatar. Two variants are available:
51
50
 
52
- The Avatar component handles two primary states automatically:
51
+ - `thin` — 1px ring, `border-icon` color
52
+ - `thick` — 2px ring, `border-muted-subtle-transparent` color
53
53
 
54
- - **With Image**: Displays the provided image when `src` is valid and loads successfully
55
- - **Fallback**: Shows a User icon when `src` is undefined or the image fails to load
54
+ Omit the prop (or leave it `undefined`) for no ring.
56
55
 
57
- <Canvas of={AvatarStories.FallbackShowcase} />
56
+ <Canvas of={AvatarStories.AppearanceShowcase} />
58
57
 
59
58
  ### Notification Indicator
60
59
 
@@ -71,27 +70,13 @@ import { Avatar, DotIndicator, getDotIndicatorProps } from '@ledgerhq/lumen-ui-r
71
70
  </DotIndicator>;
72
71
  ```
73
72
 
74
- > The notification dot is only supported on the `sm` and `md` sizes.
75
-
76
- > When the dot conveys state to the user, pass an `accessibilityLabel` to `DotIndicator`.
77
-
78
73
  <Canvas of={AvatarStories.NotificationShowcase} />
79
74
 
80
- ### As Interactive Trigger
81
-
82
- Avatars are commonly used as interactive triggers for navigation or actions:
83
-
84
- <Canvas of={AvatarStories.InteractiveShowcase} />
85
-
86
75
  ## Accessibility
87
76
 
88
- To be implemented:
89
-
90
- - **Color contrast**
91
- - **Text zoom support**
92
- - **Semantic alt text for images**
93
- - **Screen reader announcements for notification state**
94
- - **Touch target sizing** (minimum 44px)
77
+ - Renders with `accessibilityRole="image"` and exposes `alt` as `accessibilityLabel`.
78
+ - Provide a meaningful `alt` describing the user (e.g. `"John Doe's profile picture"`).
79
+ - When using `DotIndicator` for notifications, pass an `accessibilityLabel` to it so the notification state is announced by screen readers.
95
80
 
96
81
  </Tab>
97
82
  <Tab label="Implementation">
@@ -100,7 +85,7 @@ To be implemented:
100
85
 
101
86
  Install and set up the library with our [Setup Guide →](?path=/docs/getting-started-setup--docs).
102
87
 
103
- ### Basic Usage
88
+ ## Basic Usage
104
89
 
105
90
  ```tsx
106
91
  import { Avatar } from '@ledgerhq/lumen-ui-rnative';
@@ -110,22 +95,21 @@ function MyComponent() {
110
95
  }
111
96
  ```
112
97
 
113
- ### Fallback Handling
98
+ ## Fallback with Initials and Color
114
99
 
115
- The Avatar component automatically displays a fallback User icon when the image source is undefined or fails to load:
100
+ Use `fallbackText` for initials and `fallbackColor` for a stable per-user background:
116
101
 
117
102
  ```tsx
118
- import { Avatar } from '@ledgerhq/lumen-ui-rnative';
103
+ import { Avatar, resolveAvatarColor } from '@ledgerhq/lumen-ui-rnative';
119
104
 
120
- function MyComponent() {
121
- // Fallback will be shown automatically
122
- return <Avatar size="md" alt="User profile" />;
123
- }
105
+ <Avatar
106
+ fallbackColor={resolveAvatarColor(user.id)}
107
+ fallbackText={user.initials}
108
+ alt={user.name}
109
+ />;
124
110
  ```
125
111
 
126
- ### With Notification
127
-
128
- Wrap the Avatar in a `DotIndicator` to show a status or alert dot, using `getDotIndicatorProps` to match the dot to the avatar size:
112
+ ## With Notification
129
113
 
130
114
  ```tsx
131
115
  import { Avatar, DotIndicator, getDotIndicatorProps } from '@ledgerhq/lumen-ui-rnative';
@@ -146,9 +130,16 @@ function MyComponent() {
146
130
  }
147
131
  ```
148
132
 
149
- ### Different Sizes
133
+ ## Appearance
150
134
 
151
- Choose the appropriate size based on your layout needs:
135
+ Use the `appearance` prop to display a predefined inset ring:
136
+
137
+ ```tsx
138
+ <Avatar src="https://example.com/photo.jpg" size="md" appearance="thin" />
139
+ <Avatar src="https://example.com/photo.jpg" size="md" appearance="thick" />
140
+ ```
141
+
142
+ ## Different Sizes
152
143
 
153
144
  ```tsx
154
145
  import { Avatar, Box } from '@ledgerhq/lumen-ui-rnative';
@@ -156,162 +147,16 @@ import { Avatar, Box } from '@ledgerhq/lumen-ui-rnative';
156
147
  function MyComponent() {
157
148
  return (
158
149
  <Box lx={{ flexDirection: 'row', alignItems: 'center', gap: 's8' }}>
150
+ <Avatar src="https://example.com/photo.jpg" size="xs" />
159
151
  <Avatar src="https://example.com/photo.jpg" size="sm" />
160
152
  <Avatar src="https://example.com/photo.jpg" size="md" />
161
153
  <Avatar src="https://example.com/photo.jpg" size="lg" />
162
154
  <Avatar src="https://example.com/photo.jpg" size="xl" />
155
+ <Avatar src="https://example.com/photo.jpg" size="2xl" />
163
156
  </Box>
164
157
  );
165
158
  }
166
159
  ```
167
160
 
168
- ### As Interactive Trigger
169
-
170
- Avatars are commonly used as interactive triggers for navigation or actions. Wrap the Avatar in a `Pressable` component:
171
-
172
- ```tsx
173
- import { Avatar, DotIndicator, getDotIndicatorProps } from '@ledgerhq/lumen-ui-rnative';
174
- import { Pressable, Linking } from 'react-native';
175
-
176
- function UserProfile() {
177
- const handlePress = () => {
178
- // Navigate or perform action
179
- console.log('Avatar pressed');
180
- };
181
-
182
- return (
183
- <Pressable
184
- onPress={handlePress}
185
- style={({ pressed }) => ({
186
- borderRadius: 9999,
187
- opacity: pressed ? 0.7 : 1,
188
- backgroundColor: pressed ? 'rgba(0, 0, 0, 0.05)' : 'transparent',
189
- })}
190
- >
191
- <DotIndicator
192
- {...getDotIndicatorProps('avatar', 'md')}
193
- accessibilityLabel="New notifications"
194
- >
195
- <Avatar src="https://example.com/photo.jpg" size="md" alt="User menu" />
196
- </DotIndicator>
197
- </Pressable>
198
- );
199
- }
200
- ```
201
-
202
- **Key points:**
203
- - Wrap Avatar in a `Pressable` component for touch interactions
204
- - Use `borderRadius: 9999` to maintain circular touch area
205
- - Add opacity changes for visual feedback on press
206
- - Provide appropriate `alt` text for accessibility
207
- - Pass an `accessibilityLabel` to `DotIndicator` so the notification state is announced by screen readers
208
-
209
- ### Custom Styling
210
-
211
- While the component comes with predefined styles, you can extend them using the `lx` prop for token-based styling:
212
-
213
- ```tsx
214
- <Avatar
215
- src="https://example.com/photo.jpg"
216
- size="md"
217
- lx={{ marginRight: 's8' }} // Layout positioning with design tokens
218
- />
219
- ```
220
-
221
- You can also use the `style` prop for escape-hatch styling when needed:
222
-
223
- ```tsx
224
- <Avatar
225
- src="https://example.com/photo.jpg"
226
- size="md"
227
- style={{ marginRight: 8 }} // Raw style values
228
- />
229
- ```
230
-
231
- ### Complete Example
232
-
233
- Here's a comprehensive example showing all Avatar features in a user profile context:
234
-
235
- ```tsx
236
- import { Avatar, Box, Text, DotIndicator, getDotIndicatorProps } from '@ledgerhq/lumen-ui-rnative';
237
- import { Pressable } from 'react-native';
238
- import { useState } from 'react';
239
-
240
- function UserProfileHeader() {
241
- const [user, setUser] = useState({
242
- name: 'John Doe',
243
- avatar: 'https://example.com/photo.jpg',
244
- hasNotifications: true,
245
- });
246
-
247
- const handleProfilePress = () => {
248
- console.log('Opening user menu...');
249
- // Navigate to profile or show menu
250
- };
251
-
252
- const avatar = (
253
- <Avatar
254
- src={user.avatar}
255
- size="md"
256
- alt={`${user.name} profile picture`}
257
- />
258
- );
259
-
260
- return (
261
- <Box lx={{ flexDirection: 'row', alignItems: 'center', gap: 's12', padding: 's16' }}>
262
- <Pressable
263
- onPress={handleProfilePress}
264
- style={({ pressed }) => ({
265
- borderRadius: 9999,
266
- opacity: pressed ? 0.7 : 1,
267
- backgroundColor: pressed ? 'rgba(0, 0, 0, 0.05)' : 'transparent',
268
- })}
269
- >
270
- {user.hasNotifications ? (
271
- <DotIndicator
272
- {...getDotIndicatorProps('avatar', 'md')}
273
- accessibilityLabel="You have new notifications"
274
- >
275
- {avatar}
276
- </DotIndicator>
277
- ) : (
278
- avatar
279
- )}
280
- </Pressable>
281
- <Box lx={{ flexDirection: 'column' }}>
282
- <Text>{user.name}</Text>
283
- {user.hasNotifications && (
284
- <Text style={{ fontSize: 12, color: '#666' }}>
285
- You have new notifications
286
- </Text>
287
- )}
288
- </Box>
289
- </Box>
290
- );
291
- }
292
- ```
293
-
294
-
295
- ## Platform Considerations
296
-
297
- ### iOS Specific
298
-
299
- - Avatars automatically adapt to iOS design guidelines
300
- - Touch feedback uses appropriate opacity transitions
301
- - Respects iOS accessibility settings like reduced motion
302
-
303
- ### Android Specific
304
-
305
- - Material Design touch feedback is supported through React Native's Pressable
306
- - Handles Android back button interactions appropriately
307
- - Respects Android accessibility services
308
-
309
- ### Cross-Platform
310
-
311
- - Consistent visual appearance across platforms
312
- - Platform-appropriate touch feedback via Pressable
313
- - Unified API regardless of platform
314
- - Images load using React Native's Image component with cross-platform optimization
315
-
316
161
  </Tab>
317
162
  </CustomTabs>