@ledgerhq/native-ui 0.7.17-nightly.0 → 0.7.18-universal.0
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/lib/components/Layout/Modals/BaseModal/index.d.ts +2 -1
- package/lib/components/Layout/Modals/BaseModal/index.js +7 -7
- package/lib/components/Layout/Modals/BottomDrawer/index.js +7 -1
- package/lib/components/cta/Button/getButtonStyle.d.ts +2 -0
- package/lib/components/cta/Button/getButtonStyle.js +12 -10
- package/lib/components/cta/Button/index.d.ts +3 -3
- package/lib/components/cta/Button/index.js +11 -9
- package/package.json +5 -5
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/native-ui",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.18-universal.0",
|
|
4
4
|
"description": "Ledger Live - Mobile UI",
|
|
5
5
|
"repository": "https://github.com/LedgerHQ/ui",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"lib/**/*"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@ledgerhq/icons-ui": "^0.2.
|
|
29
|
-
"@ledgerhq/ui-shared": "^0.1.
|
|
28
|
+
"@ledgerhq/icons-ui": "^0.2.4",
|
|
29
|
+
"@ledgerhq/ui-shared": "^0.1.8-universal.0",
|
|
30
30
|
"@types/color": "^3.0.3",
|
|
31
31
|
"@types/react": "^17.0.39",
|
|
32
32
|
"@types/react-native": "^0.65.9",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"glob": "^7.2.0",
|
|
109
109
|
"metro": "^0.67.0",
|
|
110
110
|
"metro-config": "^0.67.0",
|
|
111
|
-
"metro-extra-config": "1.0.
|
|
111
|
+
"metro-extra-config": "1.0.0",
|
|
112
112
|
"metro-minify-uglify": "^0.67.0",
|
|
113
113
|
"metro-react-native-babel-preset": "^0.67.0",
|
|
114
114
|
"metro-runtime": "^0.67.0",
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
"build": "tsc -p tsconfig.prod.json && node scripts/postBuild",
|
|
136
136
|
"prebuild:storybook": "pnpm -F ui-shared -F icons-ui build",
|
|
137
137
|
"build:storybook": "pnpm build-storybook -o web-build",
|
|
138
|
-
"watch": "tsc --watch",
|
|
138
|
+
"watch": "tsc -p tsconfig.prod.json --watch",
|
|
139
139
|
"clean": "rimraf lib",
|
|
140
140
|
"eject": "expo eject",
|
|
141
141
|
"ios": "expo start --ios",
|