@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
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/lumen-ui-rnative",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.52",
|
|
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.40",
|
|
37
37
|
"react": "~18.3.1",
|
|
38
38
|
"react-native": "~0.77.3",
|
|
39
39
|
"react-native-reanimated": "^3.0.0",
|
|
@@ -3,6 +3,7 @@ import { TextInput } from 'react-native';
|
|
|
3
3
|
export declare const BaseInput: React.ForwardRefExoticComponent<{
|
|
4
4
|
label?: string;
|
|
5
5
|
style?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
6
|
+
containerStyle?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
6
7
|
inputStyle?: import("react-native").StyleProp<import("react-native").TextStyle>;
|
|
7
8
|
labelStyle?: import("react-native").StyleProp<import("react-native").TextStyle>;
|
|
8
9
|
errorMessage?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseInput.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/BaseInput/BaseInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AACf,OAAO,EAA8B,SAAS,EAAQ,MAAM,cAAc,CAAC;AAQ3E,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"BaseInput.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/BaseInput/BaseInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AACf,OAAO,EAA8B,SAAS,EAAQ,MAAM,cAAc,CAAC;AAQ3E,eAAO,MAAM,SAAS;;;;;;;;;;;;;sEA0JrB,CAAC"}
|
|
@@ -6,7 +6,7 @@ import { useStyleSheet, useTheme } from '../../../styles';
|
|
|
6
6
|
import { DeleteCircleFill } from '../../Symbols/Icons/DeleteCircleFill';
|
|
7
7
|
import { InteractiveIcon } from '../InteractiveIcon';
|
|
8
8
|
import { Box, Pressable } from '../Utility';
|
|
9
|
-
export const BaseInput = React.forwardRef(({ lx, style, inputStyle, labelStyle, label, errorMessage, hideClearButton, onChangeText: onChangeTextProp, editable = true, prefix, suffix, ...props }, ref) => {
|
|
9
|
+
export const BaseInput = React.forwardRef(({ lx, style, containerStyle, inputStyle, labelStyle, label, errorMessage, hideClearButton, onChangeText: onChangeTextProp, editable = true, prefix, suffix, ...props }, ref) => {
|
|
10
10
|
const { t } = useCommonTranslation();
|
|
11
11
|
const { theme } = useTheme();
|
|
12
12
|
const inputRef = useRef(null);
|
|
@@ -56,7 +56,11 @@ export const BaseInput = React.forwardRef(({ lx, style, inputStyle, labelStyle,
|
|
|
56
56
|
hasError: !!errorMessage,
|
|
57
57
|
isEditable: editable,
|
|
58
58
|
});
|
|
59
|
-
return (_jsxs(Box, { lx: lx, style: style, children: [_jsxs(Pressable, { style: styles.container, onPress: () => inputRef.current?.focus(), disabled: !editable, children: [prefix, _jsx(TextInput, { ref: inputRef, value: value, style:
|
|
59
|
+
return (_jsxs(Box, { lx: lx, style: style, children: [_jsxs(Pressable, { style: StyleSheet.flatten([styles.container, containerStyle]), onPress: () => inputRef.current?.focus(), disabled: !editable, children: [prefix, _jsx(TextInput, { ref: inputRef, value: value, style: StyleSheet.flatten([
|
|
60
|
+
styles.input,
|
|
61
|
+
{ lineHeight: 0 },
|
|
62
|
+
inputStyle,
|
|
63
|
+
]), onFocus: () => setIsFocused(true), onBlur: () => setIsFocused(false), onChangeText: handleChangeText, editable: editable, autoCapitalize: 'none', autoCorrect: false, selectionColor: theme.colors.text.active, placeholderTextColor: theme.colors.text.muted, ...props }), label && (_jsx(Animated.Text, { style: [
|
|
60
64
|
floatingLabelStyles.label,
|
|
61
65
|
floatingLabelStyles.animatedLabel,
|
|
62
66
|
labelStyle,
|
|
@@ -6,9 +6,13 @@ export type BaseInputProps = {
|
|
|
6
6
|
*/
|
|
7
7
|
label?: string;
|
|
8
8
|
/**
|
|
9
|
-
* Additional styles to apply to the
|
|
9
|
+
* Additional styles to apply to the outer wrapper element.
|
|
10
10
|
*/
|
|
11
11
|
style?: StyleProp<ViewStyle>;
|
|
12
|
+
/**
|
|
13
|
+
* Additional styles to apply to the inner container element (Pressable).
|
|
14
|
+
*/
|
|
15
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
12
16
|
/**
|
|
13
17
|
* Additional styles to apply to the input element.
|
|
14
18
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/BaseInput/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;OAEG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClC;;OAEG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GAAG,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,GAC/B,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/BaseInput/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;OAEG;IACH,cAAc,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC;;OAEG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClC;;OAEG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GAAG,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,GAC/B,QAAQ,CAAC"}
|
|
@@ -2,5 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { TextInput } from 'react-native';
|
|
3
3
|
export declare const SearchInput: React.ForwardRefExoticComponent<Omit<import("../BaseInput").BaseInputProps, "label" | "prefix"> & {
|
|
4
4
|
lx?: import("../../../styles").LumenViewStyle;
|
|
5
|
-
} & import("react-native").ViewProps &
|
|
5
|
+
} & import("react-native").ViewProps & {
|
|
6
|
+
appearance?: "plain" | "transparent";
|
|
7
|
+
} & React.RefAttributes<TextInput>>;
|
|
6
8
|
//# sourceMappingURL=SearchInput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/SearchInput/SearchInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"SearchInput.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/SearchInput/SearchInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAMzC,eAAO,MAAM,WAAW;;;;mCAqBvB,CAAC"}
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { useStyleSheet } from '../../../styles';
|
|
3
4
|
import { Search as SearchIcon } from '../../Symbols';
|
|
4
5
|
import { BaseInput } from '../BaseInput';
|
|
5
|
-
export const SearchInput = React.forwardRef((props, ref) => {
|
|
6
|
-
|
|
6
|
+
export const SearchInput = React.forwardRef(({ appearance = 'plain', style, containerStyle, inputStyle, ...props }, ref) => {
|
|
7
|
+
const styles = useAppearanceStyles(appearance);
|
|
8
|
+
return (_jsx(BaseInput, { ref: ref, prefix: _jsx(SearchIcon, { size: 20, color: 'muted', accessible: false }), style: style, containerStyle: [containerStyle, styles.container], inputStyle: [inputStyle, styles.input], ...props }));
|
|
7
9
|
});
|
|
10
|
+
const useAppearanceStyles = (appearance) => {
|
|
11
|
+
return useStyleSheet((t) => ({
|
|
12
|
+
container: appearance === 'transparent'
|
|
13
|
+
? { backgroundColor: t.colors.bg.mutedTransparent }
|
|
14
|
+
: {},
|
|
15
|
+
input: { backgroundColor: 'transparent' },
|
|
16
|
+
}), [appearance]);
|
|
17
|
+
};
|
|
8
18
|
SearchInput.displayName = 'SearchInput';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.stories.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/SearchInput/SearchInput.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAGvE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,WAAW,
|
|
1
|
+
{"version":3,"file":"SearchInput.stories.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/SearchInput/SearchInput.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAGvE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,WAAW,CAiClC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,WAAW,CAAC,CAAC;AA6B1C,eAAO,MAAM,IAAI,EAAE,KAOlB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAOzB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAUvB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KASjC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,KAOnC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,KAa/B,CAAC"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { BaseInputProps } from '../BaseInput';
|
|
2
2
|
import { BoxProps } from '../Utility';
|
|
3
|
-
export type SearchInputProps = Omit<BaseInputProps, 'prefix' | 'label'> & BoxProps
|
|
3
|
+
export type SearchInputProps = Omit<BaseInputProps, 'prefix' | 'label'> & BoxProps & {
|
|
4
|
+
/**
|
|
5
|
+
* The visual appearance of the search input
|
|
6
|
+
* @default 'plain'
|
|
7
|
+
*/
|
|
8
|
+
appearance?: 'plain' | 'transparent';
|
|
9
|
+
};
|
|
4
10
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/SearchInput/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,cAAc,EAAE,QAAQ,GAAG,OAAO,CAAC,GACrE,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/SearchInput/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,cAAc,EAAE,QAAQ,GAAG,OAAO,CAAC,GACrE,QAAQ,GAAG;IACT;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;CACtC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tile.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Tile/Tile.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAc,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAc,IAAI,EAAE,MAAM,cAAc,CAAC;AAIhD,OAAO,EACL,gBAAgB,EAEhB,oBAAoB,EAEpB,aAAa,EACb,cAAc,EACf,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Tile.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Tile/Tile.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAc,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAc,IAAI,EAAE,MAAM,cAAc,CAAC;AAIhD,OAAO,EACL,gBAAgB,EAEhB,oBAAoB,EAEpB,aAAa,EACb,cAAc,EACf,MAAM,SAAS,CAAC;AAqDjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,IAAI;;;;;;6HAoChB,CAAC;AAkBF;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ;YAAW,aAAa;;CAM5C,CAAC;AAeF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW;8BAA6B,gBAAgB;;CAWpE,CAAC;AAwBF;;;;GAIG;AACH,eAAO,MAAM,SAAS;8BAA6B,cAAc;;CA6BhE,CAAC;AAwBF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe;+BAIzB,oBAAoB;;CA6BtB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { View } from 'react-native';
|
|
2
|
+
import type { LinearGradientDirection } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* LinearGradient - A container component that renders a linear gradient background.
|
|
5
|
+
*
|
|
6
|
+
* Uses react-native-svg to render gradients that work consistently across platforms.
|
|
7
|
+
* Extends Box, so it supports all lx style props for layout and sizing.
|
|
8
|
+
*
|
|
9
|
+
* @see {@link https://ldls.vercel.app/?path=/docs/utility-lineargradient--docs Storybook}
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { LinearGradient } from '@ledgerhq/lumen-ui-rnative';
|
|
14
|
+
*
|
|
15
|
+
* // Basic usage with direction preset
|
|
16
|
+
* <LinearGradient
|
|
17
|
+
* direction="to-bottomright"
|
|
18
|
+
* stops={[
|
|
19
|
+
* { color: '#FF6B6B', offset: 0 },
|
|
20
|
+
* { color: '#6BCB77', offset: 1 },
|
|
21
|
+
* ]}
|
|
22
|
+
* lx={{ height: 's200', borderRadius: 'lg' }}
|
|
23
|
+
* />
|
|
24
|
+
*/
|
|
25
|
+
export declare const LinearGradient: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<{
|
|
26
|
+
stops: import("../gradient.types").GradientStop[];
|
|
27
|
+
children?: import("react").ReactNode;
|
|
28
|
+
direction?: LinearGradientDirection | number;
|
|
29
|
+
} & {
|
|
30
|
+
lx?: import("../../../../../styles").LumenViewStyle;
|
|
31
|
+
} & import("react-native").ViewProps & import("react").RefAttributes<View>>>;
|
|
32
|
+
//# sourceMappingURL=LinearGradient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinearGradient.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/Utility/Gradient/LinearGradient/LinearGradient.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAUzC,OAAO,KAAK,EAEV,uBAAuB,EAExB,MAAM,SAAS,CAAC;AAwCjB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc;;;;;;4EA8C1B,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, memo, useId, useMemo } from 'react';
|
|
3
|
+
import { StyleSheet } from 'react-native';
|
|
4
|
+
import Svg, { Defs, LinearGradient as SvgLinearGradient, Rect, Stop, } from 'react-native-svg';
|
|
5
|
+
import { useTheme } from '../../../../../styles';
|
|
6
|
+
import { Box } from '../../Box';
|
|
7
|
+
import { processGradientStops } from '../utils/resolveGradientColor';
|
|
8
|
+
const DIRECTION_MAP = {
|
|
9
|
+
'to-bottom': { x1: '0%', y1: '0%', x2: '0%', y2: '100%' },
|
|
10
|
+
'to-top': { x1: '0%', y1: '100%', x2: '0%', y2: '0%' },
|
|
11
|
+
'to-right': { x1: '0%', y1: '0%', x2: '100%', y2: '0%' },
|
|
12
|
+
'to-left': { x1: '100%', y1: '0%', x2: '0%', y2: '0%' },
|
|
13
|
+
'to-bottomright': { x1: '0%', y1: '0%', x2: '100%', y2: '100%' },
|
|
14
|
+
'to-bottomleft': { x1: '100%', y1: '0%', x2: '0%', y2: '100%' },
|
|
15
|
+
'to-topright': { x1: '0%', y1: '100%', x2: '100%', y2: '0%' },
|
|
16
|
+
'to-topleft': { x1: '100%', y1: '100%', x2: '0%', y2: '0%' },
|
|
17
|
+
};
|
|
18
|
+
const angleToCoordinates = (angle) => {
|
|
19
|
+
const normalizedAngle = ((angle % 360) + 360) % 360;
|
|
20
|
+
// Convert to radians (CSS: 0° is up, going clockwise)
|
|
21
|
+
// SVG: we need to map this to x1,y1 -> x2,y2
|
|
22
|
+
const radians = ((normalizedAngle - 90) * Math.PI) / 180;
|
|
23
|
+
const x2 = Math.cos(radians) * 0.5 + 0.5;
|
|
24
|
+
const y2 = Math.sin(radians) * 0.5 + 0.5;
|
|
25
|
+
const x1 = 1 - x2;
|
|
26
|
+
const y1 = 1 - y2;
|
|
27
|
+
return {
|
|
28
|
+
x1: `${Math.round(x1 * 100)}%`,
|
|
29
|
+
y1: `${Math.round(y1 * 100)}%`,
|
|
30
|
+
x2: `${Math.round(x2 * 100)}%`,
|
|
31
|
+
y2: `${Math.round(y2 * 100)}%`,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
const styles = StyleSheet.create({
|
|
35
|
+
gradient: {
|
|
36
|
+
...StyleSheet.absoluteFillObject,
|
|
37
|
+
width: '100%',
|
|
38
|
+
height: '100%',
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* LinearGradient - A container component that renders a linear gradient background.
|
|
43
|
+
*
|
|
44
|
+
* Uses react-native-svg to render gradients that work consistently across platforms.
|
|
45
|
+
* Extends Box, so it supports all lx style props for layout and sizing.
|
|
46
|
+
*
|
|
47
|
+
* @see {@link https://ldls.vercel.app/?path=/docs/utility-lineargradient--docs Storybook}
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```tsx
|
|
51
|
+
* import { LinearGradient } from '@ledgerhq/lumen-ui-rnative';
|
|
52
|
+
*
|
|
53
|
+
* // Basic usage with direction preset
|
|
54
|
+
* <LinearGradient
|
|
55
|
+
* direction="to-bottomright"
|
|
56
|
+
* stops={[
|
|
57
|
+
* { color: '#FF6B6B', offset: 0 },
|
|
58
|
+
* { color: '#6BCB77', offset: 1 },
|
|
59
|
+
* ]}
|
|
60
|
+
* lx={{ height: 's200', borderRadius: 'lg' }}
|
|
61
|
+
* />
|
|
62
|
+
*/
|
|
63
|
+
export const LinearGradient = memo(forwardRef(({ direction = 'to-bottom', stops, children, lx = {}, ...props }, ref) => {
|
|
64
|
+
const gradientId = useId();
|
|
65
|
+
const { theme } = useTheme();
|
|
66
|
+
const coordinates = useMemo(() => {
|
|
67
|
+
const isCustomAngle = typeof direction === 'number';
|
|
68
|
+
return isCustomAngle
|
|
69
|
+
? angleToCoordinates(direction)
|
|
70
|
+
: DIRECTION_MAP[direction];
|
|
71
|
+
}, [direction]);
|
|
72
|
+
const processedStops = useMemo(() => processGradientStops(stops, theme.colors.bg), [stops, theme.colors.bg]);
|
|
73
|
+
return (_jsxs(Box, { ref: ref, lx: { overflow: 'hidden', ...lx }, ...props, children: [_jsxs(Svg, { style: styles.gradient, preserveAspectRatio: 'none', children: [_jsx(Defs, { children: _jsx(SvgLinearGradient, { id: gradientId, ...coordinates, children: processedStops.map((stop, index) => (_jsx(Stop, { offset: `${stop.offset * 100}%`, stopColor: stop.color, stopOpacity: stop.opacity }, index))) }) }), _jsx(Rect, { x: '0', y: '0', width: '100%', height: '100%', fill: `url(#${gradientId})` })] }), children] }));
|
|
74
|
+
}));
|
|
75
|
+
LinearGradient.displayName = 'LinearGradient';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-native-web-vite';
|
|
2
|
+
import { LinearGradient } from './LinearGradient';
|
|
3
|
+
declare const meta: Meta<typeof LinearGradient>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof LinearGradient>;
|
|
6
|
+
export declare const Base: Story;
|
|
7
|
+
export declare const DirectionShowcase: Story;
|
|
8
|
+
export declare const WithChildren: Story;
|
|
9
|
+
export declare const WithMultipleStops: Story;
|
|
10
|
+
export declare const CryptoGradients: Story;
|
|
11
|
+
//# sourceMappingURL=LinearGradient.stories.d.ts.map
|
package/dist/src/lib/Components/Utility/Gradient/LinearGradient/LinearGradient.stories.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinearGradient.stories.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/Utility/Gradient/LinearGradient/LinearGradient.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAIvE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,cAAc,CAcrC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,cAAc,CAAC,CAAC;AAE7C,eAAO,MAAM,IAAI,EAAE,KAUlB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,KAoC/B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAwB1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,KA4B/B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAyC7B,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useTheme } from 'src/styles';
|
|
3
|
+
import { Box } from '../../Box';
|
|
4
|
+
import { Text } from '../../Text';
|
|
5
|
+
import { LinearGradient } from './LinearGradient';
|
|
6
|
+
const meta = {
|
|
7
|
+
component: LinearGradient,
|
|
8
|
+
title: 'Utility/LinearGradient',
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'centered',
|
|
11
|
+
backgrounds: { default: 'light' },
|
|
12
|
+
docs: {
|
|
13
|
+
source: {
|
|
14
|
+
language: 'tsx',
|
|
15
|
+
format: true,
|
|
16
|
+
type: 'code',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
export default meta;
|
|
22
|
+
export const Base = {
|
|
23
|
+
args: {
|
|
24
|
+
direction: 'to-bottom',
|
|
25
|
+
stops: [{ color: 'accent' }, { color: 'active', opacity: 0 }],
|
|
26
|
+
lx: {
|
|
27
|
+
width: 's192',
|
|
28
|
+
height: 's56',
|
|
29
|
+
borderRadius: 'lg',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export const DirectionShowcase = {
|
|
34
|
+
render: () => {
|
|
35
|
+
const orientations = [
|
|
36
|
+
'to-bottom',
|
|
37
|
+
'to-right',
|
|
38
|
+
'to-top',
|
|
39
|
+
'to-left',
|
|
40
|
+
'to-bottomright',
|
|
41
|
+
'to-bottomleft',
|
|
42
|
+
'to-topright',
|
|
43
|
+
'to-topleft',
|
|
44
|
+
0,
|
|
45
|
+
90,
|
|
46
|
+
180,
|
|
47
|
+
270,
|
|
48
|
+
];
|
|
49
|
+
return (_jsx(Box, { lx: { flexDirection: 'row', flexWrap: 'wrap', gap: 's20' }, children: orientations.map((orientation) => {
|
|
50
|
+
return (_jsxs(Box, { lx: { gap: 's4' }, children: [_jsx(LinearGradient, { direction: orientation, stops: [{ color: 'accent' }, { color: 'active', opacity: 0 }], lx: { height: 's40', width: 's176', borderRadius: 'md' } }), _jsx(Text, { typography: 'body4', lx: { color: 'base' }, children: orientation })] }, orientation));
|
|
51
|
+
}) }));
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
export const WithChildren = {
|
|
55
|
+
args: {
|
|
56
|
+
direction: 'to-bottomright',
|
|
57
|
+
stops: [{ color: 'accent' }, { color: 'active', opacity: 0, offset: 0.75 }],
|
|
58
|
+
lx: {
|
|
59
|
+
padding: 's24',
|
|
60
|
+
borderRadius: 'lg',
|
|
61
|
+
width: 's288',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
render: (args) => (_jsxs(LinearGradient, { ...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 consectetur adipisicing elit adipisicing elit. Mas adename labin anet." })] })),
|
|
65
|
+
};
|
|
66
|
+
export const WithMultipleStops = {
|
|
67
|
+
args: {
|
|
68
|
+
direction: 'to-right',
|
|
69
|
+
stops: [
|
|
70
|
+
{ color: 'accent', offset: 0, opacity: 1 },
|
|
71
|
+
{ color: 'warning', offset: 0.5, opacity: 1 },
|
|
72
|
+
{ color: 'errorStrong', offset: 1, opacity: 1 },
|
|
73
|
+
],
|
|
74
|
+
lx: {
|
|
75
|
+
borderRadius: 'md',
|
|
76
|
+
height: 's56',
|
|
77
|
+
width: 's288',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
render: (args) => {
|
|
81
|
+
const { theme } = useTheme();
|
|
82
|
+
console.log({ theme });
|
|
83
|
+
return (_jsxs(Box, { lx: { gap: 's12' }, children: [_jsx(LinearGradient, { ...args }), _jsxs(Box, { lx: { flexDirection: 'row', justifyContent: 'space-between' }, children: [_jsx(Text, { children: "accent" }), _jsx(Text, { children: "warning" }), _jsx(Text, { children: "errorStrong" })] })] }));
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
export const CryptoGradients = {
|
|
87
|
+
args: {
|
|
88
|
+
direction: 'to-bottomright',
|
|
89
|
+
lx: {
|
|
90
|
+
borderRadius: 'md',
|
|
91
|
+
height: 's56',
|
|
92
|
+
width: 's288',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
render: (args) => {
|
|
96
|
+
const { theme } = useTheme();
|
|
97
|
+
return (_jsx(Box, { lx: {
|
|
98
|
+
gap: 's20',
|
|
99
|
+
flexDirection: 'row',
|
|
100
|
+
flexWrap: 'wrap',
|
|
101
|
+
}, children: Object.entries(theme.colors.gradients.crypto).map(([key, gradient]) => (_jsxs(Box, { lx: { gap: 's4' }, children: [_jsx(LinearGradient, { ...args, lx: {
|
|
102
|
+
height: 's40',
|
|
103
|
+
width: 's176',
|
|
104
|
+
borderRadius: 'md',
|
|
105
|
+
}, stops: gradient }), _jsx(Text, { typography: 'body4', lx: { color: 'base' }, children: key })] }, key))) }));
|
|
106
|
+
},
|
|
107
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/Utility/Gradient/LinearGradient/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 GradientCoordinates = {
|
|
5
|
+
x1: string;
|
|
6
|
+
y1: string;
|
|
7
|
+
x2: string;
|
|
8
|
+
y2: string;
|
|
9
|
+
};
|
|
10
|
+
export type LinearGradientDirection = 'to-bottom' | 'to-top' | 'to-left' | 'to-right' | 'to-bottomright' | 'to-bottomleft' | 'to-topright' | 'to-topleft';
|
|
11
|
+
/**
|
|
12
|
+
* Props for the LinearGradient component.
|
|
13
|
+
*/
|
|
14
|
+
export type LinearGradientProps = {
|
|
15
|
+
/**
|
|
16
|
+
* Gradient color stops
|
|
17
|
+
*/
|
|
18
|
+
stops: GradientStop[];
|
|
19
|
+
/**
|
|
20
|
+
* Optional children to render on top of the gradient
|
|
21
|
+
*/
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* Direction preset for the gradient.
|
|
25
|
+
* @default 'to-bottom'
|
|
26
|
+
*
|
|
27
|
+
* Can be a direction preset or a custom angle in degrees.
|
|
28
|
+
* 0° points to the right, 90° points down.
|
|
29
|
+
*/
|
|
30
|
+
direction?: LinearGradientDirection | number;
|
|
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/LinearGradient/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;AAEjD,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAC/B,WAAW,GACX,QAAQ,GACR,SAAS,GACT,UAAU,GACV,gBAAgB,GAChB,eAAe,GACf,aAAa,GACb,YAAY,CAAC;AAEjB;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,uBAAuB,GAAG,MAAM,CAAC;CAC9C,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { View } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* RadialGradient - A container component that renders a radial gradient background.
|
|
4
|
+
*
|
|
5
|
+
* Uses react-native-svg to render gradients that work consistently across platforms.
|
|
6
|
+
* Extends Box, so it supports all lx style props for layout and sizing.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://ldls.vercel.app/?path=/docs/utility-radialgradient--docs Storybook}
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { RadialGradient } from '@ledgerhq/lumen-ui-rnative';
|
|
13
|
+
*
|
|
14
|
+
* // Basic usage (center to edge)
|
|
15
|
+
* <RadialGradient
|
|
16
|
+
* lx={{ height: 's200', borderRadius: 'lg' }}
|
|
17
|
+
* stops={[
|
|
18
|
+
* { color: '#845EC2', offset: 0 },
|
|
19
|
+
* { color: '#FF6F91', offset: 1 },
|
|
20
|
+
* ]}
|
|
21
|
+
* />
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const RadialGradient: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<{
|
|
25
|
+
stops: import("../gradient.types").GradientStop[];
|
|
26
|
+
children?: import("react").ReactNode;
|
|
27
|
+
center?: import("./types").RadialGradientCenter;
|
|
28
|
+
} & {
|
|
29
|
+
lx?: import("../../../../../styles").LumenViewStyle;
|
|
30
|
+
} & import("react-native").ViewProps & import("react").RefAttributes<View>>>;
|
|
31
|
+
//# sourceMappingURL=RadialGradient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadialGradient.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/Utility/Gradient/RadialGradient/RadialGradient.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAsBzC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc;;;;;;4EAqD1B,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, memo, useId, useMemo } from 'react';
|
|
3
|
+
import { StyleSheet } from 'react-native';
|
|
4
|
+
import Svg, { Defs, RadialGradient as SvgRadialGradient, Rect, Stop, } from 'react-native-svg';
|
|
5
|
+
import { useTheme } from '../../../../../styles';
|
|
6
|
+
import { Box } from '../../Box';
|
|
7
|
+
import { processGradientStops } from '../utils/resolveGradientColor';
|
|
8
|
+
const DEFAULT_CENTER = { x: 0.5, y: 0.5 };
|
|
9
|
+
const styles = StyleSheet.create({
|
|
10
|
+
gradient: {
|
|
11
|
+
...StyleSheet.absoluteFillObject,
|
|
12
|
+
width: '100%',
|
|
13
|
+
height: '100%',
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* RadialGradient - A container component that renders a radial gradient background.
|
|
18
|
+
*
|
|
19
|
+
* Uses react-native-svg to render gradients that work consistently across platforms.
|
|
20
|
+
* Extends Box, so it supports all lx style props for layout and sizing.
|
|
21
|
+
*
|
|
22
|
+
* @see {@link https://ldls.vercel.app/?path=/docs/utility-radialgradient--docs Storybook}
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* import { RadialGradient } from '@ledgerhq/lumen-ui-rnative';
|
|
27
|
+
*
|
|
28
|
+
* // Basic usage (center to edge)
|
|
29
|
+
* <RadialGradient
|
|
30
|
+
* lx={{ height: 's200', borderRadius: 'lg' }}
|
|
31
|
+
* stops={[
|
|
32
|
+
* { color: '#845EC2', offset: 0 },
|
|
33
|
+
* { color: '#FF6F91', offset: 1 },
|
|
34
|
+
* ]}
|
|
35
|
+
* />
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export const RadialGradient = memo(forwardRef(({ center = DEFAULT_CENTER, stops, children, lx = {}, ...props }, ref) => {
|
|
39
|
+
const gradientId = useId();
|
|
40
|
+
const { theme } = useTheme();
|
|
41
|
+
const processedStops = useMemo(() => {
|
|
42
|
+
return processGradientStops(stops, theme.colors.bg);
|
|
43
|
+
}, [stops, theme.colors.bg]);
|
|
44
|
+
const centerCoordinates = useMemo(() => {
|
|
45
|
+
return {
|
|
46
|
+
cx: `${center.x * 100}%`,
|
|
47
|
+
cy: `${center.y * 100}%`,
|
|
48
|
+
};
|
|
49
|
+
}, [center]);
|
|
50
|
+
return (_jsxs(Box, { ref: ref, lx: { overflow: 'hidden', ...lx }, ...props, children: [_jsxs(Svg, { style: styles.gradient, preserveAspectRatio: 'none', children: [_jsx(Defs, { children: _jsx(SvgRadialGradient, { id: gradientId, cx: centerCoordinates.cx, cy: centerCoordinates.cy, rx: '50%', ry: '50%', fx: centerCoordinates.cx, fy: centerCoordinates.cy, children: processedStops.map((stop, index) => (_jsx(Stop, { offset: `${stop.offset * 100}%`, stopColor: stop.color, stopOpacity: stop.opacity }, index))) }) }), _jsx(Rect, { x: '0', y: '0', width: '100%', height: '100%', fill: `url(#${gradientId})` })] }), children] }));
|
|
51
|
+
}));
|
|
52
|
+
RadialGradient.displayName = 'RadialGradient';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-native-web-vite';
|
|
2
|
+
import { RadialGradient } from './RadialGradient';
|
|
3
|
+
declare const meta: Meta<typeof RadialGradient>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof RadialGradient>;
|
|
6
|
+
export declare const Base: Story;
|
|
7
|
+
export declare const CenterPositionShowcase: Story;
|
|
8
|
+
export declare const WithChildren: Story;
|
|
9
|
+
export declare const WithMultipleStops: Story;
|
|
10
|
+
//# sourceMappingURL=RadialGradient.stories.d.ts.map
|
package/dist/src/lib/Components/Utility/Gradient/RadialGradient/RadialGradient.stories.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadialGradient.stories.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/Utility/Gradient/RadialGradient/RadialGradient.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAGvE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,cAAc,CAcrC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,cAAc,CAAC,CAAC;AAE7C,eAAO,MAAM,IAAI,EAAE,KASlB,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,KAuEpC,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAwB1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,KAa/B,CAAC"}
|