@ledgerhq/lumen-ui-rnative 0.0.52 → 0.0.53
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/package.json +2 -2
- package/dist/src/lib/Components/BaseInput/BaseInput.d.ts +1 -0
- package/dist/src/lib/Components/BaseInput/BaseInput.d.ts.map +1 -1
- package/dist/src/lib/Components/BaseInput/BaseInput.js +6 -2
- package/dist/src/lib/Components/BaseInput/types.d.ts +5 -1
- package/dist/src/lib/Components/BaseInput/types.d.ts.map +1 -1
- package/dist/src/lib/Components/SearchInput/SearchInput.d.ts +3 -1
- package/dist/src/lib/Components/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/src/lib/Components/SearchInput/SearchInput.js +12 -2
- package/dist/src/lib/Components/SearchInput/SearchInput.stories.d.ts.map +1 -1
- package/dist/src/lib/Components/SearchInput/SearchInput.stories.js +3 -0
- package/dist/src/lib/Components/SearchInput/types.d.ts +7 -1
- package/dist/src/lib/Components/SearchInput/types.d.ts.map +1 -1
- package/dist/src/lib/Components/Tile/Tile.d.ts.map +1 -1
- package/dist/src/lib/Components/Tile/Tile.js +1 -0
- package/dist/src/lib/Components/Utility/Gradient/LinearGradient/LinearGradient.d.ts +32 -0
- package/dist/src/lib/Components/Utility/Gradient/LinearGradient/LinearGradient.d.ts.map +1 -0
- package/dist/src/lib/Components/Utility/Gradient/LinearGradient/LinearGradient.js +75 -0
- package/dist/src/lib/Components/Utility/Gradient/LinearGradient/LinearGradient.stories.d.ts +11 -0
- package/dist/src/lib/Components/Utility/Gradient/LinearGradient/LinearGradient.stories.d.ts.map +1 -0
- package/dist/src/lib/Components/Utility/Gradient/LinearGradient/LinearGradient.stories.js +107 -0
- package/dist/src/lib/Components/Utility/Gradient/LinearGradient/index.d.ts +3 -0
- package/dist/src/lib/Components/Utility/Gradient/LinearGradient/index.d.ts.map +1 -0
- package/dist/src/lib/Components/Utility/Gradient/LinearGradient/index.js +2 -0
- package/dist/src/lib/Components/Utility/Gradient/LinearGradient/types.d.ts +32 -0
- package/dist/src/lib/Components/Utility/Gradient/LinearGradient/types.d.ts.map +1 -0
- package/dist/src/lib/Components/Utility/Gradient/LinearGradient/types.js +1 -0
- package/dist/src/lib/Components/Utility/Gradient/RadialGradient/RadialGradient.d.ts +31 -0
- package/dist/src/lib/Components/Utility/Gradient/RadialGradient/RadialGradient.d.ts.map +1 -0
- package/dist/src/lib/Components/Utility/Gradient/RadialGradient/RadialGradient.js +52 -0
- package/dist/src/lib/Components/Utility/Gradient/RadialGradient/RadialGradient.stories.d.ts +10 -0
- package/dist/src/lib/Components/Utility/Gradient/RadialGradient/RadialGradient.stories.d.ts.map +1 -0
- package/dist/src/lib/Components/Utility/Gradient/RadialGradient/RadialGradient.stories.js +101 -0
- package/dist/src/lib/Components/Utility/Gradient/RadialGradient/index.d.ts +3 -0
- package/dist/src/lib/Components/Utility/Gradient/RadialGradient/index.d.ts.map +1 -0
- package/dist/src/lib/Components/Utility/Gradient/RadialGradient/index.js +2 -0
- package/dist/src/lib/Components/Utility/Gradient/RadialGradient/types.d.ts +32 -0
- package/dist/src/lib/Components/Utility/Gradient/RadialGradient/types.d.ts.map +1 -0
- package/dist/src/lib/Components/Utility/Gradient/RadialGradient/types.js +1 -0
- package/dist/src/lib/Components/Utility/Gradient/gradient.types.d.ts +21 -0
- package/dist/src/lib/Components/Utility/Gradient/gradient.types.d.ts.map +1 -0
- package/dist/src/lib/Components/Utility/Gradient/gradient.types.js +1 -0
- package/dist/src/lib/Components/Utility/Gradient/utils/resolveGradientColor.d.ts +21 -0
- package/dist/src/lib/Components/Utility/Gradient/utils/resolveGradientColor.d.ts.map +1 -0
- package/dist/src/lib/Components/Utility/Gradient/utils/resolveGradientColor.js +38 -0
- package/dist/src/lib/Components/Utility/index.d.ts +2 -0
- package/dist/src/lib/Components/Utility/index.d.ts.map +1 -1
- package/dist/src/lib/Components/Utility/index.js +2 -0
- package/package.json +2 -2
- package/src/lib/Components/BaseInput/BaseInput.tsx +7 -2
- package/src/lib/Components/BaseInput/types.ts +5 -1
- package/src/lib/Components/SearchInput/SearchInput.stories.tsx +3 -0
- package/src/lib/Components/SearchInput/SearchInput.tsx +32 -8
- package/src/lib/Components/SearchInput/types.ts +7 -1
- package/src/lib/Components/Tile/Tile.tsx +1 -0
- package/src/lib/Components/Utility/Gradient/LinearGradient/LinearGradient.mdx +142 -0
- package/src/lib/Components/Utility/Gradient/LinearGradient/LinearGradient.stories.tsx +173 -0
- package/src/lib/Components/Utility/Gradient/LinearGradient/LinearGradient.test.tsx +69 -0
- package/src/lib/Components/Utility/Gradient/LinearGradient/LinearGradient.tsx +127 -0
- package/src/lib/Components/Utility/Gradient/LinearGradient/index.ts +2 -0
- package/src/lib/Components/Utility/Gradient/LinearGradient/types.ts +42 -0
- package/src/lib/Components/Utility/Gradient/RadialGradient/RadialGradient.mdx +109 -0
- package/src/lib/Components/Utility/Gradient/RadialGradient/RadialGradient.stories.tsx +148 -0
- package/src/lib/Components/Utility/Gradient/RadialGradient/RadialGradient.test.tsx +69 -0
- package/src/lib/Components/Utility/Gradient/RadialGradient/RadialGradient.tsx +102 -0
- package/src/lib/Components/Utility/Gradient/RadialGradient/index.ts +2 -0
- package/src/lib/Components/Utility/Gradient/RadialGradient/types.ts +32 -0
- package/src/lib/Components/Utility/Gradient/gradient.types.ts +22 -0
- package/src/lib/Components/Utility/Gradient/utils/resolveGradientColor.test.ts +144 -0
- package/src/lib/Components/Utility/Gradient/utils/resolveGradientColor.ts +59 -0
- package/src/lib/Components/Utility/index.ts +2 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from '../../Box';
|
|
3
|
+
import { Text } from '../../Text';
|
|
4
|
+
import { RadialGradient } from './RadialGradient';
|
|
5
|
+
const meta = {
|
|
6
|
+
component: RadialGradient,
|
|
7
|
+
title: 'Utility/RadialGradient',
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: 'centered',
|
|
10
|
+
backgrounds: { default: 'light' },
|
|
11
|
+
docs: {
|
|
12
|
+
source: {
|
|
13
|
+
language: 'tsx',
|
|
14
|
+
format: true,
|
|
15
|
+
type: 'code',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
export default meta;
|
|
21
|
+
export const Base = {
|
|
22
|
+
args: {
|
|
23
|
+
stops: [{ color: 'accent' }, { color: 'active', opacity: 0 }],
|
|
24
|
+
lx: {
|
|
25
|
+
height: 's192',
|
|
26
|
+
width: 's192',
|
|
27
|
+
borderRadius: 'lg',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
export const CenterPositionShowcase = {
|
|
32
|
+
render: () => {
|
|
33
|
+
const positions = [
|
|
34
|
+
{
|
|
35
|
+
title: 'Aspect ratio 1:1',
|
|
36
|
+
isSquare: true,
|
|
37
|
+
items: [
|
|
38
|
+
{
|
|
39
|
+
center: { x: 0.5, y: 0.5 },
|
|
40
|
+
label: '{x: 0.5, y: 0.5} (default)',
|
|
41
|
+
},
|
|
42
|
+
{ center: { x: 0.2, y: 0.2 }, label: '{x: 0.2, y: 0.2}' },
|
|
43
|
+
{ center: { x: 0.8, y: 0.8 }, label: '{x: 0.8, y: 0.8}' },
|
|
44
|
+
{ center: { x: 0.2, y: 0.8 }, label: '{x: 0.2, y: 0.8}' },
|
|
45
|
+
{ center: { x: 0.8, y: 0.2 }, label: '{x: 0.8, y: 0.2}' },
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
title: 'Aspect ratio 1:2',
|
|
50
|
+
isSquare: false,
|
|
51
|
+
items: [
|
|
52
|
+
{
|
|
53
|
+
center: { x: 0.5, y: 0.5 },
|
|
54
|
+
label: '{x: 0.5, y: 0.5} (default)',
|
|
55
|
+
},
|
|
56
|
+
{ center: { x: 0.2, y: 0.2 }, label: '{x: 0.2, y: 0.2}' },
|
|
57
|
+
{ center: { x: 0.8, y: 0.8 }, label: '{x: 0.8, y: 0.8}' },
|
|
58
|
+
{ center: { x: 0.2, y: 0.8 }, label: '{x: 0.2, y: 0.8}' },
|
|
59
|
+
{ center: { x: 0.8, y: 0.2 }, label: '{x: 0.8, y: 0.2}' },
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
return (_jsx(Box, { lx: { flexDirection: 'column', gap: 's40' }, children: positions.map(({ title, isSquare, items }) => (_jsxs(Box, { children: [_jsx(Text, { typography: 'heading5SemiBold', lx: { color: 'base', marginBottom: 's16' }, children: title }), _jsx(Box, { lx: { flexDirection: 'row', flexWrap: 'wrap', gap: 's24' }, children: items.map(({ center, label }) => (_jsxs(Box, { lx: { gap: 's8', alignItems: 'center' }, children: [_jsx(RadialGradient, { center: center, stops: [
|
|
64
|
+
{ color: 'accent' },
|
|
65
|
+
{ color: 'active', opacity: 0 },
|
|
66
|
+
], lx: {
|
|
67
|
+
height: 's72',
|
|
68
|
+
width: isSquare ? 's72' : 's144',
|
|
69
|
+
borderRadius: 'md',
|
|
70
|
+
borderColor: 'active',
|
|
71
|
+
borderWidth: 's1',
|
|
72
|
+
} }), _jsx(Text, { typography: 'body4', lx: { color: 'base' }, children: label })] }, label))) })] }, title))) }));
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
export const WithChildren = {
|
|
76
|
+
args: {
|
|
77
|
+
stops: [{ color: 'accent' }, { color: 'active', opacity: 0 }],
|
|
78
|
+
lx: {
|
|
79
|
+
padding: 's24',
|
|
80
|
+
borderRadius: 'lg',
|
|
81
|
+
width: 's288',
|
|
82
|
+
borderColor: 'active',
|
|
83
|
+
borderWidth: 's1',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
render: (args) => (_jsxs(RadialGradient, { ...args, children: [_jsx(Text, { typography: 'heading2SemiBold', lx: { color: 'base' }, children: "With Children" }), _jsx(Text, { typography: 'body2', lx: { color: 'base', marginTop: 's8' }, children: "Adapt height based on content." }), _jsx(Text, { typography: 'body3', lx: { color: 'base', marginTop: 's8' }, children: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos" })] })),
|
|
87
|
+
};
|
|
88
|
+
export const WithMultipleStops = {
|
|
89
|
+
args: {
|
|
90
|
+
stops: [
|
|
91
|
+
{ color: 'warning', offset: 0, opacity: 1 },
|
|
92
|
+
{ color: 'accent', offset: 0.5, opacity: 1 },
|
|
93
|
+
{ color: 'error', offset: 1, opacity: 1 },
|
|
94
|
+
],
|
|
95
|
+
lx: {
|
|
96
|
+
height: 's80',
|
|
97
|
+
width: 's80',
|
|
98
|
+
borderRadius: 'full',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/Utility/Gradient/RadialGradient/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { StyledViewProps } from '../../../../../styles';
|
|
3
|
+
import { GradientStop } from '../gradient.types';
|
|
4
|
+
export type RadialGradientCenter = {
|
|
5
|
+
/**
|
|
6
|
+
* Horizontal position (0 = left, 1 = right)
|
|
7
|
+
*/
|
|
8
|
+
x: number;
|
|
9
|
+
/**
|
|
10
|
+
* Vertical position (0 = top, 1 = bottom)
|
|
11
|
+
*/
|
|
12
|
+
y: number;
|
|
13
|
+
};
|
|
14
|
+
export type RadialGradientProps = {
|
|
15
|
+
/**
|
|
16
|
+
* Gradient color stops
|
|
17
|
+
* Takes an object of color, offset and opacity.
|
|
18
|
+
* Offset is a number between 0 and 1.
|
|
19
|
+
* Opacity is a number between 0 and 1.
|
|
20
|
+
*/
|
|
21
|
+
stops: GradientStop[];
|
|
22
|
+
/**
|
|
23
|
+
* Optional children to render on top of the gradient
|
|
24
|
+
*/
|
|
25
|
+
children?: ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* Center position of the gradient.
|
|
28
|
+
* @default { x: 0.5, y: 0.5 }
|
|
29
|
+
*/
|
|
30
|
+
center?: RadialGradientCenter;
|
|
31
|
+
} & StyledViewProps;
|
|
32
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/Utility/Gradient/RadialGradient/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;;OAKG;IACH,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,oBAAoB,CAAC;CAC/B,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { LumenStyleSheetTheme } from '../../../../styles';
|
|
2
|
+
/**
|
|
3
|
+
* Background color token from the theme
|
|
4
|
+
*/
|
|
5
|
+
export type BackgroundColorToken = keyof LumenStyleSheetTheme['colors']['bg'];
|
|
6
|
+
export type GradientStop = {
|
|
7
|
+
/**
|
|
8
|
+
* Color value - can be a design token key (e.g., 'accent', 'error')
|
|
9
|
+
* or a raw color string (e.g., '#FF6B6B', 'rgba(...)')
|
|
10
|
+
*/
|
|
11
|
+
color: BackgroundColorToken | (string & {});
|
|
12
|
+
/**
|
|
13
|
+
* Position of the stop (0-1). If omitted, stops are auto-spread evenly.
|
|
14
|
+
*/
|
|
15
|
+
offset?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Opacity of the color (0-1).
|
|
18
|
+
*/
|
|
19
|
+
opacity?: number;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=gradient.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gradient.types.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/Components/Utility/Gradient/gradient.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,oBAAoB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;AAE9E,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,KAAK,EAAE,oBAAoB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAC5C;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { LumenStyleSheetTheme } from '../../../../../styles';
|
|
2
|
+
import type { GradientStop } from '../gradient.types';
|
|
3
|
+
type BackgroundColors = LumenStyleSheetTheme['colors']['bg'];
|
|
4
|
+
/**
|
|
5
|
+
* Resolves a gradient stop color to a concrete color value.
|
|
6
|
+
* If the color is a design token, it's resolved from the theme.
|
|
7
|
+
* If it's a raw color string, it's returned as-is.
|
|
8
|
+
*/
|
|
9
|
+
export declare const resolveGradientColor: (color: string, bgColors: BackgroundColors) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Processes gradient stops by:
|
|
12
|
+
* 1. Resolving color tokens to actual values
|
|
13
|
+
* 2. Auto-spreading offsets if not provided
|
|
14
|
+
*/
|
|
15
|
+
export declare const processGradientStops: (stops: GradientStop[], bgColors: BackgroundColors) => Array<{
|
|
16
|
+
color: string;
|
|
17
|
+
offset: number;
|
|
18
|
+
opacity: number;
|
|
19
|
+
}>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=resolveGradientColor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveGradientColor.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/Utility/Gradient/utils/resolveGradientColor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAwB,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE5E,KAAK,gBAAgB,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;AAI7D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,MAAM,EACb,UAAU,gBAAgB,KACzB,MAMF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,YAAY,EAAE,EACrB,UAAU,gBAAgB,KACzB,KAAK,CAAC;IACP,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAuBA,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const DEFAULT_OPACITY = 1;
|
|
2
|
+
const DEFAULT_OFFSET = 0;
|
|
3
|
+
/**
|
|
4
|
+
* Resolves a gradient stop color to a concrete color value.
|
|
5
|
+
* If the color is a design token, it's resolved from the theme.
|
|
6
|
+
* If it's a raw color string, it's returned as-is.
|
|
7
|
+
*/
|
|
8
|
+
export const resolveGradientColor = (color, bgColors) => {
|
|
9
|
+
const isBackgroundToken = color in bgColors;
|
|
10
|
+
if (isBackgroundToken) {
|
|
11
|
+
return bgColors[color];
|
|
12
|
+
}
|
|
13
|
+
return color;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Processes gradient stops by:
|
|
17
|
+
* 1. Resolving color tokens to actual values
|
|
18
|
+
* 2. Auto-spreading offsets if not provided
|
|
19
|
+
*/
|
|
20
|
+
export const processGradientStops = (stops, bgColors) => {
|
|
21
|
+
const stopCount = stops.length;
|
|
22
|
+
return stops.map((stop, index) => {
|
|
23
|
+
const resolvedColor = resolveGradientColor(stop.color, bgColors);
|
|
24
|
+
// Auto-spread offsets if not provided
|
|
25
|
+
// For n stops: 0, 1/(n-1), 2/(n-1), ..., 1
|
|
26
|
+
const offset = stop.offset !== undefined
|
|
27
|
+
? stop.offset
|
|
28
|
+
: stopCount === 1
|
|
29
|
+
? DEFAULT_OFFSET
|
|
30
|
+
: index / (stopCount - 1);
|
|
31
|
+
const opacity = stop.opacity !== undefined ? stop.opacity : DEFAULT_OPACITY;
|
|
32
|
+
return {
|
|
33
|
+
color: resolvedColor,
|
|
34
|
+
offset,
|
|
35
|
+
opacity,
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Utility/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Utility/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/lumen-ui-rnative",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.53",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@gorhom/bottom-sheet": "^5.0.0",
|
|
36
|
-
"@ledgerhq/lumen-design-core": "0.0.
|
|
36
|
+
"@ledgerhq/lumen-design-core": "0.0.41",
|
|
37
37
|
"react": "~18.3.1",
|
|
38
38
|
"react-native": "~0.77.3",
|
|
39
39
|
"react-native-reanimated": "^3.0.0",
|
|
@@ -18,6 +18,7 @@ export const BaseInput = React.forwardRef<TextInput, BaseInputProps>(
|
|
|
18
18
|
{
|
|
19
19
|
lx,
|
|
20
20
|
style,
|
|
21
|
+
containerStyle,
|
|
21
22
|
inputStyle,
|
|
22
23
|
labelStyle,
|
|
23
24
|
label,
|
|
@@ -100,7 +101,7 @@ export const BaseInput = React.forwardRef<TextInput, BaseInputProps>(
|
|
|
100
101
|
return (
|
|
101
102
|
<Box lx={lx} style={style}>
|
|
102
103
|
<Pressable
|
|
103
|
-
style={styles.container}
|
|
104
|
+
style={StyleSheet.flatten([styles.container, containerStyle])}
|
|
104
105
|
onPress={() => inputRef.current?.focus()}
|
|
105
106
|
disabled={!editable}
|
|
106
107
|
>
|
|
@@ -109,7 +110,11 @@ export const BaseInput = React.forwardRef<TextInput, BaseInputProps>(
|
|
|
109
110
|
<TextInput
|
|
110
111
|
ref={inputRef}
|
|
111
112
|
value={value}
|
|
112
|
-
style={[
|
|
113
|
+
style={StyleSheet.flatten([
|
|
114
|
+
styles.input,
|
|
115
|
+
{ lineHeight: 0 },
|
|
116
|
+
inputStyle,
|
|
117
|
+
])}
|
|
113
118
|
onFocus={() => setIsFocused(true)}
|
|
114
119
|
onBlur={() => setIsFocused(false)}
|
|
115
120
|
onChangeText={handleChangeText}
|
|
@@ -12,9 +12,13 @@ export type BaseInputProps = {
|
|
|
12
12
|
*/
|
|
13
13
|
label?: string;
|
|
14
14
|
/**
|
|
15
|
-
* Additional styles to apply to the
|
|
15
|
+
* Additional styles to apply to the outer wrapper element.
|
|
16
16
|
*/
|
|
17
17
|
style?: StyleProp<ViewStyle>;
|
|
18
|
+
/**
|
|
19
|
+
* Additional styles to apply to the inner container element (Pressable).
|
|
20
|
+
*/
|
|
21
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
18
22
|
/**
|
|
19
23
|
* Additional styles to apply to the input element.
|
|
20
24
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TextInput } from 'react-native';
|
|
3
|
+
import { useStyleSheet } from '../../../styles';
|
|
3
4
|
import { Search as SearchIcon } from '../../Symbols';
|
|
4
5
|
import { BaseInput } from '../BaseInput';
|
|
5
6
|
import { type SearchInputProps } from './types';
|
|
@@ -7,14 +8,37 @@ import { type SearchInputProps } from './types';
|
|
|
7
8
|
export const SearchInput = React.forwardRef<
|
|
8
9
|
React.ElementRef<typeof TextInput>,
|
|
9
10
|
SearchInputProps
|
|
10
|
-
>(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
>(
|
|
12
|
+
(
|
|
13
|
+
{ appearance = 'plain', style, containerStyle, inputStyle, ...props },
|
|
14
|
+
ref,
|
|
15
|
+
) => {
|
|
16
|
+
const styles = useAppearanceStyles(appearance);
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<BaseInput
|
|
20
|
+
ref={ref}
|
|
21
|
+
prefix={<SearchIcon size={20} color='muted' accessible={false} />}
|
|
22
|
+
style={style}
|
|
23
|
+
containerStyle={[containerStyle, styles.container]}
|
|
24
|
+
inputStyle={[inputStyle, styles.input]}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const useAppearanceStyles = (appearance: 'plain' | 'transparent') => {
|
|
32
|
+
return useStyleSheet(
|
|
33
|
+
(t) => ({
|
|
34
|
+
container:
|
|
35
|
+
appearance === 'transparent'
|
|
36
|
+
? { backgroundColor: t.colors.bg.mutedTransparent }
|
|
37
|
+
: {},
|
|
38
|
+
input: { backgroundColor: 'transparent' },
|
|
39
|
+
}),
|
|
40
|
+
[appearance],
|
|
17
41
|
);
|
|
18
|
-
}
|
|
42
|
+
};
|
|
19
43
|
|
|
20
44
|
SearchInput.displayName = 'SearchInput';
|
|
@@ -2,4 +2,10 @@ import { BaseInputProps } from '../BaseInput';
|
|
|
2
2
|
import { BoxProps } from '../Utility';
|
|
3
3
|
|
|
4
4
|
export type SearchInputProps = Omit<BaseInputProps, 'prefix' | 'label'> &
|
|
5
|
-
BoxProps
|
|
5
|
+
BoxProps & {
|
|
6
|
+
/**
|
|
7
|
+
* The visual appearance of the search input
|
|
8
|
+
* @default 'plain'
|
|
9
|
+
*/
|
|
10
|
+
appearance?: 'plain' | 'transparent';
|
|
11
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as LinearGradientStories from './LinearGradient.stories';
|
|
3
|
+
import { CustomTabs, Tab } from '../../../../../../.storybook/components';
|
|
4
|
+
|
|
5
|
+
<Meta title='Utility/LinearGradient' of={LinearGradientStories} />
|
|
6
|
+
|
|
7
|
+
# LinearGradient
|
|
8
|
+
|
|
9
|
+
<CustomTabs>
|
|
10
|
+
<Tab label="Overview ">
|
|
11
|
+
|
|
12
|
+
## Introduction
|
|
13
|
+
|
|
14
|
+
LinearGradient renders a linear gradient background using `react-native-svg`.
|
|
15
|
+
It extends Box, supporting all `lx` style props for layout and sizing.
|
|
16
|
+
|
|
17
|
+
## Anatomy
|
|
18
|
+
|
|
19
|
+
<Canvas of={LinearGradientStories.Base} />
|
|
20
|
+
<Controls of={LinearGradientStories.Base} />
|
|
21
|
+
|
|
22
|
+
## Properties
|
|
23
|
+
|
|
24
|
+
### Direction
|
|
25
|
+
|
|
26
|
+
Supports preset directions or custom angles in degrees:
|
|
27
|
+
|
|
28
|
+
<Canvas of={LinearGradientStories.DirectionShowcase} />
|
|
29
|
+
|
|
30
|
+
### With Children
|
|
31
|
+
|
|
32
|
+
Content renders on top of the gradient:
|
|
33
|
+
|
|
34
|
+
<Canvas of={LinearGradientStories.WithChildren} />
|
|
35
|
+
|
|
36
|
+
### Multiple Stops
|
|
37
|
+
|
|
38
|
+
The `offset` prop controls where each color appears along the gradient (0 = start, 1 = end).
|
|
39
|
+
When omitted, stops are distributed evenly.
|
|
40
|
+
For example, 3 stops without offsets will be placed at 0, 0.5, and 1.
|
|
41
|
+
|
|
42
|
+
<Canvas of={LinearGradientStories.WithMultipleStops} />
|
|
43
|
+
|
|
44
|
+
### Crypto Gradients
|
|
45
|
+
|
|
46
|
+
The `theme` object expose a `colors.gradients.crypto` object that contains gradient definitions for each crypto token.
|
|
47
|
+
|
|
48
|
+
<Canvas of={LinearGradientStories.CryptoGradients} />
|
|
49
|
+
|
|
50
|
+
</Tab>
|
|
51
|
+
|
|
52
|
+
<Tab label="Implementation ">
|
|
53
|
+
|
|
54
|
+
## Setup
|
|
55
|
+
|
|
56
|
+
Install and set up the library with our [Setup Guide →](?path=/docs/getting-started-setup--docs).
|
|
57
|
+
|
|
58
|
+
## Basic Usage
|
|
59
|
+
|
|
60
|
+
The `direction` prop accepts preset strings like `to-bottom`, `to-right`, or diagonal variants.
|
|
61
|
+
Use design tokens for colors to ensure theme consistency.
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { LinearGradient } from '@ledgerhq/lumen-ui-rnative';
|
|
65
|
+
|
|
66
|
+
<LinearGradient
|
|
67
|
+
direction="to-bottom"
|
|
68
|
+
stops={[{ color: 'accent' }, { color: 'active', opacity: 0 }]}
|
|
69
|
+
lx={{ height: 's192', width: 's192', borderRadius: 'lg' }}
|
|
70
|
+
/>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Custom Angle
|
|
74
|
+
|
|
75
|
+
Pass a number to `direction` for precise angle control.
|
|
76
|
+
Angles follow convention:
|
|
77
|
+
- 0° points up
|
|
78
|
+
- 90° points right
|
|
79
|
+
- 180° points down
|
|
80
|
+
- 270° points left
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
<LinearGradient
|
|
84
|
+
direction={45}
|
|
85
|
+
stops={[{ color: 'accent' }, { color: 'active' }]}
|
|
86
|
+
lx={{ height: 's80', width: 's80' }}
|
|
87
|
+
/>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### With Children
|
|
91
|
+
|
|
92
|
+
The gradient acts as a background. Children are rendered on top and define the component's height when no explicit size is set.
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
<LinearGradient
|
|
96
|
+
direction="to-bottomright"
|
|
97
|
+
stops={[{ color: 'accent' }, { color: 'active', opacity: 0 }]}
|
|
98
|
+
lx={{ padding: 's24', borderRadius: 'lg' }}
|
|
99
|
+
>
|
|
100
|
+
<Text lx={{ color: 'base' }}>Content on gradient</Text>
|
|
101
|
+
</LinearGradient>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Stops API
|
|
105
|
+
|
|
106
|
+
Each stop defines a color at a position.
|
|
107
|
+
Use `opacity: 0` for fade-out effects.
|
|
108
|
+
Colors support both design tokens (`'accent'`) and raw values (`'#FF6B6B'`).
|
|
109
|
+
|
|
110
|
+
**Default behavior when `offset` is omitted:** stops are evenly distributed.
|
|
111
|
+
- With 2 stops → `[0, 1]`.
|
|
112
|
+
- With 3 stops → `[0, 0.5, 1]`.
|
|
113
|
+
- With 4 stops → `[0, 0.33, 0.66, 1]`.
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
type GradientStop = {
|
|
117
|
+
color: BackgroundColorToken | string; // Token or raw color
|
|
118
|
+
offset?: number; // 0-1, auto-spread if omitted
|
|
119
|
+
opacity?: number; // 0-1, defaults to 1
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Crypto Gradients
|
|
124
|
+
|
|
125
|
+
The `theme` object expose a `colors.gradients.crypto` object that contains gradient definitions for each crypto token.
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
import { useTheme } from '@ledgerhq/lumen-ui-rnative';
|
|
129
|
+
|
|
130
|
+
const { theme } = useTheme();
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<LinearGradient
|
|
134
|
+
stops={theme.colors.gradients.crypto.bitcoin}
|
|
135
|
+
lx={{ padding: 's24', borderRadius: 'lg' }}
|
|
136
|
+
direction="to-bottomright"
|
|
137
|
+
/>
|
|
138
|
+
);
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
</Tab>
|
|
142
|
+
</CustomTabs>
|