@ledgerhq/lumen-ui-rnative 0.1.49 → 0.1.51
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/BaseInput/BaseInput.js +84 -25
- package/dist/module/lib/Components/BaseInput/BaseInput.js.map +1 -1
- package/dist/module/lib/Components/Button/ButtonGroup.figma.js +19 -0
- package/dist/module/lib/Components/Button/ButtonGroup.figma.js.map +1 -0
- package/dist/module/lib/Components/DescriptionItem/DescriptionItem.js +31 -9
- package/dist/module/lib/Components/DescriptionItem/DescriptionItem.js.map +1 -1
- package/dist/module/lib/Components/DescriptionItem/DescriptionItem.mdx +10 -7
- package/dist/module/lib/Components/DescriptionItem/DescriptionItem.stories.js +29 -40
- package/dist/module/lib/Components/DescriptionItem/DescriptionItem.stories.js.map +1 -1
- package/dist/module/lib/Components/DescriptionItem/DescriptionItem.test.js +22 -0
- package/dist/module/lib/Components/DescriptionItem/DescriptionItem.test.js.map +1 -1
- package/dist/module/lib/Components/ListItem/ListItem.figma.js +11 -0
- package/dist/module/lib/Components/ListItem/ListItem.figma.js.map +1 -1
- package/dist/module/lib/Components/ListItem/ListItem.js +78 -20
- package/dist/module/lib/Components/ListItem/ListItem.js.map +1 -1
- package/dist/module/lib/Components/ListItem/ListItem.mdx +17 -0
- package/dist/module/lib/Components/ListItem/ListItem.stories.js +132 -0
- package/dist/module/lib/Components/ListItem/ListItem.stories.js.map +1 -1
- package/dist/module/lib/Components/ListItem/ListItem.test.js +80 -0
- package/dist/module/lib/Components/ListItem/ListItem.test.js.map +1 -1
- package/dist/module/lib/Components/SectionHeader/SectionHeader.figma.js +22 -0
- package/dist/module/lib/Components/SectionHeader/SectionHeader.figma.js.map +1 -0
- package/dist/module/lib/Components/SectionHeader/SectionHeader.js +99 -0
- package/dist/module/lib/Components/SectionHeader/SectionHeader.js.map +1 -0
- package/dist/module/lib/Components/SectionHeader/SectionHeader.mdx +79 -0
- package/dist/module/lib/Components/SectionHeader/SectionHeader.stories.js +104 -0
- package/dist/module/lib/Components/SectionHeader/SectionHeader.stories.js.map +1 -0
- package/dist/module/lib/Components/SectionHeader/SectionHeader.test.js +108 -0
- package/dist/module/lib/Components/SectionHeader/SectionHeader.test.js.map +1 -0
- package/dist/module/lib/Components/SectionHeader/index.js +5 -0
- package/dist/module/lib/Components/SectionHeader/index.js.map +1 -0
- package/dist/module/lib/Components/SectionHeader/types.js +4 -0
- package/dist/module/lib/Components/SectionHeader/types.js.map +1 -0
- package/dist/module/lib/Components/TextInput/TextInput.figma.js +5 -0
- package/dist/module/lib/Components/TextInput/TextInput.figma.js.map +1 -1
- package/dist/module/lib/Components/TextInput/TextInput.mdx +43 -73
- package/dist/module/lib/Components/TextInput/TextInput.stories.js +58 -1
- package/dist/module/lib/Components/TextInput/TextInput.stories.js.map +1 -1
- package/dist/module/lib/Components/TextInput/TextInput.test.js +45 -1
- package/dist/module/lib/Components/TextInput/TextInput.test.js.map +1 -1
- package/dist/module/lib/Components/TileButton/TileButton.figma.js +5 -0
- package/dist/module/lib/Components/TileButton/TileButton.figma.js.map +1 -1
- package/dist/module/lib/Components/TileButton/TileButton.js +39 -27
- package/dist/module/lib/Components/TileButton/TileButton.js.map +1 -1
- package/dist/module/lib/Components/TileButton/TileButton.mdx +10 -1
- package/dist/module/lib/Components/TileButton/TileButton.stories.js +33 -2
- package/dist/module/lib/Components/TileButton/TileButton.stories.js.map +1 -1
- package/dist/module/lib/Components/TileButton/TileButton.test.js +26 -0
- package/dist/module/lib/Components/TileButton/TileButton.test.js.map +1 -1
- package/dist/module/lib/Components/index.js +1 -0
- package/dist/module/lib/Components/index.js.map +1 -1
- package/dist/module/lib/Symbols/Icons/Atm.js +50 -0
- package/dist/module/lib/Symbols/Icons/Atm.js.map +1 -0
- package/dist/module/lib/Symbols/Icons/Cutlery.js +50 -0
- package/dist/module/lib/Symbols/Icons/Cutlery.js.map +1 -0
- package/dist/module/lib/Symbols/Icons/GameControler.js +50 -0
- package/dist/module/lib/Symbols/Icons/GameControler.js.map +1 -0
- package/dist/module/lib/Symbols/Icons/Upload.js +50 -0
- package/dist/module/lib/Symbols/Icons/Upload.js.map +1 -0
- package/dist/module/lib/Symbols/index.js +4 -0
- package/dist/module/lib/Symbols/index.js.map +1 -1
- package/dist/typescript/src/lib/Components/BaseInput/BaseInput.d.ts +1 -1
- package/dist/typescript/src/lib/Components/BaseInput/BaseInput.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/BaseInput/types.d.ts +16 -0
- package/dist/typescript/src/lib/Components/BaseInput/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/DescriptionItem/DescriptionItem.d.ts +1 -1
- package/dist/typescript/src/lib/Components/DescriptionItem/DescriptionItem.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/DescriptionItem/types.d.ts +6 -0
- package/dist/typescript/src/lib/Components/DescriptionItem/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/ListItem/ListItem.d.ts +1 -1
- package/dist/typescript/src/lib/Components/ListItem/ListItem.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/ListItem/types.d.ts +11 -1
- package/dist/typescript/src/lib/Components/ListItem/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/SectionHeader/SectionHeader.d.ts +20 -0
- package/dist/typescript/src/lib/Components/SectionHeader/SectionHeader.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/SectionHeader/index.d.ts +3 -0
- package/dist/typescript/src/lib/Components/SectionHeader/index.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/SectionHeader/types.d.ts +27 -0
- package/dist/typescript/src/lib/Components/SectionHeader/types.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/TileButton/TileButton.d.ts +1 -1
- package/dist/typescript/src/lib/Components/TileButton/TileButton.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/TileButton/types.d.ts +5 -0
- package/dist/typescript/src/lib/Components/TileButton/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/index.d.ts +1 -0
- package/dist/typescript/src/lib/Components/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Symbols/Icons/Atm.d.ts +35 -0
- package/dist/typescript/src/lib/Symbols/Icons/Atm.d.ts.map +1 -0
- package/dist/typescript/src/lib/Symbols/Icons/Cutlery.d.ts +35 -0
- package/dist/typescript/src/lib/Symbols/Icons/Cutlery.d.ts.map +1 -0
- package/dist/typescript/src/lib/Symbols/Icons/GameControler.d.ts +35 -0
- package/dist/typescript/src/lib/Symbols/Icons/GameControler.d.ts.map +1 -0
- package/dist/typescript/src/lib/Symbols/Icons/Upload.d.ts +35 -0
- package/dist/typescript/src/lib/Symbols/Icons/Upload.d.ts.map +1 -0
- package/dist/typescript/src/lib/Symbols/index.d.ts +4 -0
- package/dist/typescript/src/lib/Symbols/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/lib/Components/BaseInput/BaseInput.tsx +93 -22
- package/src/lib/Components/BaseInput/types.ts +18 -0
- package/src/lib/Components/Button/ButtonGroup.figma.tsx +15 -0
- package/src/lib/Components/DescriptionItem/DescriptionItem.mdx +10 -7
- package/src/lib/Components/DescriptionItem/DescriptionItem.stories.tsx +21 -41
- package/src/lib/Components/DescriptionItem/DescriptionItem.test.tsx +24 -0
- package/src/lib/Components/DescriptionItem/DescriptionItem.tsx +31 -8
- package/src/lib/Components/DescriptionItem/types.ts +6 -0
- package/src/lib/Components/ListItem/ListItem.figma.tsx +43 -8
- package/src/lib/Components/ListItem/ListItem.mdx +17 -0
- package/src/lib/Components/ListItem/ListItem.stories.tsx +92 -0
- package/src/lib/Components/ListItem/ListItem.test.tsx +78 -0
- package/src/lib/Components/ListItem/ListItem.tsx +64 -19
- package/src/lib/Components/ListItem/types.ts +11 -1
- package/src/lib/Components/SectionHeader/SectionHeader.figma.tsx +24 -0
- package/src/lib/Components/SectionHeader/SectionHeader.mdx +79 -0
- package/src/lib/Components/SectionHeader/SectionHeader.stories.tsx +95 -0
- package/src/lib/Components/SectionHeader/SectionHeader.test.tsx +103 -0
- package/src/lib/Components/SectionHeader/SectionHeader.tsx +125 -0
- package/src/lib/Components/SectionHeader/index.ts +6 -0
- package/src/lib/Components/SectionHeader/types.ts +30 -0
- package/src/lib/Components/TextInput/TextInput.figma.tsx +6 -1
- package/src/lib/Components/TextInput/TextInput.mdx +43 -73
- package/src/lib/Components/TextInput/TextInput.stories.tsx +57 -1
- package/src/lib/Components/TextInput/TextInput.test.tsx +60 -1
- package/src/lib/Components/TileButton/TileButton.figma.tsx +5 -0
- package/src/lib/Components/TileButton/TileButton.mdx +10 -1
- package/src/lib/Components/TileButton/TileButton.stories.tsx +28 -4
- package/src/lib/Components/TileButton/TileButton.test.tsx +35 -1
- package/src/lib/Components/TileButton/TileButton.tsx +47 -28
- package/src/lib/Components/TileButton/types.ts +5 -0
- package/src/lib/Components/index.ts +1 -0
- package/src/lib/Symbols/Icons/Atm.tsx +45 -0
- package/src/lib/Symbols/Icons/Cutlery.tsx +45 -0
- package/src/lib/Symbols/Icons/GameControler.tsx +45 -0
- package/src/lib/Symbols/Icons/Upload.tsx +45 -0
- package/src/lib/Symbols/index.ts +4 -0
|
@@ -109,6 +109,38 @@ describe('ListItem', () => {
|
|
|
109
109
|
});
|
|
110
110
|
});
|
|
111
111
|
|
|
112
|
+
describe('active', () => {
|
|
113
|
+
it('applies muted background when active', () => {
|
|
114
|
+
renderListItem({ active: true });
|
|
115
|
+
const inner = screen.getByTestId('list-item-content');
|
|
116
|
+
expect(inner.props.style.backgroundColor).not.toBe('transparent');
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('applies disabled background when active and disabled', () => {
|
|
120
|
+
renderListItem({ active: true, disabled: true });
|
|
121
|
+
const inner = screen.getByTestId('list-item-content');
|
|
122
|
+
expect(inner.props.style.backgroundColor).not.toBe('transparent');
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('uses transparent background when not active', () => {
|
|
126
|
+
renderListItem();
|
|
127
|
+
const inner = screen.getByTestId('list-item-content');
|
|
128
|
+
expect(inner.props.style.backgroundColor).toBe('transparent');
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('sets selected accessibility state when active', () => {
|
|
132
|
+
renderListItem({ active: true });
|
|
133
|
+
const item = screen.getByTestId('list-item');
|
|
134
|
+
expect(item.props.accessibilityState?.selected).toBe(true);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('does not set selected accessibility state when not active', () => {
|
|
138
|
+
renderListItem();
|
|
139
|
+
const item = screen.getByTestId('list-item');
|
|
140
|
+
expect(item.props.accessibilityState?.selected).toBeFalsy();
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
112
144
|
describe('disabled', () => {
|
|
113
145
|
it('sets disabled accessibility state', () => {
|
|
114
146
|
renderListItem({ disabled: true });
|
|
@@ -125,6 +157,52 @@ describe('ListItem', () => {
|
|
|
125
157
|
});
|
|
126
158
|
});
|
|
127
159
|
|
|
160
|
+
describe('priority', () => {
|
|
161
|
+
const renderWithPriority = (priority?: ListItemProps['priority']) =>
|
|
162
|
+
render(
|
|
163
|
+
<TestWrapper>
|
|
164
|
+
<ListItem priority={priority}>
|
|
165
|
+
<ListItemLeading testID='leading'>
|
|
166
|
+
<ListItemContent testID='content'>
|
|
167
|
+
<ListItemTitle>Title</ListItemTitle>
|
|
168
|
+
</ListItemContent>
|
|
169
|
+
</ListItemLeading>
|
|
170
|
+
<ListItemTrailing testID='trailing'>
|
|
171
|
+
<RNText>Trailing</RNText>
|
|
172
|
+
</ListItemTrailing>
|
|
173
|
+
</ListItem>
|
|
174
|
+
</TestWrapper>,
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
it('in "end" priority, leading shrinks, trailing shows', () => {
|
|
178
|
+
renderWithPriority();
|
|
179
|
+
|
|
180
|
+
expect(screen.getByTestId('leading').props.style).toEqual(
|
|
181
|
+
expect.objectContaining({ flexShrink: 1 }),
|
|
182
|
+
);
|
|
183
|
+
expect(screen.getByTestId('content').props.style).toEqual(
|
|
184
|
+
expect.objectContaining({ flex: 1 }),
|
|
185
|
+
);
|
|
186
|
+
expect(screen.getByTestId('trailing').props.style).not.toEqual(
|
|
187
|
+
expect.objectContaining({ flexShrink: 1 }),
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('in "start" priority, trailing shrinks, leading shows', () => {
|
|
192
|
+
renderWithPriority('start');
|
|
193
|
+
|
|
194
|
+
expect(screen.getByTestId('leading').props.style).not.toEqual(
|
|
195
|
+
expect.objectContaining({ flexShrink: 1 }),
|
|
196
|
+
);
|
|
197
|
+
expect(screen.getByTestId('content').props.style).toEqual(
|
|
198
|
+
expect.objectContaining({ flex: 0, flexShrink: 1 }),
|
|
199
|
+
);
|
|
200
|
+
expect(screen.getByTestId('trailing').props.style).toEqual(
|
|
201
|
+
expect.objectContaining({ flexShrink: 1 }),
|
|
202
|
+
);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
128
206
|
describe('ListItemContentRow', () => {
|
|
129
207
|
it('renders title alongside additional content in a row', () => {
|
|
130
208
|
render(
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
createSafeContext,
|
|
3
3
|
type Density,
|
|
4
4
|
DisabledProvider,
|
|
5
|
+
type Priority,
|
|
5
6
|
useDisabledContext,
|
|
6
7
|
} from '@ledgerhq/lumen-utils-shared';
|
|
7
8
|
import type { ComponentRef, ReactNode, Ref } from 'react';
|
|
@@ -24,12 +25,21 @@ const [ListItemTrailingProvider, useListItemTrailingContext] =
|
|
|
24
25
|
isInTrailing: false,
|
|
25
26
|
});
|
|
26
27
|
|
|
28
|
+
const [ListItemPriorityProvider, useListItemPriorityContext] =
|
|
29
|
+
createSafeContext<{ priority?: Priority }>('ListItemPriority', {
|
|
30
|
+
priority: undefined,
|
|
31
|
+
});
|
|
32
|
+
|
|
27
33
|
const useRootStyles = ({
|
|
28
34
|
pressed,
|
|
29
35
|
density,
|
|
36
|
+
active,
|
|
37
|
+
disabled,
|
|
30
38
|
}: {
|
|
31
39
|
pressed: boolean;
|
|
32
40
|
density: Density;
|
|
41
|
+
active: boolean;
|
|
42
|
+
disabled: boolean;
|
|
33
43
|
}) => {
|
|
34
44
|
return useStyleSheet(
|
|
35
45
|
(t) => ({
|
|
@@ -43,13 +53,15 @@ const useRootStyles = ({
|
|
|
43
53
|
borderRadius: t.borderRadius.md,
|
|
44
54
|
backgroundColor: 'transparent',
|
|
45
55
|
paddingHorizontal: t.spacings.s8,
|
|
56
|
+
overflow: 'hidden',
|
|
46
57
|
},
|
|
47
|
-
pressed && {
|
|
48
|
-
|
|
49
|
-
},
|
|
58
|
+
pressed && { backgroundColor: t.colors.bg.baseTransparentPressed },
|
|
59
|
+
active && { backgroundColor: t.colors.bg.muted },
|
|
60
|
+
active && pressed && { backgroundColor: t.colors.bg.mutedPressed },
|
|
61
|
+
active && disabled && { backgroundColor: t.colors.bg.disabled },
|
|
50
62
|
]),
|
|
51
63
|
}),
|
|
52
|
-
[pressed, density],
|
|
64
|
+
[pressed, density, active, disabled],
|
|
53
65
|
);
|
|
54
66
|
};
|
|
55
67
|
|
|
@@ -93,6 +105,8 @@ export const ListItem = ({
|
|
|
93
105
|
style,
|
|
94
106
|
disabled: disabledProp = false,
|
|
95
107
|
density = 'expanded',
|
|
108
|
+
priority = 'end',
|
|
109
|
+
active = false,
|
|
96
110
|
onPress,
|
|
97
111
|
onLongPress,
|
|
98
112
|
ref,
|
|
@@ -116,13 +130,19 @@ export const ListItem = ({
|
|
|
116
130
|
onPress={onPress}
|
|
117
131
|
onLongPress={onLongPress}
|
|
118
132
|
accessibilityRole='button'
|
|
119
|
-
accessibilityState={{ disabled }}
|
|
133
|
+
accessibilityState={{ disabled, selected: active }}
|
|
120
134
|
{...props}
|
|
121
135
|
>
|
|
122
136
|
{({ pressed }) => (
|
|
123
|
-
<
|
|
124
|
-
|
|
125
|
-
|
|
137
|
+
<ListItemPriorityProvider value={{ priority }}>
|
|
138
|
+
<ListItemInner
|
|
139
|
+
pressed={pressed}
|
|
140
|
+
density={density}
|
|
141
|
+
active={active}
|
|
142
|
+
>
|
|
143
|
+
{children}
|
|
144
|
+
</ListItemInner>
|
|
145
|
+
</ListItemPriorityProvider>
|
|
126
146
|
)}
|
|
127
147
|
</Pressable>
|
|
128
148
|
</DisabledProvider>
|
|
@@ -135,12 +155,14 @@ export const ListItem = ({
|
|
|
135
155
|
ref={ref}
|
|
136
156
|
lx={lx}
|
|
137
157
|
style={style}
|
|
138
|
-
accessibilityState={{ disabled }}
|
|
158
|
+
accessibilityState={{ disabled, selected: active }}
|
|
139
159
|
{...props}
|
|
140
160
|
>
|
|
141
|
-
<
|
|
142
|
-
{
|
|
143
|
-
|
|
161
|
+
<ListItemPriorityProvider value={{ priority }}>
|
|
162
|
+
<ListItemInner pressed={false} density={density} active={active}>
|
|
163
|
+
{children}
|
|
164
|
+
</ListItemInner>
|
|
165
|
+
</ListItemPriorityProvider>
|
|
144
166
|
</Box>
|
|
145
167
|
</DisabledProvider>
|
|
146
168
|
);
|
|
@@ -152,13 +174,19 @@ export const ListItem = ({
|
|
|
152
174
|
const ListItemInner = ({
|
|
153
175
|
pressed,
|
|
154
176
|
density,
|
|
177
|
+
active,
|
|
155
178
|
children,
|
|
156
179
|
}: {
|
|
157
180
|
pressed: boolean;
|
|
158
181
|
density: Density;
|
|
182
|
+
active: boolean;
|
|
159
183
|
children: ReactNode;
|
|
160
184
|
}) => {
|
|
161
|
-
const
|
|
185
|
+
const disabled = useDisabledContext({
|
|
186
|
+
consumerName: 'ListItemInner',
|
|
187
|
+
contextRequired: false,
|
|
188
|
+
});
|
|
189
|
+
const styles = useRootStyles({ pressed, density, active, disabled });
|
|
162
190
|
return (
|
|
163
191
|
<View style={styles.container} testID='list-item-content'>
|
|
164
192
|
{children}
|
|
@@ -177,17 +205,23 @@ export const ListItemLeading = ({
|
|
|
177
205
|
ref,
|
|
178
206
|
...props
|
|
179
207
|
}: ListItemLeadingProps & { ref?: Ref<View> }) => {
|
|
208
|
+
const { priority } = useListItemPriorityContext({
|
|
209
|
+
consumerName: 'ListItemLeading',
|
|
210
|
+
contextRequired: false,
|
|
211
|
+
});
|
|
212
|
+
|
|
180
213
|
const styles = useStyleSheet(
|
|
181
214
|
(t) => ({
|
|
182
215
|
leading: {
|
|
183
|
-
|
|
216
|
+
flexGrow: 1,
|
|
217
|
+
flexShrink: priority === 'end' ? 1 : 0,
|
|
184
218
|
minWidth: 0,
|
|
185
219
|
flexDirection: 'row',
|
|
186
220
|
alignItems: 'center',
|
|
187
221
|
gap: t.spacings.s12,
|
|
188
222
|
},
|
|
189
223
|
}),
|
|
190
|
-
[],
|
|
224
|
+
[priority],
|
|
191
225
|
);
|
|
192
226
|
|
|
193
227
|
return (
|
|
@@ -217,16 +251,22 @@ export const ListItemContent = ({
|
|
|
217
251
|
contextRequired: false,
|
|
218
252
|
});
|
|
219
253
|
|
|
254
|
+
const { priority } = useListItemPriorityContext({
|
|
255
|
+
consumerName: 'ListItemContent',
|
|
256
|
+
contextRequired: false,
|
|
257
|
+
});
|
|
258
|
+
|
|
220
259
|
const styles = useStyleSheet(
|
|
221
260
|
(t) => ({
|
|
222
261
|
content: {
|
|
223
|
-
flex: isInTrailing ? 0 : 1,
|
|
262
|
+
flex: isInTrailing || priority === 'start' ? 0 : 1,
|
|
263
|
+
...(priority === 'start' && { flexShrink: 1, flexBasis: 'auto' }),
|
|
224
264
|
minWidth: 0,
|
|
225
265
|
gap: t.spacings.s4,
|
|
226
266
|
alignItems: isInTrailing ? 'flex-end' : 'stretch',
|
|
227
267
|
},
|
|
228
268
|
}),
|
|
229
|
-
[isInTrailing],
|
|
269
|
+
[priority, isInTrailing],
|
|
230
270
|
);
|
|
231
271
|
|
|
232
272
|
return (
|
|
@@ -386,14 +426,19 @@ export const ListItemTrailing = ({
|
|
|
386
426
|
ref,
|
|
387
427
|
...props
|
|
388
428
|
}: ListItemTrailingProps & { ref?: Ref<View> }) => {
|
|
429
|
+
const { priority } = useListItemPriorityContext({
|
|
430
|
+
consumerName: 'ListItemTrailing',
|
|
431
|
+
contextRequired: false,
|
|
432
|
+
});
|
|
433
|
+
|
|
389
434
|
const styles = useStyleSheet(
|
|
390
435
|
() => ({
|
|
391
436
|
trailing: {
|
|
392
|
-
flexShrink: 0,
|
|
437
|
+
flexShrink: priority === 'start' ? 1 : 0,
|
|
393
438
|
alignItems: 'center',
|
|
394
439
|
},
|
|
395
440
|
}),
|
|
396
|
-
[],
|
|
441
|
+
[priority],
|
|
397
442
|
);
|
|
398
443
|
|
|
399
444
|
return (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Density } from '@ledgerhq/lumen-utils-shared';
|
|
1
|
+
import type { Density, Priority } from '@ledgerhq/lumen-utils-shared';
|
|
2
2
|
import type {
|
|
3
3
|
StyledPressableProps,
|
|
4
4
|
StyledTextProps,
|
|
@@ -18,10 +18,20 @@ export type ListItemProps = {
|
|
|
18
18
|
* @default 'expanded'
|
|
19
19
|
*/
|
|
20
20
|
density?: Density;
|
|
21
|
+
/**
|
|
22
|
+
* The parts which are protected from shrinking and truncation when horizontal space is limited.
|
|
23
|
+
* @default 'end'
|
|
24
|
+
*/
|
|
25
|
+
priority?: Priority;
|
|
21
26
|
/**
|
|
22
27
|
* Whether the list item is disabled.
|
|
23
28
|
*/
|
|
24
29
|
disabled?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the list item is in an active/selected state.
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
active?: boolean;
|
|
25
35
|
/**
|
|
26
36
|
* Callback function when the list item is pressed.
|
|
27
37
|
*/
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import figma from '@figma/code-connect';
|
|
2
|
+
import { SectionHeader, SectionHeaderTitle } from './SectionHeader';
|
|
3
|
+
|
|
4
|
+
figma.connect(
|
|
5
|
+
SectionHeader,
|
|
6
|
+
'https://www.figma.com/design/JxaLVMTWirCpU0rsbZ30k7?node-id=18640-48457',
|
|
7
|
+
{
|
|
8
|
+
imports: [
|
|
9
|
+
"import { SectionHeader, SectionHeaderTitle } from '@ledgerhq/lumen-ui-rnative'",
|
|
10
|
+
],
|
|
11
|
+
props: {
|
|
12
|
+
appearance: figma.enum('appearance', {
|
|
13
|
+
'no-background': 'no-background',
|
|
14
|
+
plain: 'plain',
|
|
15
|
+
}),
|
|
16
|
+
title: figma.string('label'),
|
|
17
|
+
},
|
|
18
|
+
example: (props) => (
|
|
19
|
+
<SectionHeader appearance={props.appearance}>
|
|
20
|
+
<SectionHeaderTitle>{props.title}</SectionHeaderTitle>
|
|
21
|
+
</SectionHeader>
|
|
22
|
+
),
|
|
23
|
+
},
|
|
24
|
+
);
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Meta, Canvas, Controls, Source } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as SectionHeaderStories from './SectionHeader.stories';
|
|
3
|
+
import { SectionHeader } from './SectionHeader';
|
|
4
|
+
import { CustomTabs, Tab, SetupNote } from '../../../../.storybook/components';
|
|
5
|
+
|
|
6
|
+
<Meta title='Core/SectionHeader' of={SectionHeaderStories} />
|
|
7
|
+
|
|
8
|
+
# SectionHeader
|
|
9
|
+
|
|
10
|
+
<CustomTabs>
|
|
11
|
+
<Tab label="Overview">
|
|
12
|
+
|
|
13
|
+
## Introduction
|
|
14
|
+
|
|
15
|
+
SectionHeader is a compact, muted label used to title grouped content areas. It is smaller and more subdued than Subheader, making it suitable for category labels, list group headers, and inline section markers.
|
|
16
|
+
|
|
17
|
+
> View in [Figma](https://www.figma.com/design/JxaLVMTWirCpU0rsbZ30k7/2.-Components-Library?node-id=18640-48457&m=dev).
|
|
18
|
+
|
|
19
|
+
## Anatomy
|
|
20
|
+
|
|
21
|
+
<Canvas of={SectionHeaderStories.Base} />
|
|
22
|
+
|
|
23
|
+
The SectionHeader uses a composite structure with the following components:
|
|
24
|
+
|
|
25
|
+
- **SectionHeader** (container): The root component with optional `appearance` variant
|
|
26
|
+
- **SectionHeaderLeading** (optional): Slot for a leading icon or other content
|
|
27
|
+
- **SectionHeaderTitle** (required): The muted label text
|
|
28
|
+
|
|
29
|
+
## Properties
|
|
30
|
+
|
|
31
|
+
### Overview
|
|
32
|
+
|
|
33
|
+
<Canvas of={SectionHeaderStories.Base} />
|
|
34
|
+
<Controls of={SectionHeaderStories.Base} />
|
|
35
|
+
|
|
36
|
+
### Appearance
|
|
37
|
+
|
|
38
|
+
There are two appearances: `no-background` (default) renders plain muted text with no container styling, and `plain` wraps the label in a subtle surface chip.
|
|
39
|
+
|
|
40
|
+
<Canvas of={SectionHeaderStories.AppearanceShowcase} />
|
|
41
|
+
|
|
42
|
+
### With leading icon
|
|
43
|
+
|
|
44
|
+
Use `SectionHeaderLeading` to add an optional icon before the title.
|
|
45
|
+
|
|
46
|
+
<Canvas of={SectionHeaderStories.WithLeadingIcon} />
|
|
47
|
+
|
|
48
|
+
### Truncation
|
|
49
|
+
|
|
50
|
+
Long titles truncate with an ellipsis while keeping leading content visible.
|
|
51
|
+
|
|
52
|
+
<Canvas of={SectionHeaderStories.ResponsiveShowcase} />
|
|
53
|
+
|
|
54
|
+
</Tab>
|
|
55
|
+
|
|
56
|
+
<Tab label="Implementation">
|
|
57
|
+
|
|
58
|
+
<SetupNote />
|
|
59
|
+
|
|
60
|
+
`SectionHeader` is a compound component. Compose it with `SectionHeaderTitle` (required) and, optionally, `SectionHeaderLeading` for a leading icon.
|
|
61
|
+
|
|
62
|
+
### Basic Usage
|
|
63
|
+
|
|
64
|
+
<Source of={SectionHeaderStories.Base} />
|
|
65
|
+
|
|
66
|
+
### With leading icon
|
|
67
|
+
|
|
68
|
+
Add `SectionHeaderLeading` before the title to render a leading icon.
|
|
69
|
+
|
|
70
|
+
<Source of={SectionHeaderStories.WithLeadingIcon} />
|
|
71
|
+
|
|
72
|
+
### Truncation
|
|
73
|
+
|
|
74
|
+
Titles truncate with an ellipsis when they exceed the available width, while leading content stays visible.
|
|
75
|
+
|
|
76
|
+
<Source of={SectionHeaderStories.TruncateShowcase} />
|
|
77
|
+
|
|
78
|
+
</Tab>
|
|
79
|
+
</CustomTabs>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-native-web-vite';
|
|
2
|
+
import { Settings } from '../../Symbols';
|
|
3
|
+
import { Box } from '../Utility';
|
|
4
|
+
import {
|
|
5
|
+
SectionHeader,
|
|
6
|
+
SectionHeaderLeading,
|
|
7
|
+
SectionHeaderTitle,
|
|
8
|
+
} from './SectionHeader';
|
|
9
|
+
|
|
10
|
+
const meta: Meta<typeof SectionHeader> = {
|
|
11
|
+
component: SectionHeader,
|
|
12
|
+
id: 'rnative-sectionheader',
|
|
13
|
+
title: 'Core/SectionHeader',
|
|
14
|
+
subcomponents: {
|
|
15
|
+
SectionHeaderLeading,
|
|
16
|
+
SectionHeaderTitle,
|
|
17
|
+
},
|
|
18
|
+
parameters: {
|
|
19
|
+
layout: 'centered',
|
|
20
|
+
backgrounds: { default: 'light' },
|
|
21
|
+
docs: {
|
|
22
|
+
source: {
|
|
23
|
+
language: 'tsx',
|
|
24
|
+
format: true,
|
|
25
|
+
type: 'dynamic',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
argTypes: {
|
|
30
|
+
appearance: {
|
|
31
|
+
control: 'radio',
|
|
32
|
+
options: ['no-background', 'plain'],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
decorators: [
|
|
36
|
+
(Story) => (
|
|
37
|
+
<Box lx={{ padding: 's8', width: 's400' }}>
|
|
38
|
+
<Story />
|
|
39
|
+
</Box>
|
|
40
|
+
),
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default meta;
|
|
45
|
+
type Story = StoryObj<typeof SectionHeader>;
|
|
46
|
+
|
|
47
|
+
export const Base: Story = {
|
|
48
|
+
args: {
|
|
49
|
+
appearance: 'no-background',
|
|
50
|
+
},
|
|
51
|
+
render: ({ appearance }) => (
|
|
52
|
+
<SectionHeader appearance={appearance}>
|
|
53
|
+
<SectionHeaderTitle>Label</SectionHeaderTitle>
|
|
54
|
+
</SectionHeader>
|
|
55
|
+
),
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const AppearanceShowcase: Story = {
|
|
59
|
+
render: () => (
|
|
60
|
+
<Box lx={{ gap: 's8' }}>
|
|
61
|
+
<SectionHeader>
|
|
62
|
+
<SectionHeaderTitle>No background</SectionHeaderTitle>
|
|
63
|
+
</SectionHeader>
|
|
64
|
+
<SectionHeader appearance='plain'>
|
|
65
|
+
<SectionHeaderTitle>Plain</SectionHeaderTitle>
|
|
66
|
+
</SectionHeader>
|
|
67
|
+
</Box>
|
|
68
|
+
),
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const WithLeadingIcon: Story = {
|
|
72
|
+
render: () => (
|
|
73
|
+
<SectionHeader appearance='plain'>
|
|
74
|
+
<SectionHeaderLeading>
|
|
75
|
+
<Settings size={16} color='muted' />
|
|
76
|
+
</SectionHeaderLeading>
|
|
77
|
+
<SectionHeaderTitle>Label</SectionHeaderTitle>
|
|
78
|
+
</SectionHeader>
|
|
79
|
+
),
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const ResponsiveShowcase: Story = {
|
|
83
|
+
render: () => (
|
|
84
|
+
<Box lx={{ width: 's144' }}>
|
|
85
|
+
<SectionHeader appearance='plain'>
|
|
86
|
+
<SectionHeaderLeading>
|
|
87
|
+
<Settings size={16} color='muted' />
|
|
88
|
+
</SectionHeaderLeading>
|
|
89
|
+
<SectionHeaderTitle>
|
|
90
|
+
Very long section header label that should truncate
|
|
91
|
+
</SectionHeaderTitle>
|
|
92
|
+
</SectionHeader>
|
|
93
|
+
</Box>
|
|
94
|
+
),
|
|
95
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { describe, it, expect } from '@jest/globals';
|
|
2
|
+
import { ledgerLiveThemes } from '@ledgerhq/lumen-design-core';
|
|
3
|
+
import { render, screen } from '@testing-library/react-native';
|
|
4
|
+
import { Text } from 'react-native';
|
|
5
|
+
import { ThemeProvider } from '../ThemeProvider/ThemeProvider';
|
|
6
|
+
import {
|
|
7
|
+
SectionHeader,
|
|
8
|
+
SectionHeaderLeading,
|
|
9
|
+
SectionHeaderTitle,
|
|
10
|
+
} from './SectionHeader';
|
|
11
|
+
|
|
12
|
+
const TestWrapper = ({ children }: { children: React.ReactNode }) => (
|
|
13
|
+
<ThemeProvider themes={ledgerLiveThemes} colorScheme='dark' locale='en'>
|
|
14
|
+
{children}
|
|
15
|
+
</ThemeProvider>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
describe('SectionHeader', () => {
|
|
19
|
+
it('renders the title', () => {
|
|
20
|
+
render(
|
|
21
|
+
<TestWrapper>
|
|
22
|
+
<SectionHeader>
|
|
23
|
+
<SectionHeaderTitle>Label</SectionHeaderTitle>
|
|
24
|
+
</SectionHeader>
|
|
25
|
+
</TestWrapper>,
|
|
26
|
+
);
|
|
27
|
+
expect(screen.getByText('Label')).toBeTruthy();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('renders with plain appearance', () => {
|
|
31
|
+
render(
|
|
32
|
+
<TestWrapper>
|
|
33
|
+
<SectionHeader appearance='plain' testID='section-header'>
|
|
34
|
+
<SectionHeaderTitle>Label</SectionHeaderTitle>
|
|
35
|
+
</SectionHeader>
|
|
36
|
+
</TestWrapper>,
|
|
37
|
+
);
|
|
38
|
+
expect(screen.getByText('Label')).toBeTruthy();
|
|
39
|
+
expect(screen.getByTestId('section-header')).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('renders with no-background appearance by default', () => {
|
|
43
|
+
render(
|
|
44
|
+
<TestWrapper>
|
|
45
|
+
<SectionHeader testID='section-header'>
|
|
46
|
+
<SectionHeaderTitle>Label</SectionHeaderTitle>
|
|
47
|
+
</SectionHeader>
|
|
48
|
+
</TestWrapper>,
|
|
49
|
+
);
|
|
50
|
+
expect(screen.getByTestId('section-header')).toBeTruthy();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('renders leading content when provided', () => {
|
|
54
|
+
render(
|
|
55
|
+
<TestWrapper>
|
|
56
|
+
<SectionHeader>
|
|
57
|
+
<SectionHeaderLeading testID='leading'>
|
|
58
|
+
<Text>icon</Text>
|
|
59
|
+
</SectionHeaderLeading>
|
|
60
|
+
<SectionHeaderTitle>Label</SectionHeaderTitle>
|
|
61
|
+
</SectionHeader>
|
|
62
|
+
</TestWrapper>,
|
|
63
|
+
);
|
|
64
|
+
expect(screen.getByTestId('leading')).toBeTruthy();
|
|
65
|
+
expect(screen.getByText('Label')).toBeTruthy();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('renders all subcomponents together with plain appearance', () => {
|
|
69
|
+
render(
|
|
70
|
+
<TestWrapper>
|
|
71
|
+
<SectionHeader appearance='plain' testID='section-header'>
|
|
72
|
+
<SectionHeaderLeading testID='leading'>
|
|
73
|
+
<Text>icon</Text>
|
|
74
|
+
</SectionHeaderLeading>
|
|
75
|
+
<SectionHeaderTitle>Accounts</SectionHeaderTitle>
|
|
76
|
+
</SectionHeader>
|
|
77
|
+
</TestWrapper>,
|
|
78
|
+
);
|
|
79
|
+
expect(screen.getByTestId('leading')).toBeTruthy();
|
|
80
|
+
expect(screen.getByText('Accounts')).toBeTruthy();
|
|
81
|
+
expect(screen.getByTestId('section-header')).toBeTruthy();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('keeps leading content visible with a long title', () => {
|
|
85
|
+
render(
|
|
86
|
+
<TestWrapper>
|
|
87
|
+
<SectionHeader lx={{ maxWidth: 's80' }}>
|
|
88
|
+
<SectionHeaderLeading testID='leading'>
|
|
89
|
+
<Text>icon</Text>
|
|
90
|
+
</SectionHeaderLeading>
|
|
91
|
+
<SectionHeaderTitle>
|
|
92
|
+
Very long section header label that should truncate
|
|
93
|
+
</SectionHeaderTitle>
|
|
94
|
+
</SectionHeader>
|
|
95
|
+
</TestWrapper>,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
expect(screen.getByTestId('leading')).toBeTruthy();
|
|
99
|
+
expect(
|
|
100
|
+
screen.getByText('Very long section header label that should truncate'),
|
|
101
|
+
).toBeTruthy();
|
|
102
|
+
});
|
|
103
|
+
});
|