@ledgerhq/native-ui 0.7.10 → 0.7.11
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.
|
@@ -15,6 +15,8 @@ export declare type ButtonProps = TouchableOpacityProps & BaseStyledProps & {
|
|
|
15
15
|
disabled?: boolean;
|
|
16
16
|
pressed?: boolean;
|
|
17
17
|
children?: React.ReactNode;
|
|
18
|
+
pending?: boolean;
|
|
19
|
+
displayContentWhenPending?: boolean;
|
|
18
20
|
};
|
|
19
21
|
export declare const Base: import("styled-components").StyledComponent<typeof TouchableOpacity, import("styled-components").DefaultTheme, {
|
|
20
22
|
iconButton?: boolean | undefined;
|
|
@@ -45,7 +45,7 @@ const Container = styled.View `
|
|
|
45
45
|
opacity: ${(p) => (p.hide ? 0 : 1)};
|
|
46
46
|
`;
|
|
47
47
|
const SpinnerContainer = styled.View `
|
|
48
|
-
position: absolute;
|
|
48
|
+
position: ${(p) => (p.displayContentWhenPending ? "relative" : "absolute")};
|
|
49
49
|
top: 0;
|
|
50
50
|
left: 0;
|
|
51
51
|
right: 0;
|
|
@@ -55,20 +55,26 @@ const SpinnerContainer = styled.View `
|
|
|
55
55
|
justify-content: center;
|
|
56
56
|
`;
|
|
57
57
|
const ButtonContainer = (props) => {
|
|
58
|
-
const { Icon, iconPosition = "right", children, hide = false, size = "medium", iconName } = props;
|
|
58
|
+
const { Icon, iconPosition = "right", children, hide = false, size = "medium", iconName, pending, displayContentWhenPending, } = props;
|
|
59
59
|
const theme = useTheme();
|
|
60
60
|
const { text } = getButtonColorStyle(theme.colors, props);
|
|
61
61
|
const IconNode = useMemo(() => (iconName && React.createElement(IconComponent, { name: iconName, size: ctaIconSize[size], color: text.color })) ||
|
|
62
62
|
(Icon && React.createElement(Icon, { size: ctaIconSize[size], color: text.color })), [iconName, size, Icon, text.color]);
|
|
63
|
+
const textColor = useMemo(() => (pending ? theme.colors.neutral.c50 : text.color), [pending, theme.colors.neutral.c50, text.color]);
|
|
63
64
|
return (React.createElement(Container, { hide: hide },
|
|
64
|
-
iconPosition === "right" && children ? (React.createElement(Text, { variant: ctaTextType[size], fontWeight: "semiBold", color:
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
iconPosition === "right" && children ? (React.createElement(Text, { variant: ctaTextType[size], fontWeight: "semiBold", color: textColor }, children)) : null,
|
|
66
|
+
pending && displayContentWhenPending ? (React.createElement(IconContainer, { iconPosition: iconPosition },
|
|
67
|
+
React.createElement(SpinnerContainer, { displayContentWhenPending: true },
|
|
68
|
+
React.createElement(ActivityIndicator, { color: theme.colors.neutral.c50, animating: true })))) : IconNode ? (React.createElement(IconContainer, { iconButton: !children, iconPosition: iconPosition }, IconNode)) : null,
|
|
69
|
+
iconPosition === "left" && children ? (React.createElement(Text, { variant: ctaTextType[size], fontWeight: "semiBold", color: textColor }, children)) : null));
|
|
67
70
|
};
|
|
68
71
|
const Button = (props) => {
|
|
69
|
-
const { Icon, children, type = "default", iconName } = props;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
const { Icon, children, type = "default", iconName, disabled = false, pending = false, displayContentWhenPending = false, } = props;
|
|
73
|
+
const theme = useTheme();
|
|
74
|
+
return (React.createElement(Base, Object.assign({}, props, { type: type, iconButton: (!!Icon || !!iconName) && !children, activeOpacity: 0.5, disabled: disabled || pending }),
|
|
75
|
+
React.createElement(ButtonContainer, Object.assign({}, props, { type: type, hide: pending && !displayContentWhenPending })),
|
|
76
|
+
pending && !displayContentWhenPending ? (React.createElement(SpinnerContainer, { displayContentWhenPending: displayContentWhenPending },
|
|
77
|
+
React.createElement(ActivityIndicator, { color: theme.colors.neutral.c50, animating: true }))) : null));
|
|
72
78
|
};
|
|
73
79
|
export const PromisableButton = (props) => {
|
|
74
80
|
const { Icon, children, onPress, type = "main", disabled = false, iconName } = props;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/native-ui",
|
|
3
|
-
"version": "0.7.
|
|
4
|
-
"description": "Ledger Live -
|
|
3
|
+
"version": "0.7.11",
|
|
4
|
+
"description": "Ledger Live - React Native UI",
|
|
5
5
|
"repository": "https://github.com/LedgerHQ/ui",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Ledger Live Team <team-live@ledger.fr>",
|