@ledgerhq/lumen-ui-rnative 0.1.61 → 0.1.62
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.
- package/dist/module/lib/Components/core/Avatar/Avatar.js +17 -6
- package/dist/module/lib/Components/core/Avatar/Avatar.js.map +1 -1
- package/dist/module/lib/Components/core/Avatar/Avatar.mdx +10 -6
- package/dist/module/lib/Components/core/Avatar/Avatar.stories.js +15 -6
- package/dist/module/lib/Components/core/Avatar/Avatar.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Avatar/Avatar.test.js +56 -0
- package/dist/module/lib/Components/core/Avatar/Avatar.test.js.map +1 -1
- package/dist/module/lib/Components/core/Avatar/index.js +1 -1
- package/dist/module/lib/Components/core/Avatar/index.js.map +1 -1
- package/dist/module/lib/Components/core/Avatar/useResolveAvatarColor.js +21 -0
- package/dist/module/lib/Components/core/Avatar/useResolveAvatarColor.js.map +1 -0
- package/dist/module/lib/Components/core/Avatar/useResolveAvatarColor.test.js +88 -0
- package/dist/module/lib/Components/core/Avatar/useResolveAvatarColor.test.js.map +1 -0
- package/dist/module/lib/Components/core/Banner/Banner.js +3 -3
- package/dist/module/lib/Components/core/Banner/Banner.js.map +1 -1
- package/dist/module/lib/Components/core/Banner/Banner.test.js +3 -3
- package/dist/module/lib/Components/core/Banner/Banner.test.js.map +1 -1
- package/dist/module/lib/Components/core/DotIcon/getDotIconProps.test.js +1 -4
- package/dist/module/lib/Components/core/DotIcon/getDotIconProps.test.js.map +1 -1
- package/dist/module/lib/Components/core/DotIcon/index.js +0 -10
- package/dist/module/lib/Components/core/DotIcon/index.js.map +1 -1
- package/dist/module/lib/Components/core/DotSymbol/getDotSymbolProps.test.js +1 -4
- package/dist/module/lib/Components/core/DotSymbol/getDotSymbolProps.test.js.map +1 -1
- package/dist/module/lib/Components/core/DotSymbol/index.js +0 -15
- package/dist/module/lib/Components/core/DotSymbol/index.js.map +1 -1
- package/dist/module/lib/Components/core/MediaButton/MediaButton.js +2 -2
- package/dist/module/lib/Components/core/MediaButton/MediaButton.mdx +2 -2
- package/dist/module/lib/Components/core/MenuList/MenuList.figma.js +21 -0
- package/dist/module/lib/Components/core/MenuList/MenuList.figma.js.map +1 -0
- package/dist/module/lib/Components/core/MenuList/MenuList.js +143 -0
- package/dist/module/lib/Components/core/MenuList/MenuList.js.map +1 -0
- package/dist/module/lib/Components/core/MenuList/MenuList.mdx +66 -0
- package/dist/module/lib/Components/core/MenuList/MenuList.stories.js +139 -0
- package/dist/module/lib/Components/core/MenuList/MenuList.stories.js.map +1 -0
- package/dist/module/lib/Components/core/MenuList/MenuList.test.js +146 -0
- package/dist/module/lib/Components/core/MenuList/MenuList.test.js.map +1 -0
- package/dist/module/lib/Components/core/MenuList/index.js +5 -0
- package/dist/module/lib/Components/core/MenuList/index.js.map +1 -0
- package/dist/module/lib/Components/core/MenuList/types.js.map +1 -0
- package/dist/module/lib/Components/core/SelectList/SelectList.figma.js +28 -0
- package/dist/module/lib/Components/core/{OptionList/OptionList.figma.js.map → SelectList/SelectList.figma.js.map} +1 -1
- package/dist/module/lib/Components/core/{OptionList/OptionList.js → SelectList/SelectList.js} +46 -46
- package/dist/module/lib/Components/core/{OptionList/OptionList.js.map → SelectList/SelectList.js.map} +1 -1
- package/dist/module/lib/Components/core/{OptionList/OptionList.mdx → SelectList/SelectList.mdx} +81 -81
- package/dist/module/lib/Components/core/{OptionList/OptionList.stories.js → SelectList/SelectList.stories.js} +130 -130
- package/dist/module/lib/Components/core/{OptionList/OptionList.stories.js.map → SelectList/SelectList.stories.js.map} +1 -1
- package/dist/module/lib/Components/core/{OptionList/OptionList.test.js → SelectList/SelectList.test.js} +83 -83
- package/dist/module/lib/Components/core/{OptionList/OptionList.test.js.map → SelectList/SelectList.test.js.map} +1 -1
- package/dist/module/lib/Components/core/SelectList/index.js +5 -0
- package/dist/module/lib/Components/core/{OptionList → SelectList}/index.js.map +1 -1
- package/dist/module/lib/Components/core/SelectList/types.js +4 -0
- package/dist/module/lib/Components/core/{OptionList → SelectList}/types.js.map +1 -1
- package/dist/module/lib/Components/core/{OptionList/useOptionList/useOptionListItems.js → SelectList/useSelectList/useSelectListItems.js} +2 -2
- package/dist/module/lib/Components/core/{OptionList/useOptionList/useOptionListItems.js.map → SelectList/useSelectList/useSelectListItems.js.map} +1 -1
- package/dist/module/lib/Components/core/{OptionList/useOptionList/useOptionListItems.test.js → SelectList/useSelectList/useSelectListItems.test.js} +17 -17
- package/dist/module/lib/Components/core/{OptionList/useOptionList/useOptionListItems.test.js.map → SelectList/useSelectList/useSelectListItems.test.js.map} +1 -1
- package/dist/module/lib/Components/core/index.js +2 -1
- package/dist/module/lib/Components/core/index.js.map +1 -1
- package/dist/module/lib/Components/internal/BaseButton/BaseButton.js +2 -2
- package/dist/module/lib/Components/internal/BaseButton/BaseButton.js.map +1 -1
- package/dist/module/lib/Components/internal/BaseTag/BaseTag.js +3 -3
- package/dist/module/lib/Components/internal/BaseTag/BaseTag.js.map +1 -1
- package/dist/module/lib/Components/internal/BaseTag/BaseTag.test.js +1 -1
- package/dist/module/lib/Components/internal/BaseTag/BaseTag.test.js.map +1 -1
- package/dist/module/lib/Components/symbols/Icon/Icon.test.js +1 -1
- package/dist/module/lib/Components/symbols/icons/CloudSync.js +50 -0
- package/dist/module/lib/Components/symbols/icons/CloudSync.js.map +1 -0
- package/dist/module/lib/Components/symbols/icons/Dollar.js +11 -5
- package/dist/module/lib/Components/symbols/icons/Dollar.js.map +1 -1
- package/dist/module/lib/Components/symbols/icons/DollarConvert.js +1 -1
- package/dist/module/lib/Components/symbols/icons/DollarConvert.js.map +1 -1
- package/dist/module/lib/Components/symbols/icons/DollarFill.js +47 -0
- package/dist/module/lib/Components/symbols/icons/DollarFill.js.map +1 -0
- package/dist/module/lib/Components/symbols/icons/FaceId.js +50 -0
- package/dist/module/lib/Components/symbols/icons/FaceId.js.map +1 -0
- package/dist/module/lib/Components/symbols/icons/Fingerprint.js +50 -0
- package/dist/module/lib/Components/symbols/icons/Fingerprint.js.map +1 -0
- package/dist/module/lib/Components/symbols/icons/Pause.js +2 -1
- package/dist/module/lib/Components/symbols/icons/Pause.js.map +1 -1
- package/dist/module/lib/Components/symbols/icons/Range.js +2 -5
- package/dist/module/lib/Components/symbols/icons/Range.js.map +1 -1
- package/dist/module/lib/Components/symbols/icons/Telegram.js +20 -9
- package/dist/module/lib/Components/symbols/icons/Telegram.js.map +1 -1
- package/dist/module/lib/Components/symbols/icons/Usb.js +1 -1
- package/dist/module/lib/Components/symbols/index.js +4 -0
- package/dist/module/lib/Components/symbols/index.js.map +1 -1
- package/dist/typescript/src/lib/Components/core/Avatar/Avatar.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Avatar/index.d.ts +1 -1
- package/dist/typescript/src/lib/Components/core/Avatar/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Avatar/types.d.ts +1 -1
- package/dist/typescript/src/lib/Components/core/Avatar/useResolveAvatarColor.d.ts +10 -0
- package/dist/typescript/src/lib/Components/core/Avatar/useResolveAvatarColor.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/DotIcon/index.d.ts +0 -7
- package/dist/typescript/src/lib/Components/core/DotIcon/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/DotSymbol/index.d.ts +0 -12
- package/dist/typescript/src/lib/Components/core/DotSymbol/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/MediaButton/MediaButton.d.ts +2 -2
- package/dist/typescript/src/lib/Components/core/MenuList/MenuList.d.ts +29 -0
- package/dist/typescript/src/lib/Components/core/MenuList/MenuList.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/MenuList/index.d.ts +3 -0
- package/dist/typescript/src/lib/Components/core/MenuList/index.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/MenuList/types.d.ts +42 -0
- package/dist/typescript/src/lib/Components/core/MenuList/types.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/SelectList/SelectList.d.ts +27 -0
- package/dist/typescript/src/lib/Components/core/{OptionList/OptionList.d.ts.map → SelectList/SelectList.d.ts.map} +1 -1
- package/dist/typescript/src/lib/Components/core/SelectList/index.d.ts +3 -0
- package/dist/typescript/src/lib/Components/core/{OptionList → SelectList}/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/{OptionList → SelectList}/types.d.ts +24 -24
- package/dist/typescript/src/lib/Components/core/{OptionList → SelectList}/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/SelectList/useSelectList/useSelectListItems.d.ts +20 -0
- package/dist/typescript/src/lib/Components/core/{OptionList/useOptionList/useOptionListItems.d.ts.map → SelectList/useSelectList/useSelectListItems.d.ts.map} +1 -1
- package/dist/typescript/src/lib/Components/core/index.d.ts +2 -1
- package/dist/typescript/src/lib/Components/core/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/symbols/icons/CloudSync.d.ts +35 -0
- package/dist/typescript/src/lib/Components/symbols/icons/CloudSync.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/symbols/icons/Dollar.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/symbols/icons/DollarFill.d.ts +35 -0
- package/dist/typescript/src/lib/Components/symbols/icons/DollarFill.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/symbols/icons/FaceId.d.ts +35 -0
- package/dist/typescript/src/lib/Components/symbols/icons/FaceId.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/symbols/icons/Fingerprint.d.ts +35 -0
- package/dist/typescript/src/lib/Components/symbols/icons/Fingerprint.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/symbols/icons/Pause.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/symbols/icons/Range.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/symbols/icons/Telegram.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/symbols/index.d.ts +4 -0
- package/dist/typescript/src/lib/Components/symbols/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/lib/Components/core/Avatar/Avatar.mdx +10 -6
- package/src/lib/Components/core/Avatar/Avatar.stories.tsx +16 -9
- package/src/lib/Components/core/Avatar/Avatar.test.tsx +64 -0
- package/src/lib/Components/core/Avatar/Avatar.tsx +41 -8
- package/src/lib/Components/core/Avatar/index.ts +1 -1
- package/src/lib/Components/core/Avatar/types.ts +1 -1
- package/src/lib/Components/core/Avatar/useResolveAvatarColor.test.tsx +106 -0
- package/src/lib/Components/core/Avatar/useResolveAvatarColor.ts +25 -0
- package/src/lib/Components/core/Banner/Banner.test.tsx +3 -3
- package/src/lib/Components/core/Banner/Banner.tsx +3 -3
- package/src/lib/Components/core/DotIcon/getDotIconProps.test.ts +1 -5
- package/src/lib/Components/core/DotIcon/index.ts +0 -10
- package/src/lib/Components/core/DotSymbol/getDotSymbolProps.test.ts +1 -5
- package/src/lib/Components/core/DotSymbol/index.ts +0 -15
- package/src/lib/Components/core/MediaButton/MediaButton.mdx +2 -2
- package/src/lib/Components/core/MediaButton/MediaButton.tsx +2 -2
- package/src/lib/Components/core/MenuList/MenuList.figma.tsx +23 -0
- package/src/lib/Components/core/MenuList/MenuList.mdx +66 -0
- package/src/lib/Components/core/MenuList/MenuList.stories.tsx +114 -0
- package/src/lib/Components/core/MenuList/MenuList.test.tsx +135 -0
- package/src/lib/Components/core/MenuList/MenuList.tsx +162 -0
- package/src/lib/Components/core/MenuList/index.ts +2 -0
- package/src/lib/Components/core/MenuList/types.ts +49 -0
- package/src/lib/Components/core/SelectList/SelectList.figma.tsx +37 -0
- package/src/lib/Components/core/{OptionList/OptionList.mdx → SelectList/SelectList.mdx} +81 -81
- package/src/lib/Components/core/{OptionList/OptionList.stories.tsx → SelectList/SelectList.stories.tsx} +227 -227
- package/src/lib/Components/core/{OptionList/OptionList.test.tsx → SelectList/SelectList.test.tsx} +138 -138
- package/src/lib/Components/core/{OptionList/OptionList.tsx → SelectList/SelectList.tsx} +92 -92
- package/src/lib/Components/core/SelectList/index.ts +2 -0
- package/src/lib/Components/core/{OptionList → SelectList}/types.ts +28 -28
- package/src/lib/Components/core/{OptionList/useOptionList/useOptionListItems.test.ts → SelectList/useSelectList/useSelectListItems.test.ts} +24 -24
- package/src/lib/Components/core/{OptionList/useOptionList/useOptionListItems.ts → SelectList/useSelectList/useSelectListItems.ts} +21 -21
- package/src/lib/Components/core/Spot/Spot.tsx +1 -1
- package/src/lib/Components/core/index.ts +2 -1
- package/src/lib/Components/internal/BaseButton/BaseButton.tsx +2 -2
- package/src/lib/Components/internal/BaseTag/BaseTag.test.tsx +3 -3
- package/src/lib/Components/internal/BaseTag/BaseTag.tsx +3 -3
- package/src/lib/Components/symbols/Icon/Icon.test.tsx +1 -1
- package/src/lib/Components/symbols/icons/CloudSync.tsx +45 -0
- package/src/lib/Components/symbols/icons/Dollar.tsx +8 -1
- package/src/lib/Components/symbols/icons/DollarConvert.tsx +1 -1
- package/src/lib/Components/symbols/icons/DollarFill.tsx +42 -0
- package/src/lib/Components/symbols/icons/FaceId.tsx +45 -0
- package/src/lib/Components/symbols/icons/Fingerprint.tsx +45 -0
- package/src/lib/Components/symbols/icons/Pause.tsx +2 -1
- package/src/lib/Components/symbols/icons/Range.tsx +2 -5
- package/src/lib/Components/symbols/icons/Telegram.tsx +14 -7
- package/src/lib/Components/symbols/icons/Usb.tsx +1 -1
- package/src/lib/Components/symbols/index.ts +4 -0
- package/dist/module/lib/Components/core/Avatar/resolveAvatarColor.js +0 -18
- package/dist/module/lib/Components/core/Avatar/resolveAvatarColor.js.map +0 -1
- package/dist/module/lib/Components/core/OptionList/OptionList.figma.js +0 -28
- package/dist/module/lib/Components/core/OptionList/index.js +0 -5
- package/dist/typescript/src/lib/Components/core/Avatar/resolveAvatarColor.d.ts +0 -8
- package/dist/typescript/src/lib/Components/core/Avatar/resolveAvatarColor.d.ts.map +0 -1
- package/dist/typescript/src/lib/Components/core/OptionList/OptionList.d.ts +0 -27
- package/dist/typescript/src/lib/Components/core/OptionList/index.d.ts +0 -3
- package/dist/typescript/src/lib/Components/core/OptionList/useOptionList/useOptionListItems.d.ts +0 -20
- package/src/lib/Components/core/Avatar/resolveAvatarColor.ts +0 -19
- package/src/lib/Components/core/OptionList/OptionList.figma.tsx +0 -37
- package/src/lib/Components/core/OptionList/index.ts +0 -2
- /package/dist/module/lib/Components/core/{OptionList → MenuList}/types.js +0 -0
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { AVATAR_COLOR_KEYS } from '@ledgerhq/lumen-utils-shared';
|
|
2
2
|
import type { Meta, StoryObj } from '@storybook/react-native-web-vite';
|
|
3
|
+
import type { ComponentProps } from 'react';
|
|
3
4
|
|
|
4
5
|
import { Box } from '../../primitives';
|
|
5
6
|
import { DotIndicator, getDotIndicatorProps } from '../DotIndicator';
|
|
6
7
|
import { Avatar } from './Avatar';
|
|
7
|
-
import {
|
|
8
|
+
import { useResolveAvatarColor } from '.';
|
|
9
|
+
|
|
10
|
+
const FallbackAvatar = ({
|
|
11
|
+
identifier,
|
|
12
|
+
...props
|
|
13
|
+
}: { identifier: string } & Omit<
|
|
14
|
+
ComponentProps<typeof Avatar>,
|
|
15
|
+
'fallbackColor'
|
|
16
|
+
>) => <Avatar {...props} fallbackColor={useResolveAvatarColor(identifier)} />;
|
|
8
17
|
|
|
9
18
|
const meta = {
|
|
10
19
|
component: Avatar,
|
|
@@ -75,7 +84,9 @@ export const FallbackShowcase: Story = {
|
|
|
75
84
|
parameters: {
|
|
76
85
|
docs: {
|
|
77
86
|
source: {
|
|
78
|
-
code:
|
|
87
|
+
code: `function UserAvatar({ user }) {
|
|
88
|
+
return <Avatar fallbackColor={useResolveAvatarColor(user.id)} alt={user.name} />;
|
|
89
|
+
}`,
|
|
79
90
|
},
|
|
80
91
|
},
|
|
81
92
|
},
|
|
@@ -83,9 +94,9 @@ export const FallbackShowcase: Story = {
|
|
|
83
94
|
<Box lx={{ gap: 's16' }}>
|
|
84
95
|
<Box lx={{ flexDirection: 'row', flexWrap: 'wrap', gap: 's16' }}>
|
|
85
96
|
{AVATAR_COLOR_KEYS.map((_, i) => (
|
|
86
|
-
<
|
|
97
|
+
<FallbackAvatar
|
|
87
98
|
key={i}
|
|
88
|
-
|
|
99
|
+
identifier={`user-${i}`}
|
|
89
100
|
fallbackText={getInitials(i)}
|
|
90
101
|
alt={getInitials(i)}
|
|
91
102
|
/>
|
|
@@ -94,11 +105,7 @@ export const FallbackShowcase: Story = {
|
|
|
94
105
|
</Box>
|
|
95
106
|
<Box lx={{ flexDirection: 'row', flexWrap: 'wrap', gap: 's16' }}>
|
|
96
107
|
{AVATAR_COLOR_KEYS.map((_, i) => (
|
|
97
|
-
<
|
|
98
|
-
key={i}
|
|
99
|
-
fallbackColor={resolveAvatarColor(`user-${i}`)}
|
|
100
|
-
alt={`User ${i}`}
|
|
101
|
-
/>
|
|
108
|
+
<FallbackAvatar key={i} identifier={`user-${i}`} alt={`User ${i}`} />
|
|
102
109
|
))}
|
|
103
110
|
<Avatar />
|
|
104
111
|
</Box>
|
|
@@ -124,6 +124,70 @@ describe('Avatar Component', () => {
|
|
|
124
124
|
);
|
|
125
125
|
});
|
|
126
126
|
|
|
127
|
+
it('should pair a decorative fallback background with its matching decorative text color', () => {
|
|
128
|
+
const { getByText } = render(
|
|
129
|
+
<TestWrapper>
|
|
130
|
+
<Avatar fallbackText='AB' fallbackColor={colors.bg.decorativeOrange} />
|
|
131
|
+
</TestWrapper>,
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
expect(getByText('AB').props.style.color).toBe(
|
|
135
|
+
colors.text.decorativeStrongOrange,
|
|
136
|
+
);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('should pair a decorative fallback background with its matching decorative icon color', () => {
|
|
140
|
+
const { getByTestId } = render(
|
|
141
|
+
<TestWrapper>
|
|
142
|
+
<Avatar fallbackColor={colors.bg.decorativeOrange} />
|
|
143
|
+
</TestWrapper>,
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
expect(getByTestId('avatar-fallback-icon').props.color).toBe(
|
|
147
|
+
colors.text.decorativeStrongOrange,
|
|
148
|
+
);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('should use black text/icon for an unknown custom fallbackColor', () => {
|
|
152
|
+
const { getByText, getByTestId, rerender } = render(
|
|
153
|
+
<TestWrapper>
|
|
154
|
+
<Avatar fallbackText='AB' fallbackColor='#aed09c' />
|
|
155
|
+
</TestWrapper>,
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
expect(getByText('AB').props.style.color).toBe(colors.text.black);
|
|
159
|
+
|
|
160
|
+
rerender(
|
|
161
|
+
<TestWrapper>
|
|
162
|
+
<Avatar fallbackColor='#aed09c' />
|
|
163
|
+
</TestWrapper>,
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
expect(getByTestId('avatar-fallback-icon').props.color).toBe(
|
|
167
|
+
colors.text.black,
|
|
168
|
+
);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('should use the base text/icon color when no fallbackColor is set', () => {
|
|
172
|
+
const { getByText, getByTestId, rerender } = render(
|
|
173
|
+
<TestWrapper>
|
|
174
|
+
<Avatar fallbackText='AB' />
|
|
175
|
+
</TestWrapper>,
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
expect(getByText('AB').props.style.color).toBe(colors.text.base);
|
|
179
|
+
|
|
180
|
+
rerender(
|
|
181
|
+
<TestWrapper>
|
|
182
|
+
<Avatar />
|
|
183
|
+
</TestWrapper>,
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
expect(getByTestId('avatar-fallback-icon').props.color).toBe(
|
|
187
|
+
colors.text.base,
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
|
|
127
191
|
it('should not apply the fallback color when an image is shown', () => {
|
|
128
192
|
const { getByTestId } = render(
|
|
129
193
|
<TestWrapper>
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import type { TypographyDefinition } from '@ledgerhq/lumen-design-core';
|
|
2
|
+
import { AVATAR_COLOR_KEYS, capitalize } from '@ledgerhq/lumen-utils-shared';
|
|
2
3
|
import { useEffect, useState } from 'react';
|
|
3
4
|
import { Image, StyleSheet, Text, View } from 'react-native';
|
|
4
5
|
import { useCommonTranslation } from '../../../../i18n';
|
|
5
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
useStyleSheet,
|
|
8
|
+
useTheme,
|
|
9
|
+
type LumenStyleSheetTheme,
|
|
10
|
+
} from '../../../../styles';
|
|
6
11
|
import { Box } from '../../primitives';
|
|
7
12
|
import { User } from '../../symbols';
|
|
8
|
-
import type { IconSize } from '../../symbols/Icon';
|
|
13
|
+
import type { IconSize, IconProps } from '../../symbols/Icon';
|
|
9
14
|
import type { AvatarProps } from './types';
|
|
10
15
|
|
|
11
16
|
type Size = NonNullable<AvatarProps['size']>;
|
|
@@ -19,14 +24,28 @@ const fallbackIconSizes: Record<Size, IconSize> = {
|
|
|
19
24
|
'2xl': 56,
|
|
20
25
|
};
|
|
21
26
|
|
|
27
|
+
const DECORATIVE_KEYS = AVATAR_COLOR_KEYS.map(capitalize);
|
|
28
|
+
|
|
29
|
+
const findDecorativeKey = (
|
|
30
|
+
colors: LumenStyleSheetTheme['colors'],
|
|
31
|
+
fallbackColor: string | undefined,
|
|
32
|
+
): (typeof DECORATIVE_KEYS)[number] | undefined =>
|
|
33
|
+
fallbackColor
|
|
34
|
+
? DECORATIVE_KEYS.find(
|
|
35
|
+
(key) => colors.bg[`decorative${key}`] === fallbackColor,
|
|
36
|
+
)
|
|
37
|
+
: undefined;
|
|
38
|
+
|
|
22
39
|
const useStyles = ({
|
|
23
40
|
size,
|
|
24
41
|
fallbackColor,
|
|
42
|
+
decorativeKey,
|
|
25
43
|
shouldFallback,
|
|
26
44
|
appearance,
|
|
27
45
|
}: {
|
|
28
46
|
size: Size;
|
|
29
47
|
fallbackColor?: string;
|
|
48
|
+
decorativeKey: (typeof DECORATIVE_KEYS)[number] | undefined;
|
|
30
49
|
shouldFallback: boolean;
|
|
31
50
|
appearance?: 'thin' | 'thick';
|
|
32
51
|
}) => {
|
|
@@ -50,6 +69,12 @@ const useStyles = ({
|
|
|
50
69
|
'2xl': t.typographies.heading1SemiBold,
|
|
51
70
|
};
|
|
52
71
|
|
|
72
|
+
const fallbackTextColor = decorativeKey
|
|
73
|
+
? t.colors.text[`decorativeStrong${decorativeKey}`]
|
|
74
|
+
: fallbackColor
|
|
75
|
+
? t.colors.text.black
|
|
76
|
+
: t.colors.text.base;
|
|
77
|
+
|
|
53
78
|
return {
|
|
54
79
|
root: {
|
|
55
80
|
position: 'relative',
|
|
@@ -66,7 +91,7 @@ const useStyles = ({
|
|
|
66
91
|
},
|
|
67
92
|
fallbackText: {
|
|
68
93
|
...fallbackTextTypography[size],
|
|
69
|
-
color:
|
|
94
|
+
color: fallbackTextColor,
|
|
70
95
|
},
|
|
71
96
|
image: {
|
|
72
97
|
position: 'absolute',
|
|
@@ -93,19 +118,19 @@ const useStyles = ({
|
|
|
93
118
|
},
|
|
94
119
|
};
|
|
95
120
|
},
|
|
96
|
-
[size, fallbackColor, shouldFallback, appearance],
|
|
121
|
+
[size, fallbackColor, decorativeKey, shouldFallback, appearance],
|
|
97
122
|
);
|
|
98
123
|
};
|
|
99
124
|
|
|
100
125
|
const FallbackContent = ({
|
|
101
126
|
size,
|
|
102
127
|
fallbackText,
|
|
103
|
-
|
|
128
|
+
fallbackIconColor,
|
|
104
129
|
styles,
|
|
105
130
|
}: {
|
|
106
131
|
size: Size;
|
|
107
132
|
fallbackText?: string;
|
|
108
|
-
|
|
133
|
+
fallbackIconColor: IconProps['color'];
|
|
109
134
|
styles: ReturnType<typeof useStyles>;
|
|
110
135
|
}) =>
|
|
111
136
|
fallbackText ? (
|
|
@@ -115,7 +140,7 @@ const FallbackContent = ({
|
|
|
115
140
|
) : (
|
|
116
141
|
<User
|
|
117
142
|
size={fallbackIconSizes[size]}
|
|
118
|
-
color={
|
|
143
|
+
color={fallbackIconColor}
|
|
119
144
|
accessible={false}
|
|
120
145
|
testID='avatar-fallback-icon'
|
|
121
146
|
/>
|
|
@@ -147,11 +172,19 @@ export const Avatar = ({
|
|
|
147
172
|
...props
|
|
148
173
|
}: AvatarProps) => {
|
|
149
174
|
const { t } = useCommonTranslation();
|
|
175
|
+
const { theme } = useTheme();
|
|
150
176
|
const [error, setError] = useState<boolean>(false);
|
|
151
177
|
const shouldFallback = !src || error;
|
|
178
|
+
const decorativeKey = findDecorativeKey(theme.colors, fallbackColor);
|
|
179
|
+
const fallbackIconColor: IconProps['color'] = decorativeKey
|
|
180
|
+
? `decorativeStrong${decorativeKey}`
|
|
181
|
+
: fallbackColor
|
|
182
|
+
? 'black'
|
|
183
|
+
: 'base';
|
|
152
184
|
const styles = useStyles({
|
|
153
185
|
size,
|
|
154
186
|
fallbackColor,
|
|
187
|
+
decorativeKey,
|
|
155
188
|
shouldFallback,
|
|
156
189
|
appearance,
|
|
157
190
|
});
|
|
@@ -175,7 +208,7 @@ export const Avatar = ({
|
|
|
175
208
|
<FallbackContent
|
|
176
209
|
size={size}
|
|
177
210
|
fallbackText={fallbackText}
|
|
178
|
-
|
|
211
|
+
fallbackIconColor={fallbackIconColor}
|
|
179
212
|
styles={styles}
|
|
180
213
|
/>
|
|
181
214
|
) : (
|
|
@@ -21,7 +21,7 @@ export type AvatarProps = {
|
|
|
21
21
|
size?: AvatarSize;
|
|
22
22
|
/**
|
|
23
23
|
* Background color behind the fallback when no image is displayed.
|
|
24
|
-
* Use `
|
|
24
|
+
* Use `useResolveAvatarColor` from `@ledgerhq/lumen-ui-rnative` to derive
|
|
25
25
|
* a stable pastel color from an identifier such as a user id.
|
|
26
26
|
* @optional
|
|
27
27
|
*/
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { describe, it, expect } from '@jest/globals';
|
|
2
|
+
import { ledgerLiveThemes } from '@ledgerhq/lumen-design-core';
|
|
3
|
+
import {
|
|
4
|
+
capitalize,
|
|
5
|
+
resolveAvatarColorKey,
|
|
6
|
+
} from '@ledgerhq/lumen-utils-shared';
|
|
7
|
+
import { renderHook } from '@testing-library/react-native';
|
|
8
|
+
import { ThemeProvider } from '../ThemeProvider/ThemeProvider';
|
|
9
|
+
import { useResolveAvatarColor } from './useResolveAvatarColor';
|
|
10
|
+
|
|
11
|
+
const decorativeBgKeyFor = (identifier: string): string =>
|
|
12
|
+
`decorative${capitalize(resolveAvatarColorKey(identifier))}`;
|
|
13
|
+
|
|
14
|
+
const LightWrapper = ({ children }: { children: React.ReactNode }) => (
|
|
15
|
+
<ThemeProvider themes={ledgerLiveThemes} colorScheme='light' locale='en'>
|
|
16
|
+
{children}
|
|
17
|
+
</ThemeProvider>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const DarkWrapper = ({ children }: { children: React.ReactNode }) => (
|
|
21
|
+
<ThemeProvider themes={ledgerLiveThemes} colorScheme='dark' locale='en'>
|
|
22
|
+
{children}
|
|
23
|
+
</ThemeProvider>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
let currentColorScheme: 'light' | 'dark' = 'light';
|
|
27
|
+
|
|
28
|
+
const SwitchableThemeWrapper = ({
|
|
29
|
+
children,
|
|
30
|
+
}: {
|
|
31
|
+
children: React.ReactNode;
|
|
32
|
+
}) => (
|
|
33
|
+
<ThemeProvider
|
|
34
|
+
themes={ledgerLiveThemes}
|
|
35
|
+
colorScheme={currentColorScheme}
|
|
36
|
+
locale='en'
|
|
37
|
+
>
|
|
38
|
+
{children}
|
|
39
|
+
</ThemeProvider>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
describe('useResolveAvatarColor', () => {
|
|
43
|
+
it('should resolve the identifier to the light-theme decorative color', () => {
|
|
44
|
+
const key = decorativeBgKeyFor('user-1');
|
|
45
|
+
const { result } = renderHook(() => useResolveAvatarColor('user-1'), {
|
|
46
|
+
wrapper: LightWrapper,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
expect(result.current).toBe(
|
|
50
|
+
(ledgerLiveThemes.light.colors.bg as Record<string, string>)[key],
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should resolve the identifier to the dark-theme decorative color, distinct from light', () => {
|
|
55
|
+
const key = decorativeBgKeyFor('user-1');
|
|
56
|
+
const { result } = renderHook(() => useResolveAvatarColor('user-1'), {
|
|
57
|
+
wrapper: DarkWrapper,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const darkColor = (
|
|
61
|
+
ledgerLiveThemes.dark.colors.bg as Record<string, string>
|
|
62
|
+
)[key];
|
|
63
|
+
const lightColor = (
|
|
64
|
+
ledgerLiveThemes.light.colors.bg as Record<string, string>
|
|
65
|
+
)[key];
|
|
66
|
+
|
|
67
|
+
expect(result.current).toBe(darkColor);
|
|
68
|
+
expect(result.current).not.toBe(lightColor);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should react to the theme changing after the initial render', () => {
|
|
72
|
+
const key = decorativeBgKeyFor('user-1');
|
|
73
|
+
const lightColor = (
|
|
74
|
+
ledgerLiveThemes.light.colors.bg as Record<string, string>
|
|
75
|
+
)[key];
|
|
76
|
+
const darkColor = (
|
|
77
|
+
ledgerLiveThemes.dark.colors.bg as Record<string, string>
|
|
78
|
+
)[key];
|
|
79
|
+
|
|
80
|
+
currentColorScheme = 'light';
|
|
81
|
+
const { result, rerender } = renderHook(
|
|
82
|
+
() => useResolveAvatarColor('user-1'),
|
|
83
|
+
{ wrapper: SwitchableThemeWrapper },
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
expect(result.current).toBe(lightColor);
|
|
87
|
+
|
|
88
|
+
currentColorScheme = 'dark';
|
|
89
|
+
rerender({});
|
|
90
|
+
|
|
91
|
+
expect(result.current).toBe(darkColor);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('should always resolve the same identifier to the same color within a theme', () => {
|
|
95
|
+
const { result: first } = renderHook(
|
|
96
|
+
() => useResolveAvatarColor('same-user'),
|
|
97
|
+
{ wrapper: LightWrapper },
|
|
98
|
+
);
|
|
99
|
+
const { result: second } = renderHook(
|
|
100
|
+
() => useResolveAvatarColor('same-user'),
|
|
101
|
+
{ wrapper: LightWrapper },
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
expect(first.current).toBe(second.current);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
capitalize,
|
|
3
|
+
resolveAvatarColorKey,
|
|
4
|
+
type AvatarColorKey,
|
|
5
|
+
} from '@ledgerhq/lumen-utils-shared';
|
|
6
|
+
import { useTheme, type LumenStyleSheetTheme } from '../../../../styles';
|
|
7
|
+
|
|
8
|
+
type DecorativeBgKey = keyof LumenStyleSheetTheme['colors']['bg'];
|
|
9
|
+
|
|
10
|
+
const decorativeBgKey = (key: AvatarColorKey): DecorativeBgKey =>
|
|
11
|
+
`decorative${capitalize(key)}` as DecorativeBgKey;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Resolves a stable identifier (e.g. a user id) to one of the avatar pastel
|
|
15
|
+
* color keys, then to that key's value in the current theme. The same
|
|
16
|
+
* identifier always resolves to the same key, but its resolved color value
|
|
17
|
+
* follows the active theme.
|
|
18
|
+
*
|
|
19
|
+
* Pass the result directly to `<Avatar fallbackColor={useResolveAvatarColor(id)} />`.
|
|
20
|
+
*/
|
|
21
|
+
export function useResolveAvatarColor(identifier: string): string {
|
|
22
|
+
const { theme } = useTheme();
|
|
23
|
+
|
|
24
|
+
return theme.colors.bg[decorativeBgKey(resolveAvatarColorKey(identifier))];
|
|
25
|
+
}
|
|
@@ -44,7 +44,7 @@ describe('Banner Component', () => {
|
|
|
44
44
|
</TestWrapper>,
|
|
45
45
|
);
|
|
46
46
|
expect(getByTestId('banner-id').props.style.backgroundColor).toBe(
|
|
47
|
-
colors.bg.
|
|
47
|
+
colors.bg.successTransparent,
|
|
48
48
|
);
|
|
49
49
|
|
|
50
50
|
rerender(
|
|
@@ -57,7 +57,7 @@ describe('Banner Component', () => {
|
|
|
57
57
|
</TestWrapper>,
|
|
58
58
|
);
|
|
59
59
|
expect(getByTestId('banner-id').props.style.backgroundColor).toBe(
|
|
60
|
-
colors.bg.
|
|
60
|
+
colors.bg.warningTransparent,
|
|
61
61
|
);
|
|
62
62
|
|
|
63
63
|
rerender(
|
|
@@ -66,7 +66,7 @@ describe('Banner Component', () => {
|
|
|
66
66
|
</TestWrapper>,
|
|
67
67
|
);
|
|
68
68
|
expect(getByTestId('banner-id').props.style.backgroundColor).toBe(
|
|
69
|
-
colors.bg.
|
|
69
|
+
colors.bg.errorTransparent,
|
|
70
70
|
);
|
|
71
71
|
});
|
|
72
72
|
|
|
@@ -32,9 +32,9 @@ const useStyles = ({ appearance }: { appearance: Appearance }) => {
|
|
|
32
32
|
(t) => {
|
|
33
33
|
const bgColors: Record<Appearance, string> = {
|
|
34
34
|
info: t.colors.bg.surface,
|
|
35
|
-
success: t.colors.bg.
|
|
36
|
-
warning: t.colors.bg.
|
|
37
|
-
error: t.colors.bg.
|
|
35
|
+
success: t.colors.bg.successTransparent,
|
|
36
|
+
warning: t.colors.bg.warningTransparent,
|
|
37
|
+
error: t.colors.bg.errorTransparent,
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from '@jest/globals';
|
|
2
|
-
import { getDotIconProps
|
|
2
|
+
import { getDotIconProps } from './index';
|
|
3
3
|
|
|
4
4
|
describe('getDotIconProps', () => {
|
|
5
5
|
it('resolves mediaImage dot icon props', () => {
|
|
@@ -10,10 +10,6 @@ describe('getDotIconProps', () => {
|
|
|
10
10
|
expect(getDotIconProps('mediaImage', 72)).toEqual({ size: 32 });
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
it('exports mediaImageDotIconSizeMap shim', () => {
|
|
14
|
-
expect(mediaImageDotIconSizeMap[56]).toBe(24);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
13
|
it('resolves spot dot icon props', () => {
|
|
18
14
|
expect(getDotIconProps('spot', 40)).toEqual({ size: 16 });
|
|
19
15
|
expect(getDotIconProps('spot', 48)).toEqual({ size: 20 });
|
|
@@ -1,13 +1,3 @@
|
|
|
1
1
|
export { DotIcon } from './DotIcon';
|
|
2
2
|
export * from './getDotIconProps';
|
|
3
3
|
export * from './types';
|
|
4
|
-
|
|
5
|
-
// shim: @ledgerhq/crypto-icons imports this
|
|
6
|
-
// remove once the package drops the dependency
|
|
7
|
-
export const mediaImageDotIconSizeMap = {
|
|
8
|
-
40: 16,
|
|
9
|
-
48: 20,
|
|
10
|
-
56: 24,
|
|
11
|
-
64: 24,
|
|
12
|
-
72: 32,
|
|
13
|
-
} as const;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from '@jest/globals';
|
|
2
|
-
import { getDotSymbolProps
|
|
2
|
+
import { getDotSymbolProps } from './index';
|
|
3
3
|
|
|
4
4
|
describe('getDotSymbolProps', () => {
|
|
5
5
|
it('resolves mediaImage dot symbol props', () => {
|
|
@@ -15,10 +15,6 @@ describe('getDotSymbolProps', () => {
|
|
|
15
15
|
expect(getDotSymbolProps('mediaImage', 72)).toEqual({ size: 32 });
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
it('exports mediaImageDotSizeMap shim', () => {
|
|
19
|
-
expect(mediaImageDotSizeMap[48]).toBe(20);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
18
|
it('resolves spot dot symbol props', () => {
|
|
23
19
|
expect(getDotSymbolProps('spot', 32)).toEqual({ size: 12 });
|
|
24
20
|
expect(getDotSymbolProps('spot', 40)).toEqual({ size: 16 });
|
|
@@ -1,18 +1,3 @@
|
|
|
1
1
|
export { DotSymbol } from './DotSymbol';
|
|
2
2
|
export * from './getDotSymbolProps';
|
|
3
3
|
export * from './types';
|
|
4
|
-
|
|
5
|
-
// shim: @ledgerhq/crypto-icons imports this
|
|
6
|
-
// remove once the package drops the dependency
|
|
7
|
-
export const mediaImageDotSizeMap = {
|
|
8
|
-
12: 8,
|
|
9
|
-
16: 8,
|
|
10
|
-
20: 8,
|
|
11
|
-
24: 10,
|
|
12
|
-
32: 12,
|
|
13
|
-
40: 16,
|
|
14
|
-
48: 20,
|
|
15
|
-
56: 24,
|
|
16
|
-
64: 24,
|
|
17
|
-
72: 32,
|
|
18
|
-
} as const;
|
|
@@ -11,11 +11,11 @@ import * as MediaButtonStories from './MediaButton.stories';
|
|
|
11
11
|
|
|
12
12
|
## Introduction
|
|
13
13
|
|
|
14
|
-
A specialized media button designed exclusively for
|
|
14
|
+
A specialized media button designed exclusively for select list and dropdown patterns. It displays a label with an optional leading icon and a permanent trailing chevron indicator.
|
|
15
15
|
|
|
16
16
|
> View in [Figma](https://www.figma.com/design/JxaLVMTWirCpU0rsbZ30k7/2.-Components-Library?node-id=6389-45680&m=dev).
|
|
17
17
|
|
|
18
|
-
> **Important**: This component should only be used as a trigger inside
|
|
18
|
+
> **Important**: This component should only be used as a trigger inside a SelectList or dropdown. For standalone actions, use [Button](/docs/rnative-button--docs) or [IconButton](/docs/rnative-iconbutton--docs) instead.
|
|
19
19
|
|
|
20
20
|
## Properties
|
|
21
21
|
|
|
@@ -127,10 +127,10 @@ const useStyles = ({
|
|
|
127
127
|
};
|
|
128
128
|
|
|
129
129
|
/**
|
|
130
|
-
* Media button for
|
|
130
|
+
* Media button for select list/dropdown components. Displays a label with an optional
|
|
131
131
|
* leading content and a trailing chevron indicator.
|
|
132
132
|
*
|
|
133
|
-
* This component is intended to be used exclusively as the trigger inside
|
|
133
|
+
* This component is intended to be used exclusively as the trigger inside a SelectList or
|
|
134
134
|
* dropdown pattern. It should not be used as a standalone action button — use `Button`
|
|
135
135
|
* or `IconButton` instead.
|
|
136
136
|
*
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import figma from '@figma/code-connect';
|
|
2
|
+
import { MenuList, MenuListItem } from './MenuList';
|
|
3
|
+
|
|
4
|
+
figma.connect(
|
|
5
|
+
MenuListItem,
|
|
6
|
+
'https://www.figma.com/design/JxaLVMTWirCpU0rsbZ30k7?node-id=7897-7037',
|
|
7
|
+
{
|
|
8
|
+
imports: [
|
|
9
|
+
"import { MenuList, MenuListItem } from '@ledgerhq/lumen-ui-rnative'",
|
|
10
|
+
],
|
|
11
|
+
props: {
|
|
12
|
+
label: figma.string('title'),
|
|
13
|
+
disabled: figma.enum('state', {
|
|
14
|
+
disabled: true,
|
|
15
|
+
}),
|
|
16
|
+
},
|
|
17
|
+
example: (props) => (
|
|
18
|
+
<MenuList>
|
|
19
|
+
<MenuListItem label={props.label} disabled={props.disabled} />
|
|
20
|
+
</MenuList>
|
|
21
|
+
),
|
|
22
|
+
},
|
|
23
|
+
);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Meta, Canvas, Controls, Source } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as MenuListStories from './MenuList.stories';
|
|
3
|
+
import {
|
|
4
|
+
CustomTabs,
|
|
5
|
+
Tab,
|
|
6
|
+
SetupNote,
|
|
7
|
+
} from '../../../../../.storybook/components';
|
|
8
|
+
|
|
9
|
+
<Meta title='Core/MenuList' of={MenuListStories} />
|
|
10
|
+
|
|
11
|
+
# MenuList
|
|
12
|
+
|
|
13
|
+
<CustomTabs>
|
|
14
|
+
<Tab label='Overview'>
|
|
15
|
+
|
|
16
|
+
## Introduction
|
|
17
|
+
|
|
18
|
+
`MenuList` is a container for a set of tappable actions. Each `MenuListItem` displays a label, an optional leading icon, and supports `base` and `red` appearances.
|
|
19
|
+
|
|
20
|
+
> View in [Figma](https://www.figma.com/design/JxaLVMTWirCpU0rsbZ30k7/2.-Components-Library?node-id=7897-7037&m=dev).
|
|
21
|
+
|
|
22
|
+
## Anatomy
|
|
23
|
+
|
|
24
|
+
<Canvas of={MenuListStories.Base} />
|
|
25
|
+
<Controls of={MenuListStories.ItemShowcase} />
|
|
26
|
+
|
|
27
|
+
## Properties
|
|
28
|
+
|
|
29
|
+
### Appearance
|
|
30
|
+
|
|
31
|
+
`MenuListItem` supports two appearances: `base` (default) for standard actions and `red` for irreversible or dangerous operations such as deleting or unlinking. The red appearance renders the label and icon in the error colour.
|
|
32
|
+
|
|
33
|
+
Place `red` items **last** in the list. Both the Apple HIG and Material guidelines put destructive actions at the bottom, away from the items a user reaches for by habit. `MenuList` does not enforce the order.
|
|
34
|
+
|
|
35
|
+
<Canvas of={MenuListStories.AppearanceShowcase} />
|
|
36
|
+
|
|
37
|
+
### Disabled
|
|
38
|
+
|
|
39
|
+
Set `disabled` on individual `MenuListItem`s to prevent interaction. The label and icon are rendered in the disabled colour and the press handler is suppressed.
|
|
40
|
+
|
|
41
|
+
<Canvas of={MenuListStories.DisabledShowcase} />
|
|
42
|
+
|
|
43
|
+
## Accessibility
|
|
44
|
+
|
|
45
|
+
Each `MenuListItem` has `accessibilityRole='button'` and sets `accessibilityState={{ disabled }}` to reflect its interaction state to assistive technologies.
|
|
46
|
+
|
|
47
|
+
</Tab>
|
|
48
|
+
|
|
49
|
+
<Tab label='Implementation'>
|
|
50
|
+
|
|
51
|
+
<SetupNote />
|
|
52
|
+
|
|
53
|
+
### Basic Usage
|
|
54
|
+
|
|
55
|
+
<Source of={MenuListStories.Base} />
|
|
56
|
+
|
|
57
|
+
### Appearances
|
|
58
|
+
|
|
59
|
+
<Source of={MenuListStories.AppearanceShowcase} />
|
|
60
|
+
|
|
61
|
+
### Disabled Items
|
|
62
|
+
|
|
63
|
+
<Source of={MenuListStories.DisabledShowcase} />
|
|
64
|
+
|
|
65
|
+
</Tab>
|
|
66
|
+
</CustomTabs>
|