@ledgerhq/lumen-ui-rnative 0.1.36 → 0.1.37
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/Animations/Pulse/Pulse.mdx +1 -1
- package/dist/module/lib/Animations/Spin/Spin.mdx +1 -1
- package/dist/module/lib/Components/AddressInput/AddressInput.mdx +1 -1
- package/dist/module/lib/Components/AmountDisplay/AmountDisplay.js +68 -39
- package/dist/module/lib/Components/AmountDisplay/AmountDisplay.js.map +1 -1
- package/dist/module/lib/Components/AmountDisplay/AmountDisplay.mdx +7 -1
- package/dist/module/lib/Components/AmountDisplay/AmountDisplay.stories.js +24 -0
- package/dist/module/lib/Components/AmountDisplay/AmountDisplay.stories.js.map +1 -1
- package/dist/module/lib/Components/AmountDisplay/types.js.map +1 -1
- package/dist/module/lib/Components/AmountInput/AmountInput.mdx +1 -1
- package/dist/module/lib/Components/Avatar/Avatar.mdx +1 -1
- package/dist/module/lib/Components/Banner/Banner.mdx +1 -1
- package/dist/module/lib/Components/BottomSheet/BottomSheet.mdx +1 -1
- package/dist/module/lib/Components/Button/Button.mdx +1 -1
- package/dist/module/lib/Components/Card/Card.stories.js +4 -9
- package/dist/module/lib/Components/Card/Card.stories.js.map +1 -1
- package/dist/module/lib/Components/CardButton/CardButton.mdx +1 -1
- package/dist/module/lib/Components/Checkbox/Checkbox.mdx +1 -1
- package/dist/module/lib/Components/Divider/Divider.mdx +1 -1
- package/dist/module/lib/Components/DotIcon/DotIcon.js +44 -23
- package/dist/module/lib/Components/DotIcon/DotIcon.js.map +1 -1
- package/dist/module/lib/Components/DotIcon/DotIcon.mdx +92 -0
- package/dist/module/lib/Components/DotIcon/DotIcon.stories.js +47 -0
- package/dist/module/lib/Components/DotIcon/DotIcon.stories.js.map +1 -1
- package/dist/module/lib/Components/DotSymbol/DotSymbol.js +52 -30
- package/dist/module/lib/Components/DotSymbol/DotSymbol.js.map +1 -1
- package/dist/module/lib/Components/DotSymbol/DotSymbol.mdx +79 -2
- package/dist/module/lib/Components/DotSymbol/DotSymbol.stories.js +41 -0
- package/dist/module/lib/Components/DotSymbol/DotSymbol.stories.js.map +1 -1
- package/dist/module/lib/Components/IconButton/IconButton.mdx +1 -1
- package/dist/module/lib/Components/InteractiveIcon/InteractiveIcon.mdx +1 -1
- package/dist/module/lib/Components/Link/Link.mdx +1 -1
- package/dist/module/lib/Components/MediaBanner/MediaBanner.mdx +1 -1
- package/dist/module/lib/Components/MediaButton/MediaButton.js +17 -17
- package/dist/module/lib/Components/MediaButton/MediaButton.js.map +1 -1
- package/dist/module/lib/Components/MediaButton/MediaButton.mdx +3 -3
- package/dist/module/lib/Components/MediaButton/MediaButton.stories.js +17 -17
- package/dist/module/lib/Components/MediaButton/MediaButton.stories.js.map +1 -1
- package/dist/module/lib/Components/MediaButton/MediaButton.test.js +4 -4
- package/dist/module/lib/Components/MediaButton/MediaButton.test.js.map +1 -1
- package/dist/module/lib/Components/MediaImage/MediaImage.js +20 -4
- package/dist/module/lib/Components/MediaImage/MediaImage.js.map +1 -1
- package/dist/module/lib/Components/MediaImage/MediaImage.stories.js +35 -0
- package/dist/module/lib/Components/MediaImage/MediaImage.stories.js.map +1 -1
- package/dist/module/lib/Components/NavBar/CoinCapsule.js +2 -2
- package/dist/module/lib/Components/NavBar/CoinCapsule.js.map +1 -1
- package/dist/module/lib/Components/NavBar/NavBar.js +2 -2
- package/dist/module/lib/Components/NavBar/NavBar.js.map +1 -1
- package/dist/module/lib/Components/NavBar/NavBar.mdx +2 -2
- package/dist/module/lib/Components/NavBar/NavBar.stories.js +1 -1
- package/dist/module/lib/Components/NavBar/NavBar.stories.js.map +1 -1
- package/dist/module/lib/Components/NavBar/NavBar.test.js +3 -3
- package/dist/module/lib/Components/NavBar/NavBar.test.js.map +1 -1
- package/dist/module/lib/Components/OptionList/OptionList.stories.js +4 -4
- package/dist/module/lib/Components/OptionList/OptionList.stories.js.map +1 -1
- package/dist/module/lib/Components/PageIndicator/PageIndicator.js +13 -8
- package/dist/module/lib/Components/PageIndicator/PageIndicator.js.map +1 -1
- package/dist/module/lib/Components/PageIndicator/PageIndicator.test.js +58 -0
- package/dist/module/lib/Components/PageIndicator/PageIndicator.test.js.map +1 -1
- package/dist/module/lib/Components/SearchInput/SearchInput.mdx +1 -1
- package/dist/module/lib/Components/SegmentedControl/SegmentedControl.mdx +1 -1
- package/dist/module/lib/Components/Select/Select.mdx +1 -1
- package/dist/module/lib/Components/Spinner/Spinner.mdx +1 -1
- package/dist/module/lib/Components/Spot/Spot.mdx +1 -1
- package/dist/module/lib/Components/Stepper/Stepper.mdx +1 -1
- package/dist/module/lib/Components/Subheader/Subheader.mdx +1 -1
- package/dist/module/lib/Components/Switch/Switch.mdx +1 -1
- package/dist/module/lib/Components/TabBar/TabBar.mdx +1 -1
- package/dist/module/lib/Components/TextInput/TextInput.mdx +1 -1
- package/dist/module/lib/Components/Tile/Tile.mdx +1 -1
- package/dist/module/lib/Components/Tooltip/Tooltip.mdx +1 -1
- package/dist/typescript/src/lib/Components/AmountDisplay/AmountDisplay.d.ts +1 -1
- package/dist/typescript/src/lib/Components/AmountDisplay/AmountDisplay.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/AmountDisplay/index.d.ts +1 -1
- package/dist/typescript/src/lib/Components/AmountDisplay/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/AmountDisplay/types.d.ts +10 -3
- package/dist/typescript/src/lib/Components/AmountDisplay/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/DotIcon/DotIcon.d.ts +1 -1
- package/dist/typescript/src/lib/Components/DotIcon/DotIcon.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/DotIcon/types.d.ts +6 -0
- package/dist/typescript/src/lib/Components/DotIcon/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/DotSymbol/DotSymbol.d.ts +1 -1
- package/dist/typescript/src/lib/Components/DotSymbol/DotSymbol.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/DotSymbol/types.d.ts +6 -0
- package/dist/typescript/src/lib/Components/DotSymbol/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/MediaButton/MediaButton.d.ts +3 -3
- package/dist/typescript/src/lib/Components/MediaButton/MediaButton.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/MediaButton/types.d.ts +6 -6
- package/dist/typescript/src/lib/Components/MediaButton/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/MediaImage/MediaImage.d.ts +1 -1
- package/dist/typescript/src/lib/Components/MediaImage/MediaImage.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/MediaImage/types.d.ts +6 -0
- package/dist/typescript/src/lib/Components/MediaImage/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/NavBar/CoinCapsule.d.ts +1 -1
- package/dist/typescript/src/lib/Components/NavBar/CoinCapsule.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/NavBar/NavBar.d.ts +1 -1
- package/dist/typescript/src/lib/Components/NavBar/NavBar.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/NavBar/types.d.ts +3 -3
- package/dist/typescript/src/lib/Components/NavBar/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/PageIndicator/PageIndicator.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/lib/Animations/Pulse/Pulse.mdx +1 -1
- package/src/lib/Animations/Spin/Spin.mdx +1 -1
- package/src/lib/Components/AddressInput/AddressInput.mdx +1 -1
- package/src/lib/Components/AmountDisplay/AmountDisplay.mdx +7 -1
- package/src/lib/Components/AmountDisplay/AmountDisplay.stories.tsx +18 -0
- package/src/lib/Components/AmountDisplay/AmountDisplay.tsx +71 -40
- package/src/lib/Components/AmountDisplay/index.ts +5 -1
- package/src/lib/Components/AmountDisplay/types.ts +12 -3
- package/src/lib/Components/AmountInput/AmountInput.mdx +1 -1
- package/src/lib/Components/Avatar/Avatar.mdx +1 -1
- package/src/lib/Components/Banner/Banner.mdx +1 -1
- package/src/lib/Components/BottomSheet/BottomSheet.mdx +1 -1
- package/src/lib/Components/Button/Button.mdx +1 -1
- package/src/lib/Components/Card/Card.stories.tsx +1 -3
- package/src/lib/Components/CardButton/CardButton.mdx +1 -1
- package/src/lib/Components/Checkbox/Checkbox.mdx +1 -1
- package/src/lib/Components/Divider/Divider.mdx +1 -1
- package/src/lib/Components/DotIcon/DotIcon.mdx +92 -0
- package/src/lib/Components/DotIcon/DotIcon.stories.tsx +35 -0
- package/src/lib/Components/DotIcon/DotIcon.tsx +31 -14
- package/src/lib/Components/DotIcon/types.ts +6 -0
- package/src/lib/Components/DotSymbol/DotSymbol.mdx +79 -2
- package/src/lib/Components/DotSymbol/DotSymbol.stories.tsx +17 -0
- package/src/lib/Components/DotSymbol/DotSymbol.tsx +42 -24
- package/src/lib/Components/DotSymbol/types.ts +6 -0
- package/src/lib/Components/IconButton/IconButton.mdx +1 -1
- package/src/lib/Components/InteractiveIcon/InteractiveIcon.mdx +1 -1
- package/src/lib/Components/Link/Link.mdx +1 -1
- package/src/lib/Components/MediaBanner/MediaBanner.mdx +1 -1
- package/src/lib/Components/MediaButton/MediaButton.mdx +3 -3
- package/src/lib/Components/MediaButton/MediaButton.stories.tsx +29 -15
- package/src/lib/Components/MediaButton/MediaButton.test.tsx +4 -4
- package/src/lib/Components/MediaButton/MediaButton.tsx +33 -20
- package/src/lib/Components/MediaButton/types.ts +6 -6
- package/src/lib/Components/MediaImage/MediaImage.stories.tsx +18 -0
- package/src/lib/Components/MediaImage/MediaImage.tsx +12 -2
- package/src/lib/Components/MediaImage/types.ts +6 -0
- package/src/lib/Components/NavBar/CoinCapsule.tsx +2 -2
- package/src/lib/Components/NavBar/NavBar.mdx +2 -2
- package/src/lib/Components/NavBar/NavBar.stories.tsx +3 -1
- package/src/lib/Components/NavBar/NavBar.test.tsx +3 -3
- package/src/lib/Components/NavBar/NavBar.tsx +2 -2
- package/src/lib/Components/NavBar/types.ts +3 -3
- package/src/lib/Components/OptionList/OptionList.stories.tsx +4 -4
- package/src/lib/Components/PageIndicator/PageIndicator.test.tsx +78 -0
- package/src/lib/Components/PageIndicator/PageIndicator.tsx +15 -7
- package/src/lib/Components/SearchInput/SearchInput.mdx +1 -1
- package/src/lib/Components/SegmentedControl/SegmentedControl.mdx +1 -1
- package/src/lib/Components/Select/Select.mdx +1 -1
- package/src/lib/Components/Spinner/Spinner.mdx +1 -1
- package/src/lib/Components/Spot/Spot.mdx +1 -1
- package/src/lib/Components/Stepper/Stepper.mdx +1 -1
- package/src/lib/Components/Subheader/Subheader.mdx +1 -1
- package/src/lib/Components/Switch/Switch.mdx +1 -1
- package/src/lib/Components/TabBar/TabBar.mdx +1 -1
- package/src/lib/Components/TextInput/TextInput.mdx +1 -1
- package/src/lib/Components/Tile/Tile.mdx +1 -1
- package/src/lib/Components/Tooltip/Tooltip.mdx +1 -1
|
@@ -8,6 +8,7 @@ import Animated, {
|
|
|
8
8
|
withTiming,
|
|
9
9
|
} from 'react-native-reanimated';
|
|
10
10
|
import { useCommonTranslation } from '../../../i18n';
|
|
11
|
+
import type { LumenTypographyTokenName } from '../../../styles';
|
|
11
12
|
import { useStyleSheet } from '../../../styles';
|
|
12
13
|
import { Pulse } from '../../Animations/Pulse';
|
|
13
14
|
import { useTimingConfig } from '../../Animations/useTimingConfig';
|
|
@@ -15,38 +16,66 @@ import { RuntimeConstants } from '../../utils';
|
|
|
15
16
|
import { Box } from '../Utility';
|
|
16
17
|
import type {
|
|
17
18
|
AmountDisplayProps,
|
|
19
|
+
AmountDisplaySize,
|
|
18
20
|
DigitStripListProps,
|
|
19
21
|
DigitStripProps,
|
|
22
|
+
DigitWidths,
|
|
20
23
|
} from './types';
|
|
21
24
|
import { DIGITS } from './types';
|
|
22
25
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
const TYPOGRAPHY_WIDTHS = {
|
|
27
|
+
heading1SemiBold: {
|
|
28
|
+
0: 25,
|
|
29
|
+
1: 15.5,
|
|
30
|
+
2: 23.5,
|
|
31
|
+
3: 24.5,
|
|
32
|
+
4: 25.5,
|
|
33
|
+
5: 23.5,
|
|
34
|
+
6: 25,
|
|
35
|
+
7: 22,
|
|
36
|
+
8: 24.5,
|
|
37
|
+
9: 24.5,
|
|
38
|
+
},
|
|
39
|
+
heading2SemiBold: {
|
|
40
|
+
0: 17.5,
|
|
41
|
+
1: 11,
|
|
42
|
+
2: 16.5,
|
|
43
|
+
3: 17,
|
|
44
|
+
4: 18,
|
|
45
|
+
5: 16,
|
|
46
|
+
6: 17.5,
|
|
47
|
+
7: 15,
|
|
48
|
+
8: 17,
|
|
49
|
+
9: 17,
|
|
50
|
+
},
|
|
51
|
+
heading4SemiBold: {
|
|
52
|
+
0: 13,
|
|
53
|
+
1: 8.5,
|
|
54
|
+
2: 12.5,
|
|
55
|
+
3: 12.5,
|
|
56
|
+
4: 13,
|
|
57
|
+
5: 12,
|
|
58
|
+
6: 12.5,
|
|
59
|
+
7: 11.5,
|
|
60
|
+
8: 12.5,
|
|
61
|
+
9: 12.5,
|
|
62
|
+
},
|
|
63
|
+
} as const satisfies Partial<Record<LumenTypographyTokenName, DigitWidths>>;
|
|
64
|
+
|
|
65
|
+
type MeasuredTypography = keyof typeof TYPOGRAPHY_WIDTHS;
|
|
66
|
+
|
|
67
|
+
type SizeTypographyConfig = {
|
|
68
|
+
integer: MeasuredTypography;
|
|
69
|
+
decimal: MeasuredTypography;
|
|
34
70
|
};
|
|
35
71
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
2: 16.5,
|
|
40
|
-
3: 17,
|
|
41
|
-
4: 18,
|
|
42
|
-
5: 16,
|
|
43
|
-
6: 17.5,
|
|
44
|
-
7: 15,
|
|
45
|
-
8: 17,
|
|
46
|
-
9: 17,
|
|
72
|
+
const SIZE_TYPOGRAPHY: Record<AmountDisplaySize, SizeTypographyConfig> = {
|
|
73
|
+
md: { integer: 'heading1SemiBold', decimal: 'heading2SemiBold' },
|
|
74
|
+
sm: { integer: 'heading2SemiBold', decimal: 'heading4SemiBold' },
|
|
47
75
|
};
|
|
48
76
|
|
|
49
|
-
const useStyles = () => {
|
|
77
|
+
const useStyles = (size: AmountDisplaySize) => {
|
|
78
|
+
const typography = SIZE_TYPOGRAPHY[size];
|
|
50
79
|
return useStyleSheet(
|
|
51
80
|
(t) => ({
|
|
52
81
|
container: {
|
|
@@ -61,19 +90,19 @@ const useStyles = () => {
|
|
|
61
90
|
paddingBottom: t.spacings.s2,
|
|
62
91
|
},
|
|
63
92
|
integerText: {
|
|
64
|
-
...t.typographies.
|
|
93
|
+
...t.typographies[typography.integer],
|
|
65
94
|
color: t.colors.text.base,
|
|
66
95
|
},
|
|
67
96
|
decimalText: {
|
|
68
|
-
...t.typographies.
|
|
97
|
+
...t.typographies[typography.decimal],
|
|
69
98
|
color: t.colors.text.muted,
|
|
70
99
|
},
|
|
71
100
|
currencyStartText: {
|
|
72
|
-
...t.typographies.
|
|
101
|
+
...t.typographies[typography.integer],
|
|
73
102
|
color: t.colors.text.base,
|
|
74
103
|
},
|
|
75
104
|
currencyEndText: {
|
|
76
|
-
...t.typographies.
|
|
105
|
+
...t.typographies[typography.decimal],
|
|
77
106
|
color: t.colors.text.muted,
|
|
78
107
|
},
|
|
79
108
|
spacingStart: {
|
|
@@ -83,7 +112,7 @@ const useStyles = () => {
|
|
|
83
112
|
marginLeft: t.spacings.s4,
|
|
84
113
|
},
|
|
85
114
|
}),
|
|
86
|
-
[],
|
|
115
|
+
[typography],
|
|
87
116
|
);
|
|
88
117
|
};
|
|
89
118
|
|
|
@@ -136,10 +165,8 @@ const useAnimatedDigitStrip = ({
|
|
|
136
165
|
};
|
|
137
166
|
|
|
138
167
|
const DigitStrip = memo(
|
|
139
|
-
({ value, textStyle, animate,
|
|
140
|
-
const targetWidth =
|
|
141
|
-
type === 'integer' ? INTEGER_DIGIT_WIDTHS : DECIMAL_DIGIT_WIDTHS
|
|
142
|
-
)[value];
|
|
168
|
+
({ value, textStyle, animate, widths }: DigitStripProps) => {
|
|
169
|
+
const targetWidth = widths[value];
|
|
143
170
|
const lineHeight = textStyle.lineHeight;
|
|
144
171
|
const width = useSharedValue<number>(targetWidth);
|
|
145
172
|
const { animatedStyle } = useAnimatedDigitStrip({
|
|
@@ -176,7 +203,7 @@ const DigitStrip = memo(
|
|
|
176
203
|
DigitStrip.displayName = 'DigitStrip';
|
|
177
204
|
|
|
178
205
|
const DigitStripList = memo(
|
|
179
|
-
({ items, textStyle, animate,
|
|
206
|
+
({ items, textStyle, animate, widths }: DigitStripListProps) => {
|
|
180
207
|
return items.map((item, index) => {
|
|
181
208
|
const key = items.length - index;
|
|
182
209
|
if (item.type === 'separator') {
|
|
@@ -192,7 +219,7 @@ const DigitStripList = memo(
|
|
|
192
219
|
value={Number(item.value) as DigitStripProps['value']}
|
|
193
220
|
animate={animate}
|
|
194
221
|
textStyle={textStyle}
|
|
195
|
-
|
|
222
|
+
widths={widths}
|
|
196
223
|
/>
|
|
197
224
|
);
|
|
198
225
|
});
|
|
@@ -233,15 +260,16 @@ DigitStripList.displayName = 'DigitStripList';
|
|
|
233
260
|
* <AmountDisplay value={1234.56} formatter={usdFormatter} hidden={true} />
|
|
234
261
|
* ```
|
|
235
262
|
*/
|
|
236
|
-
export
|
|
263
|
+
export function AmountDisplay({
|
|
237
264
|
value,
|
|
238
265
|
formatter,
|
|
239
266
|
hidden = false,
|
|
240
267
|
loading = false,
|
|
241
268
|
animate = true,
|
|
269
|
+
size = 'md',
|
|
242
270
|
...props
|
|
243
|
-
}: AmountDisplayProps)
|
|
244
|
-
const styles = useStyles();
|
|
271
|
+
}: AmountDisplayProps) {
|
|
272
|
+
const styles = useStyles(size);
|
|
245
273
|
const { t } = useCommonTranslation();
|
|
246
274
|
const parts = formatter(value);
|
|
247
275
|
const splitDigits = useSplitText(parts);
|
|
@@ -250,6 +278,9 @@ export const AmountDisplay = ({
|
|
|
250
278
|
hidden,
|
|
251
279
|
t('components.amountDisplay.amountHiddenAriaLabel'),
|
|
252
280
|
);
|
|
281
|
+
const typography = SIZE_TYPOGRAPHY[size];
|
|
282
|
+
const integerWidths = TYPOGRAPHY_WIDTHS[typography.integer];
|
|
283
|
+
const decimalWidths = TYPOGRAPHY_WIDTHS[typography.decimal];
|
|
253
284
|
|
|
254
285
|
return (
|
|
255
286
|
<Box
|
|
@@ -281,7 +312,7 @@ export const AmountDisplay = ({
|
|
|
281
312
|
items={splitDigits.integerPart}
|
|
282
313
|
textStyle={styles.integerText}
|
|
283
314
|
animate={animate}
|
|
284
|
-
|
|
315
|
+
widths={integerWidths}
|
|
285
316
|
/>
|
|
286
317
|
)}
|
|
287
318
|
</View>
|
|
@@ -296,7 +327,7 @@ export const AmountDisplay = ({
|
|
|
296
327
|
items={splitDigits.decimalPart}
|
|
297
328
|
textStyle={styles.decimalText}
|
|
298
329
|
animate={animate}
|
|
299
|
-
|
|
330
|
+
widths={decimalWidths}
|
|
300
331
|
/>
|
|
301
332
|
)}
|
|
302
333
|
{parts.currencyPosition === 'end' && (
|
|
@@ -312,4 +343,4 @@ export const AmountDisplay = ({
|
|
|
312
343
|
</Pulse>
|
|
313
344
|
</Box>
|
|
314
345
|
);
|
|
315
|
-
}
|
|
346
|
+
}
|
|
@@ -6,13 +6,17 @@ export type { FormattedValue };
|
|
|
6
6
|
|
|
7
7
|
export const DIGITS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] as const;
|
|
8
8
|
|
|
9
|
-
type
|
|
9
|
+
type Digit = (typeof DIGITS)[number];
|
|
10
|
+
|
|
11
|
+
export type AmountDisplaySize = 'sm' | 'md';
|
|
12
|
+
|
|
13
|
+
export type DigitWidths = Record<Digit, number>;
|
|
10
14
|
|
|
11
15
|
export type DigitStripProps = {
|
|
12
|
-
value:
|
|
16
|
+
value: Digit;
|
|
13
17
|
animate: boolean;
|
|
14
18
|
textStyle: TextStyle & { lineHeight: number };
|
|
15
|
-
|
|
19
|
+
widths: DigitWidths;
|
|
16
20
|
};
|
|
17
21
|
|
|
18
22
|
export type DigitStripListProps = {
|
|
@@ -48,4 +52,9 @@ export type AmountDisplayProps = ViewProps & {
|
|
|
48
52
|
* @default true
|
|
49
53
|
*/
|
|
50
54
|
animate?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* The size variant of the amount display.
|
|
57
|
+
* @default 'md'
|
|
58
|
+
*/
|
|
59
|
+
size?: AmountDisplaySize;
|
|
51
60
|
} & Omit<StyledViewProps, 'children'>;
|
|
@@ -196,9 +196,7 @@ export const StatesShowcase: Story = {
|
|
|
196
196
|
<Card {...args} lx={{ width: 's320' }} disabled>
|
|
197
197
|
<CardHeader>
|
|
198
198
|
<CardLeading>
|
|
199
|
-
<
|
|
200
|
-
<CryptoIcon ledgerId='bitcoin' ticker='BTC' size={48} />
|
|
201
|
-
</Box>
|
|
199
|
+
<CryptoIcon ledgerId='bitcoin' ticker='BTC' size={48} />
|
|
202
200
|
<CardContent>
|
|
203
201
|
<CardContentTitle>Disabled</CardContentTitle>
|
|
204
202
|
<CardContentDescription>Non-interactive</CardContentDescription>
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks';
|
|
2
2
|
import * as DotIconStories from './DotIcon.stories';
|
|
3
|
+
import { CustomTabs, Tab } from '../../../../.storybook/components';
|
|
3
4
|
|
|
4
5
|
<Meta title='Communication/DotIcon' of={DotIconStories} />
|
|
5
6
|
|
|
6
7
|
# DotIcon
|
|
7
8
|
|
|
9
|
+
<CustomTabs>
|
|
10
|
+
<Tab label="Overview">
|
|
11
|
+
|
|
8
12
|
## Introduction
|
|
9
13
|
|
|
10
14
|
DotIcon positions a small icon indicator at a configurable corner of a child element such as MediaImage or Spot. The dot background uses a semantic color (`success`, `muted`, or `error`) to convey meaning at a glance.
|
|
15
|
+
|
|
11
16
|
> View in [Figma](https://www.figma.com/design/zSkvGGiqcnhywp2l3HTHxA/1.-Symbol-Library?node-id=6159-1866).
|
|
12
17
|
|
|
13
18
|
## Anatomy
|
|
@@ -50,7 +55,94 @@ The dot size is driven by the parent MediaImage or Spot size via the mapping hel
|
|
|
50
55
|
|
|
51
56
|
<Canvas of={DotIconStories.SizeShowcase} />
|
|
52
57
|
|
|
58
|
+
### Disabled
|
|
59
|
+
|
|
60
|
+
Only set `disabled` on `DotIcon`. The state is propagated to the child via context. Passing it to both stacks the opacity overlay.
|
|
61
|
+
|
|
62
|
+
<Canvas of={DotIconStories.DisabledShowcase} />
|
|
63
|
+
|
|
53
64
|
## Accessibility
|
|
54
65
|
|
|
55
66
|
- The icon is purely decorative; the child element should carry its own accessibility label.
|
|
56
67
|
- Pair semantic appearances with meaningful icons so the state can be understood without relying on color alone.
|
|
68
|
+
|
|
69
|
+
</Tab>
|
|
70
|
+
<Tab label="Implementation">
|
|
71
|
+
|
|
72
|
+
## Setup
|
|
73
|
+
|
|
74
|
+
Install and set up the library with our [Setup Guide →](?path=/docs/getting-started-setup--docs).
|
|
75
|
+
|
|
76
|
+
### Basic Usage
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import { DotIcon, MediaImage } from '@ledgerhq/lumen-ui-rnative';
|
|
80
|
+
import { ArrowDown } from '@ledgerhq/lumen-ui-rnative/symbols';
|
|
81
|
+
|
|
82
|
+
function MyComponent() {
|
|
83
|
+
return (
|
|
84
|
+
<DotIcon appearance='success' icon={ArrowDown}>
|
|
85
|
+
<MediaImage src='https://example.com/ada.png' alt='Cardano' size={48} />
|
|
86
|
+
</DotIcon>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Pin Placement
|
|
92
|
+
|
|
93
|
+
Position the dot at any of the four corners of the child:
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
<DotIcon appearance='success' icon={ArrowDown} pin='top-end'>
|
|
97
|
+
<MediaImage src='https://example.com/ada.png' alt='Cardano' size={48} />
|
|
98
|
+
</DotIcon>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Shapes
|
|
102
|
+
|
|
103
|
+
Use `shape='square'` to match a square child element:
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
<DotIcon appearance='muted' icon={ArrowDown} shape='square'>
|
|
107
|
+
<MediaImage src='https://example.com/ada.png' alt='Cardano' size={48} shape='square' />
|
|
108
|
+
</DotIcon>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Appearances
|
|
112
|
+
|
|
113
|
+
Pick a semantic color via `appearance`:
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
<DotIcon appearance='success' icon={ArrowDown}>...</DotIcon>
|
|
117
|
+
<DotIcon appearance='muted' icon={ArrowUp}>...</DotIcon>
|
|
118
|
+
<DotIcon appearance='error' icon={Close}>...</DotIcon>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Sizing
|
|
122
|
+
|
|
123
|
+
The dot size is driven by the parent's size via the mapping helpers:
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
import { DotIcon, mediaImageDotIconSizeMap, MediaImage } from '@ledgerhq/lumen-ui-rnative';
|
|
127
|
+
|
|
128
|
+
<DotIcon
|
|
129
|
+
appearance='success'
|
|
130
|
+
icon={ArrowDown}
|
|
131
|
+
size={mediaImageDotIconSizeMap[48]}
|
|
132
|
+
>
|
|
133
|
+
<MediaImage src='https://example.com/ada.png' alt='Cardano' size={48} />
|
|
134
|
+
</DotIcon>;
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Disabled State
|
|
138
|
+
|
|
139
|
+
Only set `disabled` on `DotIcon`. The state is propagated to the child via context. Passing it to both stacks the opacity overlay.
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
<DotIcon appearance='success' icon={ArrowDown} disabled>
|
|
143
|
+
<MediaImage src='https://example.com/ada.png' alt='Cardano' size={48} />
|
|
144
|
+
</DotIcon>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
</Tab>
|
|
148
|
+
</CustomTabs>
|
|
@@ -113,6 +113,41 @@ export const AppearanceShowcase: Story = {
|
|
|
113
113
|
),
|
|
114
114
|
};
|
|
115
115
|
|
|
116
|
+
export const DisabledShowcase: Story = {
|
|
117
|
+
args: { appearance: 'success', icon: ArrowDown },
|
|
118
|
+
render: () => (
|
|
119
|
+
<Box lx={{ flexDirection: 'row', alignItems: 'center', gap: 's32' }}>
|
|
120
|
+
<DotIcon
|
|
121
|
+
appearance='success'
|
|
122
|
+
icon={ArrowDown}
|
|
123
|
+
size={mediaImageDotIconSizeMap[48]}
|
|
124
|
+
pin='bottom-end'
|
|
125
|
+
disabled
|
|
126
|
+
>
|
|
127
|
+
<MediaImage src={parentSrc} size={48} shape='circle' />
|
|
128
|
+
</DotIcon>
|
|
129
|
+
<DotIcon
|
|
130
|
+
appearance='muted'
|
|
131
|
+
icon={ArrowUp}
|
|
132
|
+
size={mediaImageDotIconSizeMap[48]}
|
|
133
|
+
pin='bottom-end'
|
|
134
|
+
disabled
|
|
135
|
+
>
|
|
136
|
+
<MediaImage src={parentSrc} size={48} shape='circle' />
|
|
137
|
+
</DotIcon>
|
|
138
|
+
<DotIcon
|
|
139
|
+
appearance='error'
|
|
140
|
+
icon={Close}
|
|
141
|
+
size={mediaImageDotIconSizeMap[48]}
|
|
142
|
+
pin='bottom-end'
|
|
143
|
+
disabled
|
|
144
|
+
>
|
|
145
|
+
<MediaImage src={parentSrc} size={48} shape='circle' />
|
|
146
|
+
</DotIcon>
|
|
147
|
+
</Box>
|
|
148
|
+
),
|
|
149
|
+
};
|
|
150
|
+
|
|
116
151
|
export const SizeShowcase: Story = {
|
|
117
152
|
args: { appearance: 'muted', icon: Link },
|
|
118
153
|
render: () => (
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
DisabledProvider,
|
|
3
|
+
useDisabledContext,
|
|
4
|
+
} from '@ledgerhq/lumen-utils-shared';
|
|
2
5
|
import { useStyleSheet } from '../../../styles';
|
|
3
6
|
import type { IconSize } from '../Icon';
|
|
4
7
|
import { Box } from '../Utility';
|
|
@@ -63,11 +66,13 @@ const useStyles = ({
|
|
|
63
66
|
shape,
|
|
64
67
|
pin,
|
|
65
68
|
appearance,
|
|
69
|
+
disabled,
|
|
66
70
|
}: {
|
|
67
71
|
size: DotIconSize;
|
|
68
72
|
shape: 'square' | 'circle';
|
|
69
73
|
pin: DotIconPin;
|
|
70
74
|
appearance: DotIconAppearance;
|
|
75
|
+
disabled: boolean;
|
|
71
76
|
}) => {
|
|
72
77
|
return useStyleSheet(
|
|
73
78
|
(t) => {
|
|
@@ -77,6 +82,10 @@ const useStyles = ({
|
|
|
77
82
|
const pinOffset = getPinOffset(pin);
|
|
78
83
|
|
|
79
84
|
return {
|
|
85
|
+
root: {
|
|
86
|
+
position: 'relative',
|
|
87
|
+
...(disabled && { opacity: 0.3 }),
|
|
88
|
+
},
|
|
80
89
|
dot: {
|
|
81
90
|
position: 'absolute',
|
|
82
91
|
zIndex: 10,
|
|
@@ -96,7 +105,7 @@ const useStyles = ({
|
|
|
96
105
|
},
|
|
97
106
|
};
|
|
98
107
|
},
|
|
99
|
-
[size, shape, pin, appearance],
|
|
108
|
+
[size, shape, pin, appearance, disabled],
|
|
100
109
|
);
|
|
101
110
|
};
|
|
102
111
|
|
|
@@ -119,27 +128,35 @@ export const DotIcon = ({
|
|
|
119
128
|
pin = 'bottom-end',
|
|
120
129
|
size = 20,
|
|
121
130
|
shape = 'circle',
|
|
131
|
+
disabled: disabledProp = false,
|
|
122
132
|
lx = {},
|
|
123
133
|
style,
|
|
124
134
|
ref,
|
|
125
135
|
...rest
|
|
126
136
|
}: DotIconProps) => {
|
|
127
|
-
const
|
|
137
|
+
const disabled = useDisabledContext({
|
|
138
|
+
consumerName: 'DotIcon',
|
|
139
|
+
mergeWith: { disabled: disabledProp },
|
|
140
|
+
});
|
|
141
|
+
const styles = useStyles({ size, shape, pin, appearance, disabled });
|
|
128
142
|
|
|
129
143
|
return (
|
|
130
|
-
<
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
<Box
|
|
139
|
-
|
|
144
|
+
<DisabledProvider value={{ disabled: false }}>
|
|
145
|
+
<Box
|
|
146
|
+
ref={ref}
|
|
147
|
+
lx={lx}
|
|
148
|
+
style={[styles.root, style]}
|
|
149
|
+
accessibilityState={{ disabled }}
|
|
150
|
+
{...rest}
|
|
151
|
+
>
|
|
152
|
+
<Box style={{ alignSelf: 'flex-start', position: 'relative' }}>
|
|
153
|
+
{children}
|
|
154
|
+
<Box testID='dot-icon-dot' style={styles.dot}>
|
|
155
|
+
<Icon size={dotIconSizeMap[size]} style={styles.icon} />
|
|
156
|
+
</Box>
|
|
140
157
|
</Box>
|
|
141
158
|
</Box>
|
|
142
|
-
</
|
|
159
|
+
</DisabledProvider>
|
|
143
160
|
);
|
|
144
161
|
};
|
|
145
162
|
|
|
@@ -37,6 +37,12 @@ export type DotIconProps = {
|
|
|
37
37
|
* @default 'circle'
|
|
38
38
|
*/
|
|
39
39
|
shape?: 'square' | 'circle';
|
|
40
|
+
/**
|
|
41
|
+
* Shows a disabled appearance.
|
|
42
|
+
* @optional
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
disabled?: boolean;
|
|
40
46
|
/**
|
|
41
47
|
* The wrapped component (e.g. MediaImage or Spot).
|
|
42
48
|
*/
|