@ledgerhq/lumen-ui-rnative 0.1.19 → 0.1.21
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/AmountInput/AmountInput.js +2 -0
- package/dist/module/lib/Components/AmountInput/AmountInput.js.map +1 -1
- package/dist/module/lib/Components/Banner/Banner.js +13 -7
- package/dist/module/lib/Components/Banner/Banner.js.map +1 -1
- package/dist/module/lib/Components/BaseInput/BaseInput.js +7 -6
- package/dist/module/lib/Components/BaseInput/BaseInput.js.map +1 -1
- package/dist/module/lib/Components/BottomSheet/BottomSheet.mdx +4 -4
- package/dist/module/lib/Components/BottomSheet/BottomSheet.stories.js +10 -10
- package/dist/module/lib/Components/BottomSheet/BottomSheet.stories.js.map +1 -1
- package/dist/module/lib/Components/BottomSheet/BottomSheetHeader.js +12 -12
- package/dist/module/lib/Components/BottomSheet/BottomSheetHeader.js.map +1 -1
- package/dist/module/lib/Components/Button/BaseButton.js +3 -1
- package/dist/module/lib/Components/Button/BaseButton.js.map +1 -1
- package/dist/module/lib/Components/Card/Card.js +3 -1
- package/dist/module/lib/Components/Card/Card.js.map +1 -1
- package/dist/module/lib/Components/DotSymbol/DotSymbol.js +141 -0
- package/dist/module/lib/Components/DotSymbol/DotSymbol.js.map +1 -0
- package/dist/module/lib/Components/DotSymbol/DotSymbol.mdx +54 -0
- package/dist/module/lib/Components/DotSymbol/DotSymbol.stories.js +301 -0
- package/dist/module/lib/Components/DotSymbol/DotSymbol.stories.js.map +1 -0
- package/dist/module/lib/Components/DotSymbol/DotSymbol.test.js +134 -0
- package/dist/module/lib/Components/DotSymbol/DotSymbol.test.js.map +1 -0
- package/dist/module/lib/Components/DotSymbol/index.js +5 -0
- package/dist/module/lib/Components/DotSymbol/index.js.map +1 -0
- package/dist/module/lib/Components/DotSymbol/types.js +4 -0
- package/dist/module/lib/Components/DotSymbol/types.js.map +1 -0
- package/dist/module/lib/Components/ListItem/ListItem.js +2 -2
- package/dist/module/lib/Components/ListItem/ListItem.js.map +1 -1
- package/dist/module/lib/Components/MediaBanner/MediaBanner.js +1 -1
- package/dist/module/lib/Components/MediaBanner/MediaBanner.js.map +1 -1
- package/dist/module/lib/Components/MediaCard/MediaCard.js +1 -1
- package/dist/module/lib/Components/MediaCard/MediaCard.js.map +1 -1
- package/dist/module/lib/Components/MediaImage/MediaImage.js +1 -11
- package/dist/module/lib/Components/MediaImage/MediaImage.js.map +1 -1
- package/dist/module/lib/Components/MediaImage/index.js +1 -1
- package/dist/module/lib/Components/MediaImage/index.js.map +1 -1
- package/dist/module/lib/Components/NavBar/NavBar.js +27 -25
- package/dist/module/lib/Components/NavBar/NavBar.js.map +1 -1
- package/dist/module/lib/Components/NavBar/NavBar.mdx +7 -7
- package/dist/module/lib/Components/NavBar/NavBar.stories.js +6 -6
- package/dist/module/lib/Components/NavBar/NavBar.stories.js.map +1 -1
- package/dist/module/lib/Components/NavBar/NavBar.test.js +24 -24
- package/dist/module/lib/Components/NavBar/NavBar.test.js.map +1 -1
- package/dist/module/lib/Components/Select/GlobalSelectBottomSheet.js +1 -1
- package/dist/module/lib/Components/Select/GlobalSelectBottomSheet.js.map +1 -1
- package/dist/module/lib/Components/Select/Select.stories.js +1 -0
- package/dist/module/lib/Components/Select/Select.stories.js.map +1 -1
- package/dist/module/lib/Components/Spot/Spot.js +1 -0
- package/dist/module/lib/Components/Spot/Spot.js.map +1 -1
- package/dist/module/lib/Components/Stepper/Stepper.js +3 -0
- package/dist/module/lib/Components/Stepper/Stepper.js.map +1 -1
- package/dist/module/lib/Components/TabBar/TabBar.js +2 -2
- package/dist/module/lib/Components/TabBar/TabBar.js.map +1 -1
- package/dist/module/lib/Components/Tag/Tag.js +0 -2
- package/dist/module/lib/Components/Tag/Tag.js.map +1 -1
- package/dist/module/lib/Components/Tooltip/GlobalTooltipBottomSheet.js +1 -1
- package/dist/module/lib/Components/Tooltip/GlobalTooltipBottomSheet.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/typescript/src/lib/Components/AmountInput/AmountInput.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Banner/Banner.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/BottomSheet/BottomSheetHeader.d.ts +1 -1
- package/dist/typescript/src/lib/Components/BottomSheet/BottomSheetHeader.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/BottomSheet/types.d.ts +3 -2
- package/dist/typescript/src/lib/Components/BottomSheet/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Button/BaseButton.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Card/Card.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/DotSymbol/DotSymbol.d.ts +21 -0
- package/dist/typescript/src/lib/Components/DotSymbol/DotSymbol.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/DotSymbol/index.d.ts +3 -0
- package/dist/typescript/src/lib/Components/DotSymbol/index.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/DotSymbol/types.d.ts +34 -0
- package/dist/typescript/src/lib/Components/DotSymbol/types.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/MediaImage/MediaImage.d.ts +1 -2
- package/dist/typescript/src/lib/Components/MediaImage/MediaImage.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/MediaImage/index.d.ts +1 -1
- package/dist/typescript/src/lib/Components/MediaImage/index.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/Spot/Spot.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Stepper/Stepper.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Tag/Tag.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/package.json +1 -1
- package/src/lib/Components/AmountInput/AmountInput.tsx +8 -2
- package/src/lib/Components/Banner/Banner.tsx +10 -4
- package/src/lib/Components/BaseInput/BaseInput.tsx +4 -3
- package/src/lib/Components/BottomSheet/BottomSheet.mdx +4 -4
- package/src/lib/Components/BottomSheet/BottomSheet.stories.tsx +10 -10
- package/src/lib/Components/BottomSheet/BottomSheetHeader.tsx +14 -14
- package/src/lib/Components/BottomSheet/types.ts +3 -2
- package/src/lib/Components/Button/BaseButton.tsx +4 -1
- package/src/lib/Components/Card/Card.tsx +2 -0
- package/src/lib/Components/DotSymbol/DotSymbol.mdx +54 -0
- package/src/lib/Components/DotSymbol/DotSymbol.stories.tsx +191 -0
- package/src/lib/Components/DotSymbol/DotSymbol.test.tsx +119 -0
- package/src/lib/Components/DotSymbol/DotSymbol.tsx +161 -0
- package/src/lib/Components/DotSymbol/index.ts +2 -0
- package/src/lib/Components/DotSymbol/types.ts +40 -0
- package/src/lib/Components/ListItem/ListItem.tsx +4 -4
- package/src/lib/Components/MediaBanner/MediaBanner.tsx +1 -1
- package/src/lib/Components/MediaCard/MediaCard.tsx +1 -1
- package/src/lib/Components/MediaImage/MediaImage.tsx +6 -17
- package/src/lib/Components/MediaImage/index.ts +1 -1
- package/src/lib/Components/NavBar/NavBar.mdx +7 -7
- package/src/lib/Components/NavBar/NavBar.stories.tsx +6 -6
- package/src/lib/Components/NavBar/NavBar.test.tsx +25 -25
- package/src/lib/Components/NavBar/NavBar.tsx +31 -29
- package/src/lib/Components/NavBar/types.ts +3 -4
- package/src/lib/Components/Select/GlobalSelectBottomSheet.tsx +1 -1
- package/src/lib/Components/Select/Select.stories.tsx +1 -0
- package/src/lib/Components/Spot/Spot.tsx +5 -1
- package/src/lib/Components/Stepper/Stepper.tsx +15 -3
- package/src/lib/Components/TabBar/TabBar.tsx +2 -2
- package/src/lib/Components/Tag/Tag.tsx +1 -3
- package/src/lib/Components/Tooltip/GlobalTooltipBottomSheet.tsx +1 -1
- package/src/lib/Components/index.ts +1 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { Image, StyleSheet } from 'react-native';
|
|
3
|
+
import { useStyleSheet } from '../../../styles';
|
|
4
|
+
import { MediaImageSize } from '../MediaImage';
|
|
5
|
+
import { SpotSize } from '../Spot';
|
|
6
|
+
import { Box } from '../Utility';
|
|
7
|
+
import { DotSymbolPin, DotSymbolProps, DotSymbolSize } from './types';
|
|
8
|
+
|
|
9
|
+
type BorderRadiusKey = 'xs' | 'sm' | 'md' | 'lg' | 'full';
|
|
10
|
+
|
|
11
|
+
const shapeRadiusMap: Record<DotSymbolSize, BorderRadiusKey> = {
|
|
12
|
+
8: 'xs',
|
|
13
|
+
10: 'xs',
|
|
14
|
+
12: 'xs',
|
|
15
|
+
16: 'sm',
|
|
16
|
+
20: 'sm',
|
|
17
|
+
24: 'md',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const offsetBySize: Record<DotSymbolSize, number> = {
|
|
21
|
+
8: -2,
|
|
22
|
+
10: -2,
|
|
23
|
+
12: -2,
|
|
24
|
+
16: -3,
|
|
25
|
+
20: -3,
|
|
26
|
+
24: -3,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const mediaImageDotSizeMap: Record<MediaImageSize, DotSymbolSize> = {
|
|
30
|
+
12: 8,
|
|
31
|
+
16: 8,
|
|
32
|
+
20: 8,
|
|
33
|
+
24: 10,
|
|
34
|
+
32: 12,
|
|
35
|
+
40: 16,
|
|
36
|
+
48: 20,
|
|
37
|
+
56: 24,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const spotDotSizeMap: Record<SpotSize, DotSymbolSize> = {
|
|
41
|
+
32: 12,
|
|
42
|
+
40: 16,
|
|
43
|
+
48: 20,
|
|
44
|
+
56: 24,
|
|
45
|
+
72: 24,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const pinAxisMap: Record<DotSymbolPin, [vertical: string, horizontal: string]> =
|
|
49
|
+
{
|
|
50
|
+
'top-start': ['top', 'left'],
|
|
51
|
+
'top-end': ['top', 'right'],
|
|
52
|
+
'bottom-start': ['bottom', 'left'],
|
|
53
|
+
'bottom-end': ['bottom', 'right'],
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const getPinOffset = (
|
|
57
|
+
pin: DotSymbolPin,
|
|
58
|
+
size: DotSymbolSize,
|
|
59
|
+
): Record<string, number> => {
|
|
60
|
+
const [v, h] = pinAxisMap[pin];
|
|
61
|
+
const offset = offsetBySize[size];
|
|
62
|
+
return { [v]: offset, [h]: offset };
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const useStyles = ({
|
|
66
|
+
size,
|
|
67
|
+
shape,
|
|
68
|
+
pin,
|
|
69
|
+
}: {
|
|
70
|
+
size: DotSymbolSize;
|
|
71
|
+
shape: 'square' | 'circle';
|
|
72
|
+
pin: DotSymbolPin;
|
|
73
|
+
}) => {
|
|
74
|
+
return useStyleSheet(
|
|
75
|
+
(t) => {
|
|
76
|
+
const sizeValue = t.sizes[`s${size}` as keyof typeof t.sizes] as number;
|
|
77
|
+
const radius =
|
|
78
|
+
shape === 'circle'
|
|
79
|
+
? t.borderRadius.full
|
|
80
|
+
: t.borderRadius[shapeRadiusMap[size]];
|
|
81
|
+
const pinOffset = getPinOffset(pin, size);
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
dot: {
|
|
85
|
+
position: 'absolute',
|
|
86
|
+
zIndex: 10,
|
|
87
|
+
width: sizeValue,
|
|
88
|
+
height: sizeValue,
|
|
89
|
+
borderRadius: radius,
|
|
90
|
+
borderWidth: 1,
|
|
91
|
+
backgroundColor: t.colors.bg.muted,
|
|
92
|
+
borderColor: t.colors.border.baseInverted,
|
|
93
|
+
overflow: 'hidden',
|
|
94
|
+
...pinOffset,
|
|
95
|
+
},
|
|
96
|
+
image: {
|
|
97
|
+
width: '100%',
|
|
98
|
+
height: '100%',
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
[size, shape, pin],
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* A wrapper component that positions a small image indicator at a configurable
|
|
108
|
+
* corner of a child element like MediaImage or Spot.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* import { DotSymbol } from '@ledgerhq/lumen-ui-rnative';
|
|
112
|
+
*
|
|
113
|
+
* <DotSymbol src="https://example.com/eth.png" alt="Ethereum" pin="bottom-end">
|
|
114
|
+
* <MediaImage src="https://example.com/usdc.png" alt="USDC" size={48} />
|
|
115
|
+
* </DotSymbol>
|
|
116
|
+
*/
|
|
117
|
+
export const DotSymbol = ({
|
|
118
|
+
children,
|
|
119
|
+
src,
|
|
120
|
+
alt,
|
|
121
|
+
pin = 'bottom-end',
|
|
122
|
+
size = 20,
|
|
123
|
+
shape = 'circle',
|
|
124
|
+
lx = {},
|
|
125
|
+
style,
|
|
126
|
+
ref,
|
|
127
|
+
...rest
|
|
128
|
+
}: DotSymbolProps) => {
|
|
129
|
+
const styles = useStyles({ size, shape, pin });
|
|
130
|
+
const [error, setError] = useState(false);
|
|
131
|
+
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
setError(false);
|
|
134
|
+
}, [src]);
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<Box
|
|
138
|
+
ref={ref}
|
|
139
|
+
lx={lx}
|
|
140
|
+
style={StyleSheet.flatten([{ position: 'relative' }, style])}
|
|
141
|
+
accessibilityRole='image'
|
|
142
|
+
accessibilityLabel={alt}
|
|
143
|
+
{...rest}
|
|
144
|
+
>
|
|
145
|
+
{children}
|
|
146
|
+
<Box style={styles.dot}>
|
|
147
|
+
{!error && (
|
|
148
|
+
<Image
|
|
149
|
+
source={{ uri: src }}
|
|
150
|
+
style={styles.image}
|
|
151
|
+
accessible={false}
|
|
152
|
+
onError={() => setError(true)}
|
|
153
|
+
testID='dot-symbol-img'
|
|
154
|
+
/>
|
|
155
|
+
)}
|
|
156
|
+
</Box>
|
|
157
|
+
</Box>
|
|
158
|
+
);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
DotSymbol.displayName = 'DotSymbol';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { StyledViewProps } from '../../../styles';
|
|
3
|
+
|
|
4
|
+
export type DotSymbolSize = 8 | 10 | 12 | 16 | 20 | 24;
|
|
5
|
+
|
|
6
|
+
export type DotSymbolPin =
|
|
7
|
+
| 'top-start'
|
|
8
|
+
| 'top-end'
|
|
9
|
+
| 'bottom-start'
|
|
10
|
+
| 'bottom-end';
|
|
11
|
+
|
|
12
|
+
export type DotSymbolProps = {
|
|
13
|
+
/**
|
|
14
|
+
* Image source URL for the dot indicator.
|
|
15
|
+
*/
|
|
16
|
+
src: string;
|
|
17
|
+
/**
|
|
18
|
+
* Alternative text for the dot image.
|
|
19
|
+
*/
|
|
20
|
+
alt?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Corner placement of the dot indicator.
|
|
23
|
+
* @default 'bottom-end'
|
|
24
|
+
*/
|
|
25
|
+
pin?: DotSymbolPin;
|
|
26
|
+
/**
|
|
27
|
+
* The size of the dot indicator in pixels.
|
|
28
|
+
* @default 20
|
|
29
|
+
*/
|
|
30
|
+
size?: DotSymbolSize;
|
|
31
|
+
/**
|
|
32
|
+
* The shape of the dot indicator.
|
|
33
|
+
* @default 'circle'
|
|
34
|
+
*/
|
|
35
|
+
shape?: 'square' | 'circle';
|
|
36
|
+
/**
|
|
37
|
+
* The wrapped component (e.g. MediaImage or Spot).
|
|
38
|
+
*/
|
|
39
|
+
children?: ReactNode;
|
|
40
|
+
} & Omit<StyledViewProps, 'children'>;
|
|
@@ -265,12 +265,11 @@ export const ListItemTitle = ({
|
|
|
265
265
|
title: StyleSheet.flatten([
|
|
266
266
|
t.typographies.body2SemiBold,
|
|
267
267
|
{
|
|
268
|
-
flex: 1,
|
|
269
268
|
minWidth: 0,
|
|
270
269
|
flexShrink: 1,
|
|
271
270
|
textAlign: isInTrailing ? 'right' : 'left',
|
|
272
271
|
color: disabled ? t.colors.text.disabled : t.colors.text.base,
|
|
273
|
-
}
|
|
272
|
+
},
|
|
274
273
|
]),
|
|
275
274
|
}),
|
|
276
275
|
[disabled, isInTrailing],
|
|
@@ -283,6 +282,7 @@ export const ListItemTitle = ({
|
|
|
283
282
|
style={StyleSheet.flatten([styles.title, style])}
|
|
284
283
|
numberOfLines={1}
|
|
285
284
|
ellipsizeMode='tail'
|
|
285
|
+
allowFontScaling={false}
|
|
286
286
|
{...textProps}
|
|
287
287
|
>
|
|
288
288
|
{children}
|
|
@@ -315,12 +315,11 @@ export const ListItemDescription = ({
|
|
|
315
315
|
description: StyleSheet.flatten([
|
|
316
316
|
t.typographies.body3,
|
|
317
317
|
{
|
|
318
|
-
flex: 1,
|
|
319
318
|
minWidth: 0,
|
|
320
319
|
flexShrink: 1,
|
|
321
320
|
textAlign: isInTrailing ? 'right' : 'left',
|
|
322
321
|
color: disabled ? t.colors.text.disabled : t.colors.text.muted,
|
|
323
|
-
}
|
|
322
|
+
},
|
|
324
323
|
]),
|
|
325
324
|
}),
|
|
326
325
|
[disabled, isInTrailing],
|
|
@@ -333,6 +332,7 @@ export const ListItemDescription = ({
|
|
|
333
332
|
style={StyleSheet.flatten([styles.description, style])}
|
|
334
333
|
numberOfLines={1}
|
|
335
334
|
ellipsizeMode='tail'
|
|
335
|
+
allowFontScaling={false}
|
|
336
336
|
{...textProps}
|
|
337
337
|
>
|
|
338
338
|
{children}
|
|
@@ -17,17 +17,6 @@ const borderRadiusMap: Record<MediaImageSize, BorderRadiusKey> = {
|
|
|
17
17
|
56: 'lg',
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export const mediaImageDotSizeMap: Record<MediaImageSize, number> = {
|
|
21
|
-
12: 8,
|
|
22
|
-
16: 8,
|
|
23
|
-
20: 8,
|
|
24
|
-
24: 10,
|
|
25
|
-
32: 12,
|
|
26
|
-
40: 16,
|
|
27
|
-
48: 20,
|
|
28
|
-
56: 24,
|
|
29
|
-
} as const;
|
|
30
|
-
|
|
31
20
|
const useStyles = ({
|
|
32
21
|
size,
|
|
33
22
|
shape,
|
|
@@ -48,14 +37,14 @@ const useStyles = ({
|
|
|
48
37
|
width: sizeValue,
|
|
49
38
|
height: sizeValue,
|
|
50
39
|
borderRadius: radius,
|
|
51
|
-
overflow: 'hidden'
|
|
52
|
-
alignItems: 'center'
|
|
53
|
-
justifyContent: 'center'
|
|
54
|
-
backgroundColor: t.colors.bg.
|
|
40
|
+
overflow: 'hidden',
|
|
41
|
+
alignItems: 'center',
|
|
42
|
+
justifyContent: 'center',
|
|
43
|
+
backgroundColor: t.colors.bg.muted,
|
|
55
44
|
},
|
|
56
45
|
image: {
|
|
57
|
-
width: '100%'
|
|
58
|
-
height: '100%'
|
|
46
|
+
width: '100%',
|
|
47
|
+
height: '100%',
|
|
59
48
|
},
|
|
60
49
|
};
|
|
61
50
|
},
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { MediaImage
|
|
1
|
+
export { MediaImage } from './MediaImage';
|
|
2
2
|
export * from './types';
|
|
@@ -76,7 +76,7 @@ import {
|
|
|
76
76
|
NavBarTitle,
|
|
77
77
|
} from '@ledgerhq/lumen-ui-rnative';
|
|
78
78
|
|
|
79
|
-
<NavBar
|
|
79
|
+
<NavBar density='compact'>
|
|
80
80
|
<NavBarBackButton onPress={() => navigation.goBack()} />
|
|
81
81
|
<NavBarContent>
|
|
82
82
|
<NavBarTitle>Page Title</NavBarTitle>
|
|
@@ -95,7 +95,7 @@ import {
|
|
|
95
95
|
NavBarDescription,
|
|
96
96
|
} from '@ledgerhq/lumen-ui-rnative';
|
|
97
97
|
|
|
98
|
-
<NavBar
|
|
98
|
+
<NavBar density='expanded'>
|
|
99
99
|
<NavBarBackButton onPress={() => navigation.goBack()} />
|
|
100
100
|
<NavBarContent>
|
|
101
101
|
<NavBarTitle>Account Details</NavBarTitle>
|
|
@@ -110,7 +110,7 @@ import {
|
|
|
110
110
|
import { MoreHorizontal } from '@ledgerhq/lumen-ui-rnative/symbols';
|
|
111
111
|
import { IconButton } from '@ledgerhq/lumen-ui-rnative';
|
|
112
112
|
|
|
113
|
-
<NavBar
|
|
113
|
+
<NavBar density='compact'>
|
|
114
114
|
<NavBarBackButton onPress={() => navigation.goBack()} />
|
|
115
115
|
<NavBarContent>
|
|
116
116
|
<NavBarTitle>Settings</NavBarTitle>
|
|
@@ -131,7 +131,7 @@ import { IconButton } from '@ledgerhq/lumen-ui-rnative';
|
|
|
131
131
|
import Icon from '@ledgerhq/crypto-icons/native';
|
|
132
132
|
import { NavBarCoinCapsule } from '@ledgerhq/lumen-ui-rnative';
|
|
133
133
|
|
|
134
|
-
<NavBar
|
|
134
|
+
<NavBar density='compact'>
|
|
135
135
|
<NavBarBackButton onPress={() => navigation.goBack()} />
|
|
136
136
|
<NavBarContent>
|
|
137
137
|
<NavBarCoinCapsule
|
|
@@ -163,7 +163,7 @@ function App() {
|
|
|
163
163
|
<Stack.Navigator
|
|
164
164
|
screenOptions={{
|
|
165
165
|
header: ({ navigation, route }) => (
|
|
166
|
-
<NavBar
|
|
166
|
+
<NavBar density='compact'>
|
|
167
167
|
<NavBarBackButton onPress={() => navigation.goBack()} />
|
|
168
168
|
<NavBarContent>
|
|
169
169
|
<NavBarTitle>{route.name}</NavBarTitle>
|
|
@@ -201,7 +201,7 @@ export default function Layout() {
|
|
|
201
201
|
<Stack
|
|
202
202
|
screenOptions={{
|
|
203
203
|
header: ({ route }) => (
|
|
204
|
-
<NavBar
|
|
204
|
+
<NavBar density='compact'>
|
|
205
205
|
<NavBarBackButton onPress={() => router.back()} />
|
|
206
206
|
<NavBarContent>
|
|
207
207
|
<NavBarTitle>{route.name}</NavBarTitle>
|
|
@@ -236,7 +236,7 @@ export default function DetailsScreen() {
|
|
|
236
236
|
<Stack.Screen
|
|
237
237
|
options={{
|
|
238
238
|
header: () => (
|
|
239
|
-
<NavBar
|
|
239
|
+
<NavBar density='expanded'>
|
|
240
240
|
<NavBarBackButton onPress={() => router.back()} />
|
|
241
241
|
<NavBarContent>
|
|
242
242
|
<NavBarTitle>Details</NavBarTitle>
|
|
@@ -35,10 +35,10 @@ const meta: Meta<typeof NavBar> = {
|
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
37
|
argTypes: {
|
|
38
|
-
|
|
38
|
+
density: {
|
|
39
39
|
control: 'select',
|
|
40
40
|
options: ['compact', 'expanded'],
|
|
41
|
-
description: 'Controls the
|
|
41
|
+
description: 'Controls the density/layout of the NavBar',
|
|
42
42
|
},
|
|
43
43
|
},
|
|
44
44
|
};
|
|
@@ -48,7 +48,7 @@ type Story = StoryObj<typeof NavBar>;
|
|
|
48
48
|
|
|
49
49
|
export const Base: Story = {
|
|
50
50
|
args: {
|
|
51
|
-
|
|
51
|
+
density: 'compact',
|
|
52
52
|
lx: {
|
|
53
53
|
width: 's480',
|
|
54
54
|
},
|
|
@@ -74,7 +74,7 @@ export const Base: Story = {
|
|
|
74
74
|
|
|
75
75
|
export const Expanded: Story = {
|
|
76
76
|
args: {
|
|
77
|
-
|
|
77
|
+
density: 'expanded',
|
|
78
78
|
lx: {
|
|
79
79
|
width: 's480',
|
|
80
80
|
},
|
|
@@ -100,7 +100,7 @@ export const Expanded: Story = {
|
|
|
100
100
|
|
|
101
101
|
export const WithCoinCapsule: Story = {
|
|
102
102
|
args: {
|
|
103
|
-
|
|
103
|
+
density: 'compact',
|
|
104
104
|
lx: {
|
|
105
105
|
width: 's480',
|
|
106
106
|
},
|
|
@@ -128,7 +128,7 @@ export const WithCoinCapsule: Story = {
|
|
|
128
128
|
|
|
129
129
|
export const WithMultipleTrailingActions: Story = {
|
|
130
130
|
args: {
|
|
131
|
-
|
|
131
|
+
density: 'compact',
|
|
132
132
|
lx: {
|
|
133
133
|
width: 's480',
|
|
134
134
|
},
|
|
@@ -26,7 +26,7 @@ describe('NavBar', () => {
|
|
|
26
26
|
describe('Rendering', () => {
|
|
27
27
|
it('should render with title', () => {
|
|
28
28
|
renderWithProvider(
|
|
29
|
-
<NavBar testID='navbar'
|
|
29
|
+
<NavBar testID='navbar' density='compact'>
|
|
30
30
|
<NavBarContent>
|
|
31
31
|
<NavBarTitle>Test Title</NavBarTitle>
|
|
32
32
|
</NavBarContent>
|
|
@@ -39,7 +39,7 @@ describe('NavBar', () => {
|
|
|
39
39
|
|
|
40
40
|
it('should render with title and description', () => {
|
|
41
41
|
renderWithProvider(
|
|
42
|
-
<NavBar testID='navbar'
|
|
42
|
+
<NavBar testID='navbar' density='expanded'>
|
|
43
43
|
<NavBarContent>
|
|
44
44
|
<NavBarTitle>Test Title</NavBarTitle>
|
|
45
45
|
<NavBarDescription>Test Description</NavBarDescription>
|
|
@@ -54,7 +54,7 @@ describe('NavBar', () => {
|
|
|
54
54
|
it('should render with back button', () => {
|
|
55
55
|
const onPress = jest.fn();
|
|
56
56
|
renderWithProvider(
|
|
57
|
-
<NavBar testID='navbar'
|
|
57
|
+
<NavBar testID='navbar' density='compact'>
|
|
58
58
|
<NavBarBackButton onPress={onPress} />
|
|
59
59
|
<NavBarContent>
|
|
60
60
|
<NavBarTitle>Test Title</NavBarTitle>
|
|
@@ -67,7 +67,7 @@ describe('NavBar', () => {
|
|
|
67
67
|
|
|
68
68
|
it('should render with coin capsule', () => {
|
|
69
69
|
renderWithProvider(
|
|
70
|
-
<NavBar testID='navbar'
|
|
70
|
+
<NavBar testID='navbar' density='compact'>
|
|
71
71
|
<NavBarContent>
|
|
72
72
|
<NavBarCoinCapsule ticker='BTC' icon={<MockIcon />} />
|
|
73
73
|
</NavBarContent>
|
|
@@ -80,7 +80,7 @@ describe('NavBar', () => {
|
|
|
80
80
|
it('should render with all components', () => {
|
|
81
81
|
const onPress = jest.fn();
|
|
82
82
|
renderWithProvider(
|
|
83
|
-
<NavBar testID='navbar'
|
|
83
|
+
<NavBar testID='navbar' density='expanded'>
|
|
84
84
|
<NavBarBackButton onPress={onPress} />
|
|
85
85
|
<NavBarContent>
|
|
86
86
|
<NavBarTitle>Test Title</NavBarTitle>
|
|
@@ -95,12 +95,12 @@ describe('NavBar', () => {
|
|
|
95
95
|
});
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
-
describe('
|
|
98
|
+
describe('Density', () => {
|
|
99
99
|
it.each(['compact', 'expanded'] as const)(
|
|
100
|
-
'should render with %s
|
|
101
|
-
(
|
|
100
|
+
'should render with %s density',
|
|
101
|
+
(density) => {
|
|
102
102
|
renderWithProvider(
|
|
103
|
-
<NavBar testID='navbar'
|
|
103
|
+
<NavBar testID='navbar' density={density}>
|
|
104
104
|
<NavBarContent>
|
|
105
105
|
<NavBarTitle>Test Title</NavBarTitle>
|
|
106
106
|
</NavBarContent>
|
|
@@ -115,7 +115,7 @@ describe('NavBar', () => {
|
|
|
115
115
|
describe('NavBarTitle', () => {
|
|
116
116
|
it('should truncate to 1 line in compact mode', () => {
|
|
117
117
|
renderWithProvider(
|
|
118
|
-
<NavBar
|
|
118
|
+
<NavBar density='compact'>
|
|
119
119
|
<NavBarContent>
|
|
120
120
|
<NavBarTitle testID='title'>Very long title text</NavBarTitle>
|
|
121
121
|
</NavBarContent>
|
|
@@ -128,7 +128,7 @@ describe('NavBar', () => {
|
|
|
128
128
|
|
|
129
129
|
it('should truncate to 2 lines in expanded mode', () => {
|
|
130
130
|
renderWithProvider(
|
|
131
|
-
<NavBar
|
|
131
|
+
<NavBar density='expanded'>
|
|
132
132
|
<NavBarContent>
|
|
133
133
|
<NavBarTitle testID='title'>Very long title text</NavBarTitle>
|
|
134
134
|
</NavBarContent>
|
|
@@ -142,7 +142,7 @@ describe('NavBar', () => {
|
|
|
142
142
|
it('should accept custom style prop', () => {
|
|
143
143
|
const customStyle = { opacity: 0.5 };
|
|
144
144
|
renderWithProvider(
|
|
145
|
-
<NavBar
|
|
145
|
+
<NavBar density='compact'>
|
|
146
146
|
<NavBarContent>
|
|
147
147
|
<NavBarTitle testID='title' style={customStyle}>
|
|
148
148
|
Test
|
|
@@ -164,7 +164,7 @@ describe('NavBar', () => {
|
|
|
164
164
|
describe('NavBarDescription', () => {
|
|
165
165
|
it('should truncate to 1 line in compact mode', () => {
|
|
166
166
|
renderWithProvider(
|
|
167
|
-
<NavBar
|
|
167
|
+
<NavBar density='compact'>
|
|
168
168
|
<NavBarContent>
|
|
169
169
|
<NavBarTitle>Title</NavBarTitle>
|
|
170
170
|
<NavBarDescription testID='description'>
|
|
@@ -180,7 +180,7 @@ describe('NavBar', () => {
|
|
|
180
180
|
|
|
181
181
|
it('should truncate to 3 lines in expanded mode', () => {
|
|
182
182
|
renderWithProvider(
|
|
183
|
-
<NavBar
|
|
183
|
+
<NavBar density='expanded'>
|
|
184
184
|
<NavBarContent>
|
|
185
185
|
<NavBarTitle>Title</NavBarTitle>
|
|
186
186
|
<NavBarDescription testID='description'>
|
|
@@ -197,7 +197,7 @@ describe('NavBar', () => {
|
|
|
197
197
|
it('should accept custom style prop', () => {
|
|
198
198
|
const customStyle = { opacity: 0.7 };
|
|
199
199
|
renderWithProvider(
|
|
200
|
-
<NavBar
|
|
200
|
+
<NavBar density='expanded'>
|
|
201
201
|
<NavBarContent>
|
|
202
202
|
<NavBarTitle>Title</NavBarTitle>
|
|
203
203
|
<NavBarDescription testID='description' style={customStyle}>
|
|
@@ -221,7 +221,7 @@ describe('NavBar', () => {
|
|
|
221
221
|
it('should call onPress when pressed', () => {
|
|
222
222
|
const handlePress = jest.fn();
|
|
223
223
|
renderWithProvider(
|
|
224
|
-
<NavBar
|
|
224
|
+
<NavBar density='compact'>
|
|
225
225
|
<NavBarBackButton onPress={handlePress} />
|
|
226
226
|
<NavBarContent>
|
|
227
227
|
<NavBarTitle>Test Title</NavBarTitle>
|
|
@@ -236,7 +236,7 @@ describe('NavBar', () => {
|
|
|
236
236
|
it('should accept custom accessibilityLabel', () => {
|
|
237
237
|
const handlePress = jest.fn();
|
|
238
238
|
renderWithProvider(
|
|
239
|
-
<NavBar
|
|
239
|
+
<NavBar density='compact'>
|
|
240
240
|
<NavBarBackButton
|
|
241
241
|
onPress={handlePress}
|
|
242
242
|
accessibilityLabel='Navigate back'
|
|
@@ -254,7 +254,7 @@ describe('NavBar', () => {
|
|
|
254
254
|
describe('NavBarCoinCapsule', () => {
|
|
255
255
|
it('should render ticker and icon', () => {
|
|
256
256
|
renderWithProvider(
|
|
257
|
-
<NavBar
|
|
257
|
+
<NavBar density='compact'>
|
|
258
258
|
<NavBarContent>
|
|
259
259
|
<NavBarCoinCapsule ticker='ETH' icon={<MockIcon />} />
|
|
260
260
|
</NavBarContent>
|
|
@@ -268,7 +268,7 @@ describe('NavBar', () => {
|
|
|
268
268
|
describe('NavBarTrailing', () => {
|
|
269
269
|
it('should render trailing content in compact mode', () => {
|
|
270
270
|
renderWithProvider(
|
|
271
|
-
<NavBar
|
|
271
|
+
<NavBar density='compact'>
|
|
272
272
|
<NavBarBackButton />
|
|
273
273
|
<NavBarContent>
|
|
274
274
|
<NavBarTitle>Test Title</NavBarTitle>
|
|
@@ -284,7 +284,7 @@ describe('NavBar', () => {
|
|
|
284
284
|
|
|
285
285
|
it('should render trailing content in expanded mode', () => {
|
|
286
286
|
renderWithProvider(
|
|
287
|
-
<NavBar
|
|
287
|
+
<NavBar density='expanded'>
|
|
288
288
|
<NavBarBackButton />
|
|
289
289
|
<NavBarContent>
|
|
290
290
|
<NavBarTitle>Test Title</NavBarTitle>
|
|
@@ -301,7 +301,7 @@ describe('NavBar', () => {
|
|
|
301
301
|
it('should accept custom style prop', () => {
|
|
302
302
|
const customStyle = { opacity: 0.8 };
|
|
303
303
|
renderWithProvider(
|
|
304
|
-
<NavBar
|
|
304
|
+
<NavBar density='compact'>
|
|
305
305
|
<NavBarContent>
|
|
306
306
|
<NavBarTitle>Title</NavBarTitle>
|
|
307
307
|
</NavBarContent>
|
|
@@ -324,7 +324,7 @@ describe('NavBar', () => {
|
|
|
324
324
|
describe('NavBarContent', () => {
|
|
325
325
|
it('should render content in both compact and expanded modes', () => {
|
|
326
326
|
const { rerender } = renderWithProvider(
|
|
327
|
-
<NavBar
|
|
327
|
+
<NavBar density='compact'>
|
|
328
328
|
<NavBarContent>
|
|
329
329
|
<NavBarTitle>Title</NavBarTitle>
|
|
330
330
|
<NavBarDescription>Description</NavBarDescription>
|
|
@@ -337,7 +337,7 @@ describe('NavBar', () => {
|
|
|
337
337
|
|
|
338
338
|
rerender(
|
|
339
339
|
<ThemeProvider themes={ledgerLiveThemes} colorScheme='dark' locale='en'>
|
|
340
|
-
<NavBar
|
|
340
|
+
<NavBar density='expanded'>
|
|
341
341
|
<NavBarContent>
|
|
342
342
|
<NavBarTitle>Title</NavBarTitle>
|
|
343
343
|
<NavBarDescription>Description</NavBarDescription>
|
|
@@ -353,7 +353,7 @@ describe('NavBar', () => {
|
|
|
353
353
|
it('should render back button in all modes', () => {
|
|
354
354
|
const onPress = jest.fn();
|
|
355
355
|
const { rerender } = renderWithProvider(
|
|
356
|
-
<NavBar
|
|
356
|
+
<NavBar density='compact'>
|
|
357
357
|
<NavBarBackButton onPress={onPress} />
|
|
358
358
|
<NavBarContent>
|
|
359
359
|
<NavBarTitle>Title</NavBarTitle>
|
|
@@ -365,7 +365,7 @@ describe('NavBar', () => {
|
|
|
365
365
|
|
|
366
366
|
rerender(
|
|
367
367
|
<ThemeProvider themes={ledgerLiveThemes} colorScheme='dark' locale='en'>
|
|
368
|
-
<NavBar
|
|
368
|
+
<NavBar density='expanded'>
|
|
369
369
|
<NavBarBackButton onPress={onPress} />
|
|
370
370
|
<NavBarContent>
|
|
371
371
|
<NavBarTitle>Title</NavBarTitle>
|