@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
|
@@ -41,6 +41,10 @@ export type BaseInputProps = {
|
|
|
41
41
|
* Pair with `status` for error/success styling and icons; omit `status` for a neutral hint.
|
|
42
42
|
*/
|
|
43
43
|
helperText?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Soft character limit. When set, renders a `count/maxCount` counter below the input.
|
|
46
|
+
*/
|
|
47
|
+
maxCount?: number;
|
|
44
48
|
/**
|
|
45
49
|
* Visual state for border, helper text, helper icon, and the label in error state.
|
|
46
50
|
* Omit when `helperText` is a neutral hint.
|
|
@@ -66,3 +70,17 @@ export type BaseInputProps = {
|
|
|
66
70
|
hideClearButton?: boolean;
|
|
67
71
|
} & Omit<TextInputProps, 'style'> &
|
|
68
72
|
BoxProps;
|
|
73
|
+
|
|
74
|
+
export type BaseInputHelperTextProps = {
|
|
75
|
+
/**
|
|
76
|
+
* The helper copy shown below the input.
|
|
77
|
+
*/
|
|
78
|
+
helperText: string;
|
|
79
|
+
} & Pick<BaseInputProps, 'status'>;
|
|
80
|
+
|
|
81
|
+
export type BaseInputCounterProps = {
|
|
82
|
+
/**
|
|
83
|
+
* Current character count.
|
|
84
|
+
*/
|
|
85
|
+
count: number;
|
|
86
|
+
} & Required<Pick<BaseInputProps, 'maxCount'>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import figma from '@figma/code-connect';
|
|
2
|
+
import { Box } from '../Utility';
|
|
3
|
+
|
|
4
|
+
figma.connect(
|
|
5
|
+
'https://www.figma.com/design/JxaLVMTWirCpU0rsbZ30k7?node-id=6495-22228',
|
|
6
|
+
{
|
|
7
|
+
imports: ["import { Box, Button } from '@ledgerhq/lumen-ui-rnative'"],
|
|
8
|
+
props: {
|
|
9
|
+
buttons: figma.children('*'),
|
|
10
|
+
},
|
|
11
|
+
example: (props) => (
|
|
12
|
+
<Box lx={{ flexDirection: 'row', gap: 's8' }}>{props.buttons}</Box>
|
|
13
|
+
),
|
|
14
|
+
},
|
|
15
|
+
);
|
|
@@ -13,16 +13,16 @@ import { CustomTabs, Tab } from '../../../../.storybook/components';
|
|
|
13
13
|
|
|
14
14
|
## Introduction
|
|
15
15
|
|
|
16
|
-
DescriptionItem is a compound component for displaying key-value rows — typically used inside a summary panel, transaction detail, or settings screen. It composes a leading label side and a trailing value side
|
|
16
|
+
DescriptionItem is a compound component for displaying key-value rows — typically used inside a summary panel, transaction detail, or settings screen. It composes a leading label side and a trailing value side. By default the trailing value takes priority over the leading label when space is constrained.
|
|
17
17
|
|
|
18
18
|
## Anatomy
|
|
19
19
|
|
|
20
20
|
<Canvas of={DescriptionItemStories.Base} />
|
|
21
21
|
|
|
22
|
-
- **DescriptionItem**: Root row container. Accepts an optional `size` prop (`md` | `sm`).
|
|
22
|
+
- **DescriptionItem**: Root row container. Accepts an optional `size` prop (`md` | `sm`) and a `priority` prop (`end` | `start`).
|
|
23
23
|
- **DescriptionItemLeading**: Left section holding the label and any optional sibling (e.g. a tooltip icon).
|
|
24
|
-
- **DescriptionItemLabel**: Muted text label.
|
|
25
|
-
- **DescriptionItemTrailing**: Right section holding the value or any inline element (Tag, Link, etc.).
|
|
24
|
+
- **DescriptionItemLabel**: Muted text label. Truncates after two lines (`numberOfLines={2}`).
|
|
25
|
+
- **DescriptionItemTrailing**: Right section holding the value or any inline element (Tag, Link, etc.). Has layout priority by default (does not shrink), but shrinks when `priority='start'`.
|
|
26
26
|
- **DescriptionItemValue**: Semi-bold value text. Truncates to a single line (`numberOfLines={1}`).
|
|
27
27
|
|
|
28
28
|
## Properties
|
|
@@ -51,11 +51,14 @@ Pair a `Tooltip` with an info icon inside `DescriptionItemLeading` to surface ad
|
|
|
51
51
|
|
|
52
52
|
<Canvas of={DescriptionItemStories.WithInfoIcon} />
|
|
53
53
|
|
|
54
|
-
###
|
|
54
|
+
### Priority
|
|
55
55
|
|
|
56
|
-
The label
|
|
56
|
+
The label truncates after two lines and the trailing value after one. When both sides have long content and horizontal space is constrained, the `priority` prop controls which side is protected from shrinking and truncation.
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
- `priority='end'` (default): the leading label shrinks and truncates, while the trailing value is protected.
|
|
59
|
+
- `priority='start'`: the trailing value shrinks and truncates, while the leading label is protected.
|
|
60
|
+
|
|
61
|
+
<Canvas of={DescriptionItemStories.PriorityShowcase} />
|
|
59
62
|
|
|
60
63
|
</Tab>
|
|
61
64
|
<Tab label="Implementation">
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-native';
|
|
2
|
-
import { Text, View } from 'react-native';
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-native-web-vite';
|
|
3
2
|
import { Information } from '../../Symbols';
|
|
4
3
|
import { InteractiveIcon } from '../InteractiveIcon';
|
|
5
4
|
import { Tag } from '../Tag';
|
|
6
5
|
import { Tooltip, TooltipContent, TooltipTrigger } from '../Tooltip';
|
|
6
|
+
import { Box, Text } from '../Utility';
|
|
7
7
|
import {
|
|
8
8
|
DescriptionItem,
|
|
9
9
|
DescriptionItemLabel,
|
|
@@ -12,12 +12,6 @@ import {
|
|
|
12
12
|
DescriptionItemValue,
|
|
13
13
|
} from './DescriptionItem';
|
|
14
14
|
|
|
15
|
-
const Container = ({ children }: { children: React.ReactNode }) => (
|
|
16
|
-
<View style={{ padding: 8, backgroundColor: '#ffffff', width: 320 }}>
|
|
17
|
-
{children}
|
|
18
|
-
</View>
|
|
19
|
-
);
|
|
20
|
-
|
|
21
15
|
const meta: Meta<typeof DescriptionItem> = {
|
|
22
16
|
component: DescriptionItem,
|
|
23
17
|
id: 'rnative-descriptionitem',
|
|
@@ -30,6 +24,7 @@ const meta: Meta<typeof DescriptionItem> = {
|
|
|
30
24
|
},
|
|
31
25
|
parameters: {
|
|
32
26
|
layout: 'centered',
|
|
27
|
+
backgrounds: { default: 'light' },
|
|
33
28
|
docs: {
|
|
34
29
|
source: {
|
|
35
30
|
language: 'tsx',
|
|
@@ -40,9 +35,9 @@ const meta: Meta<typeof DescriptionItem> = {
|
|
|
40
35
|
},
|
|
41
36
|
decorators: [
|
|
42
37
|
(Story) => (
|
|
43
|
-
<
|
|
38
|
+
<Box lx={{ padding: 's8', width: 's320' }}>
|
|
44
39
|
<Story />
|
|
45
|
-
</
|
|
40
|
+
</Box>
|
|
46
41
|
),
|
|
47
42
|
],
|
|
48
43
|
};
|
|
@@ -71,7 +66,7 @@ export const SizeShowcase: Story = {
|
|
|
71
66
|
size: 'md',
|
|
72
67
|
},
|
|
73
68
|
render: () => (
|
|
74
|
-
<
|
|
69
|
+
<Box lx={{ gap: 's16' }}>
|
|
75
70
|
<DescriptionItem size='md'>
|
|
76
71
|
<DescriptionItemLeading>
|
|
77
72
|
<DescriptionItemLabel>Network</DescriptionItemLabel>
|
|
@@ -89,7 +84,7 @@ export const SizeShowcase: Story = {
|
|
|
89
84
|
<Tag size='md' label='Ethereum' appearance='base' />
|
|
90
85
|
</DescriptionItemTrailing>
|
|
91
86
|
</DescriptionItem>
|
|
92
|
-
|
|
87
|
+
|
|
93
88
|
<DescriptionItem size='sm'>
|
|
94
89
|
<DescriptionItemLeading>
|
|
95
90
|
<DescriptionItemLabel>Network</DescriptionItemLabel>
|
|
@@ -107,13 +102,13 @@ export const SizeShowcase: Story = {
|
|
|
107
102
|
<Tag size='sm' label='Ethereum' appearance='base' />
|
|
108
103
|
</DescriptionItemTrailing>
|
|
109
104
|
</DescriptionItem>
|
|
110
|
-
</
|
|
105
|
+
</Box>
|
|
111
106
|
),
|
|
112
107
|
};
|
|
113
108
|
|
|
114
109
|
export const TrailingVariants: Story = {
|
|
115
110
|
render: () => (
|
|
116
|
-
<
|
|
111
|
+
<Box lx={{ gap: 's16' }}>
|
|
117
112
|
<DescriptionItem>
|
|
118
113
|
<DescriptionItemLeading>
|
|
119
114
|
<DescriptionItemLabel>Plain value</DescriptionItemLabel>
|
|
@@ -141,13 +136,13 @@ export const TrailingVariants: Story = {
|
|
|
141
136
|
<Tag size='md' label='New' appearance='accent' />
|
|
142
137
|
</DescriptionItemTrailing>
|
|
143
138
|
</DescriptionItem>
|
|
144
|
-
</
|
|
139
|
+
</Box>
|
|
145
140
|
),
|
|
146
141
|
};
|
|
147
142
|
|
|
148
143
|
export const WithInfoIcon: Story = {
|
|
149
144
|
render: () => (
|
|
150
|
-
<
|
|
145
|
+
<Box lx={{ gap: 's16' }}>
|
|
151
146
|
<DescriptionItem>
|
|
152
147
|
<DescriptionItemLeading>
|
|
153
148
|
<DescriptionItemLabel>Fees</DescriptionItemLabel>
|
|
@@ -189,47 +184,32 @@ export const WithInfoIcon: Story = {
|
|
|
189
184
|
<DescriptionItemValue>~30 min</DescriptionItemValue>
|
|
190
185
|
</DescriptionItemTrailing>
|
|
191
186
|
</DescriptionItem>
|
|
192
|
-
</
|
|
187
|
+
</Box>
|
|
193
188
|
),
|
|
194
189
|
};
|
|
195
190
|
|
|
196
|
-
export const
|
|
191
|
+
export const PriorityShowcase: Story = {
|
|
197
192
|
render: () => (
|
|
198
|
-
<
|
|
199
|
-
<DescriptionItem>
|
|
200
|
-
<DescriptionItemLeading>
|
|
201
|
-
<DescriptionItemLabel>
|
|
202
|
-
This is a very long label that should go to a second line.
|
|
203
|
-
</DescriptionItemLabel>
|
|
204
|
-
</DescriptionItemLeading>
|
|
205
|
-
<DescriptionItemTrailing>
|
|
206
|
-
<DescriptionItemValue>0.001 BTC</DescriptionItemValue>
|
|
207
|
-
</DescriptionItemTrailing>
|
|
208
|
-
</DescriptionItem>
|
|
209
|
-
|
|
210
|
-
<DescriptionItem>
|
|
193
|
+
<Box lx={{ gap: 's16' }}>
|
|
194
|
+
<DescriptionItem priority='end'>
|
|
211
195
|
<DescriptionItemLeading>
|
|
212
|
-
<DescriptionItemLabel>
|
|
196
|
+
<DescriptionItemLabel>priority="end" (default)</DescriptionItemLabel>
|
|
213
197
|
</DescriptionItemLeading>
|
|
214
198
|
<DescriptionItemTrailing>
|
|
215
|
-
<DescriptionItemValue>
|
|
216
|
-
0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045
|
|
217
|
-
</DescriptionItemValue>
|
|
199
|
+
<DescriptionItemValue>0xd8dA6BF26964aF9D7eEd9e</DescriptionItemValue>
|
|
218
200
|
</DescriptionItemTrailing>
|
|
219
201
|
</DescriptionItem>
|
|
220
202
|
|
|
221
|
-
<DescriptionItem>
|
|
203
|
+
<DescriptionItem priority='start'>
|
|
222
204
|
<DescriptionItemLeading>
|
|
223
205
|
<DescriptionItemLabel>
|
|
224
|
-
|
|
206
|
+
priority="start" long label which will not truncate
|
|
225
207
|
</DescriptionItemLabel>
|
|
226
208
|
</DescriptionItemLeading>
|
|
227
209
|
<DescriptionItemTrailing>
|
|
228
|
-
<DescriptionItemValue>
|
|
229
|
-
0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045
|
|
230
|
-
</DescriptionItemValue>
|
|
210
|
+
<DescriptionItemValue>0xd8dA6BF26964aF9D7eEd9e</DescriptionItemValue>
|
|
231
211
|
</DescriptionItemTrailing>
|
|
232
212
|
</DescriptionItem>
|
|
233
|
-
</
|
|
213
|
+
</Box>
|
|
234
214
|
),
|
|
235
215
|
};
|
|
@@ -83,6 +83,30 @@ describe('DescriptionItem', () => {
|
|
|
83
83
|
});
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
+
describe('priority', () => {
|
|
87
|
+
it('in "end" priority, leading shrinks, trailing shows', () => {
|
|
88
|
+
renderDescriptionItem();
|
|
89
|
+
|
|
90
|
+
expect(screen.getByTestId('leading').props.style).toEqual(
|
|
91
|
+
expect.objectContaining({ flexShrink: 1 }),
|
|
92
|
+
);
|
|
93
|
+
expect(screen.getByTestId('trailing').props.style).toEqual(
|
|
94
|
+
expect.objectContaining({ flexShrink: 0 }),
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('in "start" priority: trailing shrinks, leading shows', () => {
|
|
99
|
+
renderDescriptionItem({ priority: 'start' });
|
|
100
|
+
|
|
101
|
+
expect(screen.getByTestId('leading').props.style).toEqual(
|
|
102
|
+
expect.objectContaining({ flexShrink: 0 }),
|
|
103
|
+
);
|
|
104
|
+
expect(screen.getByTestId('trailing').props.style).toEqual(
|
|
105
|
+
expect.objectContaining({ flexShrink: 1 }),
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
86
110
|
describe('DescriptionItemValue', () => {
|
|
87
111
|
it.each([
|
|
88
112
|
['md', typographies.body2SemiBold],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createSafeContext } from '@ledgerhq/lumen-utils-shared';
|
|
1
|
+
import { createSafeContext, type Priority } from '@ledgerhq/lumen-utils-shared';
|
|
2
2
|
import { StyleSheet } from 'react-native';
|
|
3
3
|
import { useStyleSheet } from '../../../styles';
|
|
4
4
|
import { Box, Text } from '../Utility';
|
|
@@ -20,6 +20,11 @@ const [DescriptionItemSizeProvider, useDescriptionItemSizeContext] =
|
|
|
20
20
|
size: 'md',
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
+
const [DescriptionItemPriorityProvider, useDescriptionItemPriorityContext] =
|
|
24
|
+
createSafeContext<{ priority?: Priority }>('DescriptionItemPriority', {
|
|
25
|
+
priority: undefined,
|
|
26
|
+
});
|
|
27
|
+
|
|
23
28
|
/**
|
|
24
29
|
* A compound component for displaying a key-value description row.
|
|
25
30
|
* Composed with DescriptionItemLeading / DescriptionItemLabel (key side)
|
|
@@ -42,6 +47,7 @@ export const DescriptionItem = ({
|
|
|
42
47
|
lx = {},
|
|
43
48
|
style,
|
|
44
49
|
size = 'md',
|
|
50
|
+
priority = 'end',
|
|
45
51
|
...props
|
|
46
52
|
}: DescriptionItemProps) => {
|
|
47
53
|
const styles = useStyleSheet(
|
|
@@ -58,9 +64,15 @@ export const DescriptionItem = ({
|
|
|
58
64
|
|
|
59
65
|
return (
|
|
60
66
|
<DescriptionItemSizeProvider value={{ size }}>
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
<DescriptionItemPriorityProvider value={{ priority }}>
|
|
68
|
+
<Box
|
|
69
|
+
lx={lx}
|
|
70
|
+
style={StyleSheet.flatten([styles.root, style])}
|
|
71
|
+
{...props}
|
|
72
|
+
>
|
|
73
|
+
{children}
|
|
74
|
+
</Box>
|
|
75
|
+
</DescriptionItemPriorityProvider>
|
|
64
76
|
</DescriptionItemSizeProvider>
|
|
65
77
|
);
|
|
66
78
|
};
|
|
@@ -75,17 +87,23 @@ export const DescriptionItemLeading = ({
|
|
|
75
87
|
style,
|
|
76
88
|
...props
|
|
77
89
|
}: DescriptionItemLeadingProps) => {
|
|
90
|
+
const { priority } = useDescriptionItemPriorityContext({
|
|
91
|
+
consumerName: 'DescriptionItemLeading',
|
|
92
|
+
contextRequired: false,
|
|
93
|
+
});
|
|
94
|
+
|
|
78
95
|
const styles = useStyleSheet(
|
|
79
96
|
(t) => ({
|
|
80
97
|
leading: {
|
|
81
|
-
|
|
98
|
+
flexGrow: 1,
|
|
99
|
+
flexShrink: priority === 'end' ? 1 : 0,
|
|
82
100
|
minWidth: 0,
|
|
83
101
|
flexDirection: 'row',
|
|
84
102
|
alignItems: 'center',
|
|
85
103
|
gap: t.spacings.s4,
|
|
86
104
|
},
|
|
87
105
|
}),
|
|
88
|
-
[],
|
|
106
|
+
[priority],
|
|
89
107
|
);
|
|
90
108
|
|
|
91
109
|
return (
|
|
@@ -151,17 +169,22 @@ export const DescriptionItemTrailing = ({
|
|
|
151
169
|
style,
|
|
152
170
|
...props
|
|
153
171
|
}: DescriptionItemTrailingProps) => {
|
|
172
|
+
const { priority } = useDescriptionItemPriorityContext({
|
|
173
|
+
consumerName: 'DescriptionItemTrailing',
|
|
174
|
+
contextRequired: false,
|
|
175
|
+
});
|
|
176
|
+
|
|
154
177
|
const styles = useStyleSheet(
|
|
155
178
|
(t) => ({
|
|
156
179
|
trailing: {
|
|
157
|
-
flexShrink: 0,
|
|
180
|
+
flexShrink: priority === 'start' ? 1 : 0,
|
|
158
181
|
maxWidth: '80%',
|
|
159
182
|
flexDirection: 'row',
|
|
160
183
|
alignItems: 'center',
|
|
161
184
|
gap: t.spacings.s4,
|
|
162
185
|
},
|
|
163
186
|
}),
|
|
164
|
-
[],
|
|
187
|
+
[priority],
|
|
165
188
|
);
|
|
166
189
|
|
|
167
190
|
return (
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Priority } from '@ledgerhq/lumen-utils-shared';
|
|
1
2
|
import type { ReactNode } from 'react';
|
|
2
3
|
import type { StyledTextProps, StyledViewProps } from '../../../styles';
|
|
3
4
|
|
|
@@ -13,6 +14,11 @@ export type DescriptionItemProps = {
|
|
|
13
14
|
* @default 'md'
|
|
14
15
|
*/
|
|
15
16
|
size?: DescriptionItemSize;
|
|
17
|
+
/**
|
|
18
|
+
* The parts which are protected from shrinking and truncation when horizontal space is limited.
|
|
19
|
+
* @default 'end'
|
|
20
|
+
*/
|
|
21
|
+
priority?: Priority;
|
|
16
22
|
} & Omit<StyledViewProps, 'children'>;
|
|
17
23
|
|
|
18
24
|
export type DescriptionItemLeadingProps = {
|
|
@@ -97,6 +97,9 @@ const commonProps = {
|
|
|
97
97
|
disabled: figma.enum('state', {
|
|
98
98
|
disabled: true,
|
|
99
99
|
}),
|
|
100
|
+
active: figma.enum('state', {
|
|
101
|
+
active: true,
|
|
102
|
+
}),
|
|
100
103
|
density: figma.enum('density', {
|
|
101
104
|
compact: 'compact',
|
|
102
105
|
expanded: 'expanded',
|
|
@@ -129,7 +132,11 @@ figma.connect(
|
|
|
129
132
|
}),
|
|
130
133
|
},
|
|
131
134
|
example: (props) => (
|
|
132
|
-
<ListItem
|
|
135
|
+
<ListItem
|
|
136
|
+
disabled={props.disabled}
|
|
137
|
+
active={props.active}
|
|
138
|
+
density={props.density}
|
|
139
|
+
>
|
|
133
140
|
<ListItemLeading>
|
|
134
141
|
{props.checkbox}
|
|
135
142
|
{props.leadingContent}
|
|
@@ -167,7 +174,11 @@ figma.connect(
|
|
|
167
174
|
}),
|
|
168
175
|
},
|
|
169
176
|
example: (props) => (
|
|
170
|
-
<ListItem
|
|
177
|
+
<ListItem
|
|
178
|
+
disabled={props.disabled}
|
|
179
|
+
active={props.active}
|
|
180
|
+
density={props.density}
|
|
181
|
+
>
|
|
171
182
|
<ListItemLeading>
|
|
172
183
|
{props.checkbox}
|
|
173
184
|
{props.leadingContent}
|
|
@@ -209,7 +220,11 @@ figma.connect(
|
|
|
209
220
|
}),
|
|
210
221
|
},
|
|
211
222
|
example: (props) => (
|
|
212
|
-
<ListItem
|
|
223
|
+
<ListItem
|
|
224
|
+
disabled={props.disabled}
|
|
225
|
+
active={props.active}
|
|
226
|
+
density={props.density}
|
|
227
|
+
>
|
|
213
228
|
<ListItemLeading>
|
|
214
229
|
{props.checkbox}
|
|
215
230
|
{props.leadingContent}
|
|
@@ -252,7 +267,11 @@ figma.connect(
|
|
|
252
267
|
}),
|
|
253
268
|
},
|
|
254
269
|
example: (props) => (
|
|
255
|
-
<ListItem
|
|
270
|
+
<ListItem
|
|
271
|
+
disabled={props.disabled}
|
|
272
|
+
active={props.active}
|
|
273
|
+
density={props.density}
|
|
274
|
+
>
|
|
256
275
|
<ListItemLeading>
|
|
257
276
|
{props.checkbox}
|
|
258
277
|
{props.leadingContent}
|
|
@@ -292,7 +311,11 @@ figma.connect(
|
|
|
292
311
|
}),
|
|
293
312
|
},
|
|
294
313
|
example: (props) => (
|
|
295
|
-
<ListItem
|
|
314
|
+
<ListItem
|
|
315
|
+
disabled={props.disabled}
|
|
316
|
+
active={props.active}
|
|
317
|
+
density={props.density}
|
|
318
|
+
>
|
|
296
319
|
<ListItemLeading>
|
|
297
320
|
{props.checkbox}
|
|
298
321
|
{props.leadingContent}
|
|
@@ -329,7 +352,11 @@ figma.connect(
|
|
|
329
352
|
...commonProps,
|
|
330
353
|
},
|
|
331
354
|
example: (props) => (
|
|
332
|
-
<ListItem
|
|
355
|
+
<ListItem
|
|
356
|
+
disabled={props.disabled}
|
|
357
|
+
active={props.active}
|
|
358
|
+
density={props.density}
|
|
359
|
+
>
|
|
333
360
|
<ListItemLeading>
|
|
334
361
|
{props.checkbox}
|
|
335
362
|
{props.leadingContent}
|
|
@@ -369,7 +396,11 @@ figma.connect(
|
|
|
369
396
|
}),
|
|
370
397
|
},
|
|
371
398
|
example: (props) => (
|
|
372
|
-
<ListItem
|
|
399
|
+
<ListItem
|
|
400
|
+
disabled={props.disabled}
|
|
401
|
+
active={props.active}
|
|
402
|
+
density={props.density}
|
|
403
|
+
>
|
|
373
404
|
<ListItemLeading>
|
|
374
405
|
{props.checkbox}
|
|
375
406
|
{props.leadingContent}
|
|
@@ -411,7 +442,11 @@ figma.connect(
|
|
|
411
442
|
...commonProps,
|
|
412
443
|
},
|
|
413
444
|
example: (props) => (
|
|
414
|
-
<ListItem
|
|
445
|
+
<ListItem
|
|
446
|
+
disabled={props.disabled}
|
|
447
|
+
active={props.active}
|
|
448
|
+
density={props.density}
|
|
449
|
+
>
|
|
415
450
|
<ListItemLeading>
|
|
416
451
|
{props.checkbox}
|
|
417
452
|
{props.leadingContent}
|
|
@@ -49,6 +49,17 @@ ListItems are flexible interactive elements designed for lists. They use a compo
|
|
|
49
49
|
|
|
50
50
|
<Canvas of={ListItemStories.DensityShowcase} />
|
|
51
51
|
|
|
52
|
+
### Priority
|
|
53
|
+
|
|
54
|
+
When horizontal space is constrained and both the leading and trailing sides have long content, the `priority` prop controls which side is protected from shrinking and truncation.
|
|
55
|
+
|
|
56
|
+
- `priority='end'` (default): the leading side (title/description) shrinks and truncates, while the trailing content keeps its natural size.
|
|
57
|
+
- `priority='start'`: the trailing content shrinks and truncates, while the leading side is protected.
|
|
58
|
+
|
|
59
|
+
> **Platform note:** On native, the protected side truncates with an ellipsis. On web (react-native-web), CSS flexbox will not shrink a protected item below its content width, so it is clipped by the container instead of showing an ellipsis. This is a rendering difference only - the behavior is correct on device.
|
|
60
|
+
|
|
61
|
+
<Canvas of={ListItemStories.PriorityShowcase} />
|
|
62
|
+
|
|
52
63
|
### Interactivity
|
|
53
64
|
|
|
54
65
|
The ListItem can be interactive or non-interactive. By default, the ListItem is non-interactive. To make it interactive, you need to pass an `onPress` prop.
|
|
@@ -61,6 +72,12 @@ When disabled, the ListItem becomes non-interactive. The disabled state is autom
|
|
|
61
72
|
|
|
62
73
|
<Canvas of={ListItemStories.DisabledState} />
|
|
63
74
|
|
|
75
|
+
### Active State
|
|
76
|
+
|
|
77
|
+
When `active` is `true`, the background uses the muted token to indicate a selected or highlighted item.
|
|
78
|
+
|
|
79
|
+
<Canvas of={ListItemStories.ActiveState} />
|
|
80
|
+
|
|
64
81
|
### Responsive Layout
|
|
65
82
|
|
|
66
83
|
ListItems adapt to their container width, truncating long titles and descriptions as needed.
|
|
@@ -323,6 +323,50 @@ export const DisabledState: Story = {
|
|
|
323
323
|
},
|
|
324
324
|
};
|
|
325
325
|
|
|
326
|
+
export const ActiveState: Story = {
|
|
327
|
+
args: {
|
|
328
|
+
active: true,
|
|
329
|
+
},
|
|
330
|
+
render: (args) => (
|
|
331
|
+
<Box lx={{ flexDirection: 'column', width: 's320', gap: 's8' }}>
|
|
332
|
+
<ListItem {...args}>
|
|
333
|
+
<ListItemLeading>
|
|
334
|
+
<Spot size={48} appearance='icon' icon={Settings} />
|
|
335
|
+
<ListItemContent>
|
|
336
|
+
<ListItemTitle>Active Item</ListItemTitle>
|
|
337
|
+
<ListItemDescription>
|
|
338
|
+
Static with muted background
|
|
339
|
+
</ListItemDescription>
|
|
340
|
+
</ListItemContent>
|
|
341
|
+
</ListItemLeading>
|
|
342
|
+
</ListItem>
|
|
343
|
+
|
|
344
|
+
<ListItem {...args} onPress={() => {}}>
|
|
345
|
+
<ListItemLeading>
|
|
346
|
+
<Spot size={48} appearance='icon' icon={Settings} />
|
|
347
|
+
<ListItemContent>
|
|
348
|
+
<ListItemTitle>Active Interactive</ListItemTitle>
|
|
349
|
+
<ListItemDescription>Press for muted-pressed</ListItemDescription>
|
|
350
|
+
</ListItemContent>
|
|
351
|
+
</ListItemLeading>
|
|
352
|
+
<ListItemTrailing>
|
|
353
|
+
<ChevronRight size={24} />
|
|
354
|
+
</ListItemTrailing>
|
|
355
|
+
</ListItem>
|
|
356
|
+
|
|
357
|
+
<ListItem {...args} disabled>
|
|
358
|
+
<ListItemLeading>
|
|
359
|
+
<Spot size={48} appearance='icon' icon={Wallet} />
|
|
360
|
+
<ListItemContent>
|
|
361
|
+
<ListItemTitle>Active Disabled</ListItemTitle>
|
|
362
|
+
<ListItemDescription>Uses disabled background</ListItemDescription>
|
|
363
|
+
</ListItemContent>
|
|
364
|
+
</ListItemLeading>
|
|
365
|
+
</ListItem>
|
|
366
|
+
</Box>
|
|
367
|
+
),
|
|
368
|
+
};
|
|
369
|
+
|
|
326
370
|
export const ResponsiveLayout: Story = {
|
|
327
371
|
render: () => (
|
|
328
372
|
<Box lx={{ flexDirection: 'column', width: 's480', gap: 's32' }}>
|
|
@@ -402,6 +446,54 @@ export const ResponsiveLayout: Story = {
|
|
|
402
446
|
),
|
|
403
447
|
};
|
|
404
448
|
|
|
449
|
+
export const PriorityShowcase: Story = {
|
|
450
|
+
render: () => (
|
|
451
|
+
<Box lx={{ flexDirection: 'column', width: 's320', gap: 's8' }}>
|
|
452
|
+
<Text typography='body4SemiBold' lx={{ color: 'muted' }}>
|
|
453
|
+
priority="end" (default)
|
|
454
|
+
</Text>
|
|
455
|
+
<ListItem priority='end'>
|
|
456
|
+
<ListItemLeading>
|
|
457
|
+
<Spot size={48} appearance='icon' icon={Wallet} />
|
|
458
|
+
<ListItemContent>
|
|
459
|
+
<ListItemTitle>
|
|
460
|
+
Long title competing with trailing value content
|
|
461
|
+
</ListItemTitle>
|
|
462
|
+
<ListItemDescription>priority="end"</ListItemDescription>
|
|
463
|
+
</ListItemContent>
|
|
464
|
+
</ListItemLeading>
|
|
465
|
+
<ListItemTrailing>
|
|
466
|
+
<ListItemContent>
|
|
467
|
+
<ListItemTitle>1,234,567,891,234.56</ListItemTitle>
|
|
468
|
+
<ListItemDescription>USD</ListItemDescription>
|
|
469
|
+
</ListItemContent>
|
|
470
|
+
</ListItemTrailing>
|
|
471
|
+
</ListItem>
|
|
472
|
+
|
|
473
|
+
<Text typography='body4SemiBold' lx={{ color: 'muted' }}>
|
|
474
|
+
priority="start"
|
|
475
|
+
</Text>
|
|
476
|
+
<ListItem priority='start'>
|
|
477
|
+
<ListItemLeading>
|
|
478
|
+
<Spot size={48} appearance='icon' icon={Wallet} />
|
|
479
|
+
<ListItemContent>
|
|
480
|
+
<ListItemTitle>
|
|
481
|
+
Long title competing with trailing value content
|
|
482
|
+
</ListItemTitle>
|
|
483
|
+
<ListItemDescription>priority="start"</ListItemDescription>
|
|
484
|
+
</ListItemContent>
|
|
485
|
+
</ListItemLeading>
|
|
486
|
+
<ListItemTrailing>
|
|
487
|
+
<ListItemContent>
|
|
488
|
+
<ListItemTitle>1,234,567,891,234.56</ListItemTitle>
|
|
489
|
+
<ListItemDescription>USD</ListItemDescription>
|
|
490
|
+
</ListItemContent>
|
|
491
|
+
</ListItemTrailing>
|
|
492
|
+
</ListItem>
|
|
493
|
+
</Box>
|
|
494
|
+
),
|
|
495
|
+
};
|
|
496
|
+
|
|
405
497
|
export const CompositionShowcase: Story = {
|
|
406
498
|
render: () => (
|
|
407
499
|
<Box lx={{ flexDirection: 'column', maxWidth: 's320', gap: 's8' }}>
|