@ledgerhq/native-ui 0.7.15 → 0.7.17
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/components/Layout/Modals/BaseModal/index.d.ts +2 -1
- package/components/Layout/Modals/BaseModal/index.js +7 -7
- package/components/Layout/Modals/BottomDrawer/index.js +7 -1
- package/components/cta/Button/getButtonStyle.d.ts +2 -0
- package/components/cta/Button/getButtonStyle.js +12 -10
- package/components/cta/Button/index.d.ts +3 -3
- package/components/cta/Button/index.js +11 -9
- package/components/message/Log/index.d.ts +1 -1
- package/components/message/Notification/index.js +4 -1
- package/package.json +2 -2
|
@@ -6,6 +6,7 @@ export declare type BaseModalProps = {
|
|
|
6
6
|
isOpen?: boolean;
|
|
7
7
|
onClose?: () => void;
|
|
8
8
|
modalStyle?: StyleProp<ViewStyle>;
|
|
9
|
+
safeContainerStyle?: StyleProp<ViewStyle>;
|
|
9
10
|
containerStyle?: StyleProp<ViewStyle>;
|
|
10
11
|
preventBackdropClick?: boolean;
|
|
11
12
|
Icon?: IconOrElementType;
|
|
@@ -17,4 +18,4 @@ export declare type BaseModalProps = {
|
|
|
17
18
|
noCloseButton?: boolean;
|
|
18
19
|
} & Partial<ModalProps>;
|
|
19
20
|
export declare function ModalHeader({ Icon, iconColor, title, description, subtitle, }: Pick<BaseModalProps, "Icon" | "iconColor" | "title" | "description" | "subtitle">): React.ReactElement | null;
|
|
20
|
-
export default function BaseModal({ isOpen, onClose, noCloseButton, containerStyle, modalStyle, preventBackdropClick, Icon, iconColor, title, description, subtitle, children, ...rest }: BaseModalProps): React.ReactElement;
|
|
21
|
+
export default function BaseModal({ isOpen, onClose, noCloseButton, safeContainerStyle, containerStyle, modalStyle, preventBackdropClick, Icon, iconColor, title, description, subtitle, children, ...rest }: BaseModalProps): React.ReactElement;
|
|
@@ -13,12 +13,11 @@ import React from "react";
|
|
|
13
13
|
import ReactNativeModal from "react-native-modal";
|
|
14
14
|
import styled from "styled-components/native";
|
|
15
15
|
import sizes from "../../../../helpers/getDeviceSize";
|
|
16
|
-
import Link from "../../../cta/Link";
|
|
17
|
-
import CloseMedium from "@ledgerhq/icons-ui/native/CloseMedium";
|
|
18
16
|
import Text from "../../../Text";
|
|
19
17
|
import { BoxedIcon } from "../../../Icon";
|
|
20
18
|
import { Flex } from "../../index";
|
|
21
19
|
import { space } from "styled-system";
|
|
20
|
+
import { Icons } from "../../../../assets";
|
|
22
21
|
const { width, height } = sizes;
|
|
23
22
|
const SafeContainer = styled.SafeAreaView `
|
|
24
23
|
background-color: ${(p) => p.theme.colors.background.main};
|
|
@@ -39,10 +38,11 @@ const CloseContainer = styled.View `
|
|
|
39
38
|
margin-bottom: ${(p) => p.theme.space[7]}px;
|
|
40
39
|
`;
|
|
41
40
|
const ClosePressableExtendedBounds = styled.TouchableOpacity.attrs({
|
|
42
|
-
p:
|
|
43
|
-
m: -5,
|
|
41
|
+
p: 3,
|
|
44
42
|
}) `
|
|
45
43
|
${space};
|
|
44
|
+
border-radius: 100px;
|
|
45
|
+
background-color: ${(p) => p.theme.colors.neutral.c30};
|
|
46
46
|
`;
|
|
47
47
|
const StyledTitle = styled(Text).attrs({ variant: "h2" }) `
|
|
48
48
|
text-transform: uppercase;
|
|
@@ -69,7 +69,7 @@ export function ModalHeader({ Icon, iconColor, title, description, subtitle, })
|
|
|
69
69
|
description && (React.createElement(Text, { variant: "body", color: "neutral.c70", textAlign: "center", mt: 6 }, description))));
|
|
70
70
|
}
|
|
71
71
|
export default function BaseModal(_a) {
|
|
72
|
-
var { isOpen, onClose = () => { }, noCloseButton, containerStyle = {}, modalStyle = {}, preventBackdropClick, Icon, iconColor, title, description, subtitle, children } = _a, rest = __rest(_a, ["isOpen", "onClose", "noCloseButton", "containerStyle", "modalStyle", "preventBackdropClick", "Icon", "iconColor", "title", "description", "subtitle", "children"]);
|
|
72
|
+
var { isOpen, onClose = () => { }, noCloseButton, safeContainerStyle = {}, containerStyle = {}, modalStyle = {}, preventBackdropClick, Icon, iconColor, title, description, subtitle, children } = _a, rest = __rest(_a, ["isOpen", "onClose", "noCloseButton", "safeContainerStyle", "containerStyle", "modalStyle", "preventBackdropClick", "Icon", "iconColor", "title", "description", "subtitle", "children"]);
|
|
73
73
|
const backDropProps = preventBackdropClick
|
|
74
74
|
? {}
|
|
75
75
|
: {
|
|
@@ -78,11 +78,11 @@ export default function BaseModal(_a) {
|
|
|
78
78
|
onSwipeComplete: onClose,
|
|
79
79
|
};
|
|
80
80
|
return (React.createElement(ReactNativeModal, Object.assign({}, rest, backDropProps, { isVisible: isOpen, deviceWidth: width, deviceHeight: height, useNativeDriver: true, useNativeDriverForBackdrop: true, hideModalContentWhileAnimating: true, onModalHide: onClose, style: [defaultModalStyle, modalStyle] }),
|
|
81
|
-
React.createElement(SafeContainer,
|
|
81
|
+
React.createElement(SafeContainer, { style: safeContainerStyle },
|
|
82
82
|
React.createElement(Container, { style: containerStyle },
|
|
83
83
|
!noCloseButton && (React.createElement(CloseContainer, null,
|
|
84
84
|
React.createElement(ClosePressableExtendedBounds, { onPress: onClose },
|
|
85
|
-
React.createElement(
|
|
85
|
+
React.createElement(Icons.CloseMedium, { color: "neutral.c100", size: "20px" })))),
|
|
86
86
|
React.createElement(ModalHeader, { Icon: Icon, iconColor: iconColor, title: title, description: description, subtitle: subtitle }),
|
|
87
87
|
React.createElement(ContentContainer, null, children)))));
|
|
88
88
|
}
|
|
@@ -18,6 +18,10 @@ const modalStyleOverrides = StyleSheet.create({
|
|
|
18
18
|
justifyContent: "flex-end",
|
|
19
19
|
margin: 0,
|
|
20
20
|
},
|
|
21
|
+
safeContainer: {
|
|
22
|
+
borderTopLeftRadius: 24,
|
|
23
|
+
borderTopRightRadius: 24,
|
|
24
|
+
},
|
|
21
25
|
container: {
|
|
22
26
|
minHeight: 0,
|
|
23
27
|
paddingLeft: 24,
|
|
@@ -25,9 +29,11 @@ const modalStyleOverrides = StyleSheet.create({
|
|
|
25
29
|
paddingTop: 24,
|
|
26
30
|
paddingBottom: 24,
|
|
27
31
|
maxHeight: "100%",
|
|
32
|
+
borderTopLeftRadius: 24,
|
|
33
|
+
borderTopRightRadius: 24,
|
|
28
34
|
},
|
|
29
35
|
});
|
|
30
36
|
export default function BottomDrawer(_a) {
|
|
31
37
|
var { children } = _a, restProps = __rest(_a, ["children"]);
|
|
32
|
-
return (React.createElement(BaseModal, Object.assign({}, restProps, { modalStyle: modalStyleOverrides.modal, containerStyle: modalStyleOverrides.container, propagateSwipe: true }), children));
|
|
38
|
+
return (React.createElement(BaseModal, Object.assign({}, restProps, { modalStyle: modalStyleOverrides.modal, safeContainerStyle: modalStyleOverrides.safeContainer, containerStyle: modalStyleOverrides.container, propagateSwipe: true }), children));
|
|
33
39
|
}
|
|
@@ -5,6 +5,8 @@ export declare function getButtonColors(colors: Theme["colors"]): {
|
|
|
5
5
|
primaryColor: string;
|
|
6
6
|
secondaryColor: string;
|
|
7
7
|
tertiaryColor?: string;
|
|
8
|
+
pressedColor?: string;
|
|
9
|
+
pressedOutlineColor?: string;
|
|
8
10
|
};
|
|
9
11
|
};
|
|
10
12
|
export declare function getButtonColorStyle(colors: Theme["colors"], props: ButtonProps): {
|
|
@@ -2,7 +2,7 @@ export function getButtonColors(colors) {
|
|
|
2
2
|
return {
|
|
3
3
|
default: {
|
|
4
4
|
primaryColor: colors.neutral.c100,
|
|
5
|
-
secondaryColor: "rgba(0,0,
|
|
5
|
+
secondaryColor: "rgba(0,0,255,0)",
|
|
6
6
|
},
|
|
7
7
|
disabled: {
|
|
8
8
|
primaryColor: colors.neutral.c50,
|
|
@@ -11,41 +11,43 @@ export function getButtonColors(colors) {
|
|
|
11
11
|
main: {
|
|
12
12
|
primaryColor: colors.neutral.c00,
|
|
13
13
|
secondaryColor: colors.neutral.c100,
|
|
14
|
+
pressedColor: colors.neutral.c100a06,
|
|
15
|
+
pressedOutlineColor: colors.neutral.c100a01,
|
|
14
16
|
},
|
|
15
17
|
shade: {
|
|
16
18
|
primaryColor: colors.neutral.c00,
|
|
17
19
|
secondaryColor: colors.neutral.c100,
|
|
18
20
|
tertiaryColor: colors.neutral.c40,
|
|
21
|
+
pressedColor: colors.neutral.c100a06,
|
|
22
|
+
pressedOutlineColor: colors.neutral.c100a01,
|
|
19
23
|
},
|
|
20
24
|
error: {
|
|
21
25
|
primaryColor: colors.neutral.c00,
|
|
22
26
|
secondaryColor: colors.error.c100,
|
|
27
|
+
pressedColor: colors.error.c100a07,
|
|
28
|
+
pressedOutlineColor: colors.error.c100a025,
|
|
23
29
|
},
|
|
24
30
|
color: {
|
|
25
31
|
primaryColor: colors.neutral.c00,
|
|
26
32
|
secondaryColor: colors.primary.c80,
|
|
33
|
+
pressedColor: colors.primary.c80a70,
|
|
34
|
+
pressedOutlineColor: colors.primary.c70a025,
|
|
27
35
|
},
|
|
28
36
|
};
|
|
29
37
|
}
|
|
30
38
|
export function getButtonColorStyle(colors, props) {
|
|
31
39
|
const { outline, type = "main", disabled } = props;
|
|
32
|
-
const { primaryColor, secondaryColor, tertiaryColor } = getButtonColors(colors)[disabled ? "disabled" : type];
|
|
40
|
+
const { primaryColor, secondaryColor, tertiaryColor, pressedColor, pressedOutlineColor } = getButtonColors(colors)[disabled ? "disabled" : type];
|
|
33
41
|
if (outline) {
|
|
34
42
|
return {
|
|
35
43
|
text: { color: disabled ? primaryColor : secondaryColor },
|
|
36
|
-
button: {
|
|
37
|
-
backgroundColor: "transparent",
|
|
38
|
-
borderColor: disabled ? primaryColor : tertiaryColor !== null && tertiaryColor !== void 0 ? tertiaryColor : secondaryColor,
|
|
39
|
-
borderWidth: 1,
|
|
40
|
-
},
|
|
44
|
+
button: Object.assign({ backgroundColor: "transparent", borderColor: disabled ? primaryColor : tertiaryColor !== null && tertiaryColor !== void 0 ? tertiaryColor : secondaryColor, borderWidth: 1 }, (pressedOutlineColor && { underlayColor: pressedOutlineColor })),
|
|
41
45
|
};
|
|
42
46
|
}
|
|
43
47
|
else {
|
|
44
48
|
return {
|
|
45
49
|
text: { color: primaryColor },
|
|
46
|
-
button: {
|
|
47
|
-
backgroundColor: secondaryColor,
|
|
48
|
-
},
|
|
50
|
+
button: Object.assign({ backgroundColor: secondaryColor }, (pressedColor && { underlayColor: pressedColor })),
|
|
49
51
|
};
|
|
50
52
|
}
|
|
51
53
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="styled-components-react-native" />
|
|
2
2
|
import React from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { TouchableHighlight, TouchableHighlightProps } from "react-native";
|
|
4
4
|
import { BaseStyledProps } from "../../styled";
|
|
5
|
-
export declare type ButtonProps =
|
|
5
|
+
export declare type ButtonProps = TouchableHighlightProps & BaseStyledProps & {
|
|
6
6
|
Icon?: React.ComponentType<{
|
|
7
7
|
size: number;
|
|
8
8
|
color: string;
|
|
@@ -18,7 +18,7 @@ export declare type ButtonProps = TouchableOpacityProps & BaseStyledProps & {
|
|
|
18
18
|
pending?: boolean;
|
|
19
19
|
displayContentWhenPending?: boolean;
|
|
20
20
|
};
|
|
21
|
-
export declare const Base: import("styled-components").StyledComponent<typeof
|
|
21
|
+
export declare const Base: import("styled-components").StyledComponent<typeof TouchableHighlight, import("styled-components").DefaultTheme, {
|
|
22
22
|
iconButton?: boolean | undefined;
|
|
23
23
|
sizeVariant?: ButtonProps["size"];
|
|
24
24
|
} & Omit<ButtonProps, "size">, never>;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import React, { useCallback, useState, useMemo } from "react";
|
|
11
11
|
import styled, { useTheme } from "styled-components/native";
|
|
12
|
-
import { ActivityIndicator,
|
|
12
|
+
import { ActivityIndicator, TouchableHighlight, View } from "react-native";
|
|
13
13
|
import { buttonSizeStyle, getButtonColorStyle } from "../../cta/Button/getButtonStyle";
|
|
14
14
|
import { ctaIconSize, ctaTextType } from "../../cta/getCtaStyle";
|
|
15
15
|
import Text from "../../Text";
|
|
@@ -18,7 +18,7 @@ import baseStyled from "../../styled";
|
|
|
18
18
|
const IconContainer = styled.View `
|
|
19
19
|
${(p) => p.iconButton ? "" : p.iconPosition === "left" ? `margin-right: 10px;` : `margin-left: 10px;`}
|
|
20
20
|
`;
|
|
21
|
-
export const Base = baseStyled(
|
|
21
|
+
export const Base = baseStyled(TouchableHighlight).attrs((p) => (Object.assign(Object.assign({}, getButtonColorStyle(p.theme.colors, p).button), {
|
|
22
22
|
// Avoid conflict with styled-system's size property by nulling size and renaming it
|
|
23
23
|
size: undefined, sizeVariant: p.size }))) `
|
|
24
24
|
|
|
@@ -71,10 +71,11 @@ const ButtonContainer = (props) => {
|
|
|
71
71
|
const Button = (props) => {
|
|
72
72
|
const { Icon, children, type = "default", iconName, disabled = false, pending = false, displayContentWhenPending = false, } = props;
|
|
73
73
|
const theme = useTheme();
|
|
74
|
-
return (React.createElement(Base, Object.assign({}, props, { type: type, iconButton: (!!Icon || !!iconName) && !children, activeOpacity:
|
|
75
|
-
React.createElement(
|
|
76
|
-
|
|
77
|
-
React.createElement(
|
|
74
|
+
return (React.createElement(Base, Object.assign({}, props, { type: type, iconButton: (!!Icon || !!iconName) && !children, activeOpacity: 1, disabled: disabled || pending }),
|
|
75
|
+
React.createElement(View, null,
|
|
76
|
+
React.createElement(ButtonContainer, Object.assign({}, props, { type: type, hide: pending && !displayContentWhenPending })),
|
|
77
|
+
pending && !displayContentWhenPending ? (React.createElement(SpinnerContainer, { displayContentWhenPending: displayContentWhenPending },
|
|
78
|
+
React.createElement(ActivityIndicator, { color: theme.colors.neutral.c50, animating: true }))) : null)));
|
|
78
79
|
};
|
|
79
80
|
export const PromisableButton = (props) => {
|
|
80
81
|
const { Icon, children, onPress, type = "main", disabled = false, iconName } = props;
|
|
@@ -92,8 +93,9 @@ export const PromisableButton = (props) => {
|
|
|
92
93
|
}
|
|
93
94
|
}), [onPress]);
|
|
94
95
|
return (React.createElement(Base, Object.assign({}, props, { type: type, iconButton: (!!Icon || !!iconName) && !children, disabled: disabled || spinnerOn, onPress: onPressHandler }),
|
|
95
|
-
React.createElement(
|
|
96
|
-
|
|
97
|
-
React.createElement(
|
|
96
|
+
React.createElement(View, null,
|
|
97
|
+
React.createElement(ButtonContainer, Object.assign({}, props, { type: type, hide: spinnerOn })),
|
|
98
|
+
React.createElement(SpinnerContainer, null,
|
|
99
|
+
React.createElement(ActivityIndicator, { color: theme.colors.neutral.c50, animating: spinnerOn })))));
|
|
98
100
|
};
|
|
99
101
|
export default Button;
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { BaseTextProps as TextProps } from "../../Text";
|
|
3
3
|
import { FlexBoxProps } from "../../Layout/Flex";
|
|
4
4
|
export declare type Props = React.PropsWithChildren<FlexBoxProps & {
|
|
5
|
-
extraTextProps?: TextProps
|
|
5
|
+
extraTextProps?: Omit<TextProps, "children">;
|
|
6
6
|
}>;
|
|
7
7
|
declare function Log({ children, extraTextProps }: Props): JSX.Element;
|
|
8
8
|
declare const _default: React.MemoExoticComponent<typeof Log>;
|
|
@@ -6,6 +6,7 @@ import Text from "../../Text";
|
|
|
6
6
|
import CloseMedium from "@ledgerhq/icons-ui/native/CloseMedium";
|
|
7
7
|
import { Flex } from "../../Layout";
|
|
8
8
|
import { space } from "styled-system";
|
|
9
|
+
import { ExternalLinkMedium } from "@ledgerhq/icons-ui/native";
|
|
9
10
|
const NotificationContainer = styled.View `
|
|
10
11
|
display: flex;
|
|
11
12
|
width: 100%;
|
|
@@ -35,7 +36,9 @@ export default function Notification({ Icon, iconColor, variant = "primary", num
|
|
|
35
36
|
!!subtitle && (React.createElement(Text, { variant: "body", fontWeight: "medium", color: variant === "primary" ? colors.neutral.c00 : colors.neutral.c80, mt: 2 }, subtitle)),
|
|
36
37
|
linkText && onLinkPress && (React.createElement(Flex, { mt: 3 },
|
|
37
38
|
React.createElement(TouchableOpacity, { onPress: onLinkPress },
|
|
38
|
-
React.createElement(
|
|
39
|
+
React.createElement(Flex, { flexDirection: "row", alignItems: "center" },
|
|
40
|
+
React.createElement(Text, { variant: "body", fontWeight: "semiBold", color: textColor, mr: 3 }, linkText),
|
|
41
|
+
React.createElement(ExternalLinkMedium, { size: 16, color: textColor })))))),
|
|
39
42
|
onClose && (React.createElement(FlexBox, { marginLeft: "auto", pl: 16 },
|
|
40
43
|
React.createElement(ClosePressableExtendedBounds, { onPress: onClose },
|
|
41
44
|
React.createElement(CloseMedium, { size: 14, color: textColor }))))));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/native-ui",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.17",
|
|
4
4
|
"description": "Ledger Live - React Native UI",
|
|
5
5
|
"repository": "https://github.com/LedgerHQ/ui",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@ledgerhq/icons-ui": "^0.2.4",
|
|
19
|
-
"@ledgerhq/ui-shared": "^0.1.
|
|
19
|
+
"@ledgerhq/ui-shared": "^0.1.7",
|
|
20
20
|
"@types/color": "^3.0.2",
|
|
21
21
|
"@types/react": "^17.0.37",
|
|
22
22
|
"@types/react-native": "^0.65.9",
|