@ledgerhq/native-ui 0.4.0 → 0.6.2
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/README.md +1 -4
- package/assets/logos/LedgerLiveAltRegular.d.ts +0 -1
- package/assets/logos/LedgerLiveRegular.d.ts +0 -1
- package/components/Carousel/index.d.ts +45 -0
- package/components/Carousel/index.js +74 -0
- package/components/Form/Checkbox/index.d.ts +3 -3
- package/components/Form/Checkbox/index.js +1 -1
- package/components/Form/Input/BaseInput/index.d.ts +83 -5
- package/components/Form/Input/BaseInput/index.js +6 -6
- package/components/Form/Input/LegendInput/index.d.ts +14 -3
- package/components/Form/Input/LegendInput/index.js +3 -2
- package/components/Form/Input/NumberInput/index.d.ts +16 -5
- package/components/Form/Input/NumberInput/index.js +5 -4
- package/components/Form/Input/QrCodeInput/index.d.ts +15 -4
- package/components/Form/Input/QrCodeInput/index.js +3 -2
- package/components/Form/Input/SearchInput/index.d.ts +13 -2
- package/components/Form/Input/SearchInput/index.js +3 -2
- package/components/Form/SelectableList.d.ts +12 -3
- package/components/Form/SelectableList.js +9 -8
- package/components/Form/Slider/index.d.ts +0 -1
- package/components/Form/Slider/index.native.d.ts +0 -1
- package/components/Form/Slider/index.native.js +1 -1
- package/components/Form/Switch/index.d.ts +1 -2
- package/components/Form/Switch/index.js +2 -2
- package/components/Form/Toggle/index.d.ts +1 -2
- package/components/Form/Toggle/index.js +1 -1
- package/components/Form/index.d.ts +1 -0
- package/components/Form/index.js +1 -0
- package/components/Icon/BoxedIcon.d.ts +49 -0
- package/components/Icon/BoxedIcon.js +85 -0
- package/components/Icon/Icon.d.ts +9 -0
- package/components/Icon/Icon.js +20 -0
- package/components/Icon/IconBox/index.d.ts +2 -4
- package/components/Icon/IconBox/index.js +1 -2
- package/components/Icon/index.d.ts +2 -0
- package/components/Icon/index.js +2 -0
- package/components/Icon/type.d.ts +7 -0
- package/components/Icon/type.js +1 -0
- package/components/Layout/Box/index.d.ts +11 -0
- package/components/Layout/Box/index.js +3 -0
- package/components/Layout/Collapse/Accordion/index.js +1 -1
- package/components/Layout/Flex/index.d.ts +11 -12
- package/components/Layout/Flex/index.js +2 -8
- package/components/Layout/List/IconBoxList/index.d.ts +10 -0
- package/components/Layout/List/IconBoxList/index.js +19 -0
- package/components/Layout/List/List/index.d.ts +13 -0
- package/components/Layout/List/List/index.js +29 -0
- package/components/Layout/List/NumberedList/index.d.ts +9 -0
- package/components/Layout/List/NumberedList/index.js +20 -0
- package/components/Layout/List/TipList/index.d.ts +9 -0
- package/components/Layout/List/TipList/index.js +20 -0
- package/components/Layout/List/index.d.ts +4 -0
- package/components/Layout/List/index.js +4 -0
- package/components/Layout/ScrollContainer/index.d.ts +2 -1
- package/components/Layout/ScrollContainer/index.js +2 -2
- package/components/Layout/ScrollContainerHeader/Header.d.ts +1 -2
- package/components/Layout/ScrollContainerHeader/Header.js +23 -16
- package/components/Layout/ScrollContainerHeader/index.d.ts +3 -2
- package/components/Layout/ScrollContainerHeader/index.js +9 -4
- package/components/Layout/index.d.ts +2 -0
- package/components/Layout/index.js +2 -0
- package/components/Loader/InfiniteLoader/index.d.ts +9 -0
- package/components/Loader/InfiniteLoader/index.js +58 -0
- package/components/Loader/ProgressLoader/index.d.ts +11 -0
- package/components/Loader/ProgressLoader/index.js +24 -0
- package/components/Loader/index.d.ts +2 -11
- package/components/Loader/index.js +2 -24
- package/components/Navigation/FlowStepper/index.d.ts +70 -0
- package/components/Navigation/FlowStepper/index.js +36 -0
- package/components/Navigation/SlideIndicator/index.d.ts +1 -1
- package/components/Navigation/SlideIndicator/index.js +13 -7
- package/components/Navigation/Stepper/index.d.ts +1 -1
- package/components/Navigation/Stepper/index.js +4 -4
- package/components/Navigation/index.d.ts +1 -0
- package/components/Navigation/index.js +1 -0
- package/components/ProgressBar/index.d.ts +15 -0
- package/components/ProgressBar/index.js +33 -0
- package/components/Tabs/Chip/index.d.ts +5 -0
- package/components/Tabs/Chip/index.js +20 -0
- package/components/Tabs/Graph/index.d.ts +5 -0
- package/components/Tabs/Graph/index.js +21 -0
- package/components/Tabs/TemplateTabs/index.d.ts +29 -0
- package/components/Tabs/TemplateTabs/index.js +14 -0
- package/components/Tabs/index.d.ts +2 -0
- package/components/Tabs/index.js +2 -0
- package/components/Text/getTextStyle.d.ts +1 -0
- package/components/Text/getTextStyle.js +5 -0
- package/components/Text/index.d.ts +6 -8
- package/components/Text/index.js +15 -8
- package/components/chart/index.d.ts +0 -1
- package/components/cta/Button/index.d.ts +5 -15
- package/components/cta/Button/index.js +21 -24
- package/components/cta/Link/index.js +1 -5
- package/components/index.d.ts +5 -2
- package/components/index.js +6 -2
- package/components/message/Alert/index.d.ts +1 -2
- package/components/message/Alert/index.js +2 -2
- package/components/{drawer → message}/Notification/index.d.ts +5 -4
- package/components/{drawer → message}/Notification/index.js +16 -12
- package/components/message/index.d.ts +1 -0
- package/components/message/index.js +1 -0
- package/components/styled.d.ts +15 -0
- package/components/styled.js +12 -0
- package/components/transitions/Fade.d.ts +5 -0
- package/components/transitions/Fade.js +32 -0
- package/components/transitions/Slide.d.ts +11 -0
- package/components/transitions/Slide.js +49 -0
- package/components/transitions/Transition.d.ts +49 -0
- package/components/transitions/Transition.js +39 -0
- package/components/transitions/index.d.ts +4 -0
- package/components/transitions/index.js +4 -0
- package/components/transitions/types.d.ts +21 -0
- package/components/transitions/types.js +1 -0
- package/package.json +4 -4
- package/styles/StyleProvider.d.ts +1 -1
- package/styles/StyleProvider.js +1 -1
- package/styles/helpers.js +1 -3
- package/styles/theme.js +2 -0
- package/assets/fonts/.DS_Store +0 -0
- package/assets/fonts/alpha/.DS_Store +0 -0
- package/components/Navigation/ToggleGroup/index.d.ts +0 -15
- package/components/Navigation/ToggleGroup/index.js +0 -25
- package/components/drawer/index.d.ts +0 -1
- package/components/drawer/index.js +0 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/// <reference types="styled-components-react-native" />
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { SpaceProps } from "styled-system";
|
|
4
3
|
import { TouchableOpacity, TouchableOpacityProps } from "react-native";
|
|
5
|
-
|
|
4
|
+
import { BaseStyledProps } from "../../styled";
|
|
5
|
+
export declare type ButtonProps = TouchableOpacityProps & BaseStyledProps & {
|
|
6
6
|
Icon?: React.ComponentType<{
|
|
7
7
|
size: number;
|
|
8
8
|
color: string;
|
|
9
9
|
}> | null;
|
|
10
|
+
iconName?: string;
|
|
10
11
|
type?: "main" | "shade" | "error" | "color" | "default";
|
|
11
12
|
size?: "small" | "medium" | "large";
|
|
12
13
|
iconPosition?: "right" | "left";
|
|
@@ -17,19 +18,8 @@ export declare type ButtonProps = TouchableOpacityProps & SpaceProps & {
|
|
|
17
18
|
};
|
|
18
19
|
export declare const Base: import("styled-components").StyledComponent<typeof TouchableOpacity, import("styled-components").DefaultTheme, {
|
|
19
20
|
iconButton?: boolean | undefined;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
size: number;
|
|
23
|
-
color: string;
|
|
24
|
-
}> | null | undefined;
|
|
25
|
-
type?: "default" | "main" | "shade" | "error" | "color" | undefined;
|
|
26
|
-
size?: "large" | "small" | "medium" | undefined;
|
|
27
|
-
iconPosition?: "left" | "right" | undefined;
|
|
28
|
-
outline?: boolean | undefined;
|
|
29
|
-
disabled?: boolean | undefined;
|
|
30
|
-
pressed?: boolean | undefined;
|
|
31
|
-
children?: React.ReactNode;
|
|
32
|
-
}, never>;
|
|
21
|
+
sizeVariant?: ButtonProps["size"];
|
|
22
|
+
} & Omit<ButtonProps, "size">, never>;
|
|
33
23
|
declare const Button: (props: ButtonProps) => React.ReactElement;
|
|
34
24
|
export declare const PromisableButton: (props: ButtonProps) => React.ReactElement;
|
|
35
25
|
export default Button;
|
|
@@ -7,26 +7,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import React, { useCallback, useState } from "react";
|
|
10
|
+
import React, { useCallback, useState, useMemo } from "react";
|
|
11
11
|
import styled, { useTheme } from "styled-components/native";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { buttonSizeStyle, getButtonColorStyle, } from "../../cta/Button/getButtonStyle";
|
|
12
|
+
import { ActivityIndicator, TouchableOpacity } from "react-native";
|
|
13
|
+
import { buttonSizeStyle, getButtonColorStyle } from "../../cta/Button/getButtonStyle";
|
|
15
14
|
import { ctaIconSize, ctaTextType } from "../../cta/getCtaStyle";
|
|
16
15
|
import Text from "../../Text";
|
|
16
|
+
import { Icon as IconComponent } from "../../Icon";
|
|
17
|
+
import baseStyled from "../../styled";
|
|
17
18
|
const IconContainer = styled.View `
|
|
18
|
-
${(p) => p.iconButton
|
|
19
|
-
? ""
|
|
20
|
-
: p.iconPosition === "left"
|
|
21
|
-
? `margin-right: 10px;`
|
|
22
|
-
: `margin-left: 10px;`}
|
|
19
|
+
${(p) => p.iconButton ? "" : p.iconPosition === "left" ? `margin-right: 10px;` : `margin-left: 10px;`}
|
|
23
20
|
`;
|
|
24
|
-
export const Base =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
export const Base = baseStyled(TouchableOpacity).attrs((p) => (Object.assign(Object.assign({}, getButtonColorStyle(p.theme.colors, p).button), {
|
|
22
|
+
// Avoid conflict with styled-system's size property by nulling size and renaming it
|
|
23
|
+
size: undefined, sizeVariant: p.size }))) `
|
|
24
|
+
|
|
28
25
|
border-radius: ${(p) => p.theme.space[10]}px;
|
|
29
|
-
height: ${(p) => p.theme.space[10]}px;
|
|
30
26
|
padding: 0 ${(p) => p.theme.space[7]}px;
|
|
31
27
|
flex-direction: row;
|
|
32
28
|
border-style: solid;
|
|
@@ -36,7 +32,7 @@ export const Base = styled(TouchableOpacity).attrs((p) => (Object.assign({}, get
|
|
|
36
32
|
align-content: center;
|
|
37
33
|
overflow: hidden;
|
|
38
34
|
position: relative;
|
|
39
|
-
${(p) => buttonSizeStyle[p.
|
|
35
|
+
${(p) => buttonSizeStyle[p.sizeVariant || "medium"]}
|
|
40
36
|
|
|
41
37
|
${(p) => (p.iconButton ? `padding: 0; width: ${p.theme.space[10]}px;` : "")}
|
|
42
38
|
`;
|
|
@@ -59,22 +55,23 @@ const SpinnerContainer = styled.View `
|
|
|
59
55
|
justify-content: center;
|
|
60
56
|
`;
|
|
61
57
|
const ButtonContainer = (props) => {
|
|
62
|
-
const { Icon, iconPosition = "right", children, hide = false, size = "medium", } = props;
|
|
58
|
+
const { Icon, iconPosition = "right", children, hide = false, size = "medium", iconName } = props;
|
|
63
59
|
const theme = useTheme();
|
|
64
60
|
const { text } = getButtonColorStyle(theme.colors, props);
|
|
61
|
+
const IconNode = useMemo(() => (iconName && React.createElement(IconComponent, { name: iconName, size: ctaIconSize[size], color: text.color })) ||
|
|
62
|
+
(Icon && React.createElement(Icon, { size: ctaIconSize[size], color: text.color })), [iconName, size, Icon, text.color]);
|
|
65
63
|
return (React.createElement(Container, { hide: hide },
|
|
66
64
|
iconPosition === "right" && children ? (React.createElement(Text, { variant: ctaTextType[size], fontWeight: "semiBold", color: text.color }, children)) : null,
|
|
67
|
-
|
|
68
|
-
React.createElement(Icon, { size: ctaIconSize[size], color: text.color }))) : null,
|
|
65
|
+
IconNode && (React.createElement(IconContainer, { iconButton: !children, iconPosition: iconPosition }, IconNode)),
|
|
69
66
|
iconPosition === "left" && children ? (React.createElement(Text, { variant: ctaTextType[size], fontWeight: "semiBold", color: text.color }, children)) : null));
|
|
70
67
|
};
|
|
71
68
|
const Button = (props) => {
|
|
72
|
-
const { Icon, children, type = "default"
|
|
73
|
-
return (React.createElement(Base, Object.assign({}, props, { type: type,
|
|
74
|
-
React.createElement(ButtonContainer, Object.assign({}, props, { type: type
|
|
69
|
+
const { Icon, children, type = "default" } = props;
|
|
70
|
+
return (React.createElement(Base, Object.assign({}, props, { type: type, iconButton: !!Icon && !children, activeOpacity: 0.5 }),
|
|
71
|
+
React.createElement(ButtonContainer, Object.assign({}, props, { type: type }))));
|
|
75
72
|
};
|
|
76
73
|
export const PromisableButton = (props) => {
|
|
77
|
-
const { Icon, children, onPress, type = "main",
|
|
74
|
+
const { Icon, children, onPress, type = "main", disabled = false } = props;
|
|
78
75
|
const [spinnerOn, setSpinnerOn] = useState(false);
|
|
79
76
|
const theme = useTheme();
|
|
80
77
|
const onPressHandler = useCallback((event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -88,8 +85,8 @@ export const PromisableButton = (props) => {
|
|
|
88
85
|
setSpinnerOn(false);
|
|
89
86
|
}
|
|
90
87
|
}), [onPress]);
|
|
91
|
-
return (React.createElement(Base, Object.assign({}, props, { type: type,
|
|
92
|
-
React.createElement(ButtonContainer, Object.assign({}, props, { type: type,
|
|
88
|
+
return (React.createElement(Base, Object.assign({}, props, { type: type, iconButton: !!Icon && !children, disabled: disabled || spinnerOn, onPress: onPressHandler }),
|
|
89
|
+
React.createElement(ButtonContainer, Object.assign({}, props, { type: type, hide: spinnerOn })),
|
|
93
90
|
React.createElement(SpinnerContainer, null,
|
|
94
91
|
React.createElement(ActivityIndicator, { color: theme.colors.neutral.c50, animating: spinnerOn }))));
|
|
95
92
|
};
|
|
@@ -5,11 +5,7 @@ import Text from "../../Text";
|
|
|
5
5
|
import { getLinkColors } from "./getLinkStyle";
|
|
6
6
|
import { ctaIconSize, ctaTextType } from "../getCtaStyle";
|
|
7
7
|
const IconContainer = styled.View `
|
|
8
|
-
${(p) => p.iconLink
|
|
9
|
-
? ""
|
|
10
|
-
: p.iconPosition === "left"
|
|
11
|
-
? `margin-right: 6px;`
|
|
12
|
-
: `margin-left: 6px;`}
|
|
8
|
+
${(p) => p.iconLink ? "" : p.iconPosition === "left" ? `margin-right: 6px;` : `margin-left: 6px;`}
|
|
13
9
|
`;
|
|
14
10
|
export const Base = styled(TouchableOpacity) `
|
|
15
11
|
flex-direction: row;
|
package/components/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
export * from "./cta";
|
|
2
|
-
export * from "./drawer";
|
|
3
2
|
export * from "./Form";
|
|
4
3
|
export * from "./Icon";
|
|
5
4
|
export * from "./Layout";
|
|
6
|
-
export { default as Loader } from "./Loader";
|
|
7
5
|
export * from "./message";
|
|
8
6
|
export * from "./Navigation";
|
|
9
7
|
export * from "./tags";
|
|
10
8
|
export { default as Text } from "./Text";
|
|
9
|
+
export { default as Carousel } from "./Carousel";
|
|
10
|
+
export * from "./Tabs";
|
|
11
|
+
export * from "./Loader";
|
|
12
|
+
export { default as ProgressBar } from "./ProgressBar";
|
|
13
|
+
export * as Transitions from "./transitions";
|
package/components/index.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
export * from "./cta";
|
|
2
|
-
export * from "./drawer";
|
|
3
2
|
export * from "./Form";
|
|
4
3
|
export * from "./Icon";
|
|
5
4
|
export * from "./Layout";
|
|
6
|
-
export { default as Loader } from "./Loader";
|
|
7
5
|
export * from "./message";
|
|
8
6
|
export * from "./Navigation";
|
|
9
7
|
export * from "./tags";
|
|
10
8
|
export { default as Text } from "./Text";
|
|
9
|
+
export { default as Carousel } from "./Carousel";
|
|
10
|
+
export * from "./Tabs";
|
|
11
|
+
export * from "./Loader";
|
|
12
|
+
export { default as ProgressBar } from "./ProgressBar";
|
|
13
|
+
import * as Transitions_1 from "./transitions";
|
|
14
|
+
export { Transitions_1 as Transitions };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
declare type AlertType = "info" | "warning" | "error";
|
|
3
2
|
export interface AlertProps {
|
|
4
3
|
type?: AlertType;
|
|
5
4
|
title: string;
|
|
6
5
|
showIcon?: boolean;
|
|
7
6
|
}
|
|
8
|
-
export default function Alert({ type, title, showIcon
|
|
7
|
+
export default function Alert({ type, title, showIcon }: AlertProps): JSX.Element;
|
|
9
8
|
export {};
|
|
@@ -39,10 +39,10 @@ const StyledAlertContainer = styled(FlexBox).attrs((p) => ({
|
|
|
39
39
|
flex-direction: row;
|
|
40
40
|
align-items: center;
|
|
41
41
|
`;
|
|
42
|
-
export default function Alert({ type = "info", title, showIcon = true
|
|
42
|
+
export default function Alert({ type = "info", title, showIcon = true }) {
|
|
43
43
|
const theme = useTheme();
|
|
44
44
|
const textColor = getColor(theme, alertColors[type || "info"].color);
|
|
45
45
|
return (React.createElement(StyledAlertContainer, { type: type },
|
|
46
46
|
showIcon && !!icons[type] && (React.createElement(StyledIconContainer, null, icons[type || "info"]({ size: 20, color: textColor }))),
|
|
47
|
-
React.createElement(Text, { color: textColor }, title)));
|
|
47
|
+
React.createElement(Text, { color: textColor, flexShrink: 1 }, title)));
|
|
48
48
|
}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { TextProps, TouchableOpacityProps } from "react-native";
|
|
3
3
|
declare type Props = {
|
|
4
|
-
Icon
|
|
4
|
+
Icon?: React.ComponentType<{
|
|
5
5
|
size: number;
|
|
6
6
|
color?: string;
|
|
7
7
|
}>;
|
|
8
|
-
|
|
8
|
+
iconColor?: string;
|
|
9
9
|
variant?: "primary" | "secondary";
|
|
10
10
|
title: string;
|
|
11
11
|
subtitle?: string;
|
|
12
12
|
numberOfLines?: TextProps["numberOfLines"];
|
|
13
13
|
onClose?: TouchableOpacityProps["onPress"];
|
|
14
|
-
|
|
14
|
+
linkText?: string;
|
|
15
|
+
onLinkPress?: TouchableOpacityProps["onPress"];
|
|
15
16
|
};
|
|
16
|
-
export default function Notification({ Icon,
|
|
17
|
+
export default function Notification({ Icon, iconColor, variant, numberOfLines, title, subtitle, onClose, linkText, onLinkPress, }: Props): React.ReactElement;
|
|
17
18
|
export {};
|
|
@@ -1,31 +1,35 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import styled, { useTheme } from "styled-components/native";
|
|
3
3
|
import FlexBox from "../../Layout/Flex";
|
|
4
|
-
import { TouchableOpacity
|
|
4
|
+
import { TouchableOpacity } from "react-native";
|
|
5
5
|
import Text from "../../Text";
|
|
6
6
|
import CloseMedium from "@ledgerhq/icons-ui/native/CloseMedium";
|
|
7
|
+
import { Flex } from "../../Layout";
|
|
7
8
|
const NotificationContainer = styled.View `
|
|
8
9
|
display: flex;
|
|
9
10
|
width: 100%;
|
|
10
11
|
flex-direction: row;
|
|
11
12
|
align-items: center;
|
|
12
|
-
|
|
13
|
+
${(p) => p.variant === "primary" &&
|
|
14
|
+
`
|
|
15
|
+
padding: 16px;
|
|
16
|
+
`}
|
|
13
17
|
background-color: ${(p) => p.variant === "primary" ? p.theme.colors.primary.c90 : "transparent"};
|
|
14
18
|
border-radius: ${(p) => `${p.theme.radii[1]}px`};
|
|
15
19
|
`;
|
|
16
|
-
export default function Notification({ Icon,
|
|
20
|
+
export default function Notification({ Icon, iconColor, variant = "primary", numberOfLines, title, subtitle, onClose, linkText, onLinkPress, }) {
|
|
17
21
|
const { colors } = useTheme();
|
|
18
22
|
const textColor = variant === "primary" ? colors.neutral.c00 : colors.neutral.c100;
|
|
19
23
|
return (React.createElement(NotificationContainer, { variant: variant },
|
|
20
|
-
React.createElement(FlexBox,
|
|
21
|
-
React.createElement(Icon, { size:
|
|
22
|
-
React.createElement(FlexBox, {
|
|
23
|
-
React.createElement(Text, { variant: "body", fontWeight: "medium", color:
|
|
24
|
-
!!subtitle && (React.createElement(Text, { variant: "body", fontWeight: "medium", color:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
Icon && (React.createElement(FlexBox, { mr: 16 },
|
|
25
|
+
React.createElement(Icon, { size: 20, color: iconColor || textColor }))),
|
|
26
|
+
React.createElement(FlexBox, { flexShrink: 1 },
|
|
27
|
+
React.createElement(Text, { variant: "body", fontWeight: "medium", color: textColor, numberOfLines: numberOfLines }, title),
|
|
28
|
+
!!subtitle && (React.createElement(Text, { variant: "body", fontWeight: "medium", color: variant === "primary" ? colors.neutral.c00 : colors.neutral.c80, mt: 2 }, subtitle)),
|
|
29
|
+
linkText && onLinkPress && (React.createElement(Flex, { mt: 3 },
|
|
30
|
+
React.createElement(TouchableOpacity, { onPress: onLinkPress },
|
|
31
|
+
React.createElement(Text, { variant: "body", fontWeight: "semiBold", color: textColor }, linkText))))),
|
|
28
32
|
onClose && (React.createElement(FlexBox, { marginLeft: "auto", pl: 16 },
|
|
29
33
|
React.createElement(TouchableOpacity, { onPress: onClose },
|
|
30
|
-
React.createElement(CloseMedium, { size: 14, color:
|
|
34
|
+
React.createElement(CloseMedium, { size: 14, color: textColor }))))));
|
|
31
35
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="styled-components-react-native" />
|
|
2
|
+
import { ReactNativeStyledInterface, DefaultTheme } from "styled-components/native";
|
|
3
|
+
import { FlexboxProps, SpaceProps, PositionProps, ColorProps, LayoutProps, OverflowProps, BorderProps, BackgroundProps } from "styled-system";
|
|
4
|
+
import { InterpolationFunction } from "styled-components";
|
|
5
|
+
export declare type BaseStyledProps = SpaceProps & FlexboxProps & PositionProps & ColorProps & LayoutProps & OverflowProps & BorderProps & BackgroundProps & {
|
|
6
|
+
columnGap?: string | number;
|
|
7
|
+
rowGap?: string | number;
|
|
8
|
+
color?: string;
|
|
9
|
+
display?: string;
|
|
10
|
+
position?: string;
|
|
11
|
+
maxHeight?: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const baseStyles: InterpolationFunction<unknown>;
|
|
14
|
+
declare const _default: ReactNativeStyledInterface<DefaultTheme>;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import styled from "styled-components/native";
|
|
2
|
+
import { compose, flexbox, space, position, color, layout, overflow, border, background, } from "styled-system";
|
|
3
|
+
export const baseStyles = compose(flexbox, space, position, color, layout, overflow, border, background);
|
|
4
|
+
const proxyStyled = new Proxy(styled, {
|
|
5
|
+
apply(target, thisArg, argumentsList) {
|
|
6
|
+
return styled(target.apply(thisArg, argumentsList)(baseStyles));
|
|
7
|
+
},
|
|
8
|
+
get(target, property) {
|
|
9
|
+
return styled(target[property].apply(styled, [baseStyles]));
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
export default proxyStyled;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React, { useRef, useMemo, useEffect } from "react";
|
|
2
|
+
import { Animated } from "react-native";
|
|
3
|
+
/**
|
|
4
|
+
* A fade-in / fade-out transition changing the opacity of its children based on their status.
|
|
5
|
+
*/
|
|
6
|
+
export function Fade({ status, duration, style, children }) {
|
|
7
|
+
const fadeAnim = useRef(new Animated.Value(status === "entered" ? 1 : 0)).current;
|
|
8
|
+
const fadeIn = useMemo(() => Animated.timing(fadeAnim, {
|
|
9
|
+
toValue: 1,
|
|
10
|
+
duration,
|
|
11
|
+
useNativeDriver: true,
|
|
12
|
+
}), [duration, fadeAnim]);
|
|
13
|
+
const fadeOut = useMemo(() => Animated.timing(fadeAnim, {
|
|
14
|
+
toValue: 0,
|
|
15
|
+
duration,
|
|
16
|
+
useNativeDriver: true,
|
|
17
|
+
}), [duration, fadeAnim]);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (status === "entering") {
|
|
20
|
+
fadeIn.start();
|
|
21
|
+
}
|
|
22
|
+
if (status === "exiting") {
|
|
23
|
+
fadeOut.start();
|
|
24
|
+
}
|
|
25
|
+
}, [fadeIn, fadeOut, status]);
|
|
26
|
+
return (React.createElement(Animated.View, { style: [
|
|
27
|
+
{
|
|
28
|
+
opacity: fadeAnim,
|
|
29
|
+
},
|
|
30
|
+
style,
|
|
31
|
+
] }, children));
|
|
32
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TransitionProps } from "./types";
|
|
2
|
+
export interface SlideProps extends TransitionProps {
|
|
3
|
+
/**
|
|
4
|
+
* The direction of the slide animation.
|
|
5
|
+
*/
|
|
6
|
+
direction?: "left" | "right";
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A slide left/right transition translating its children based on their status and a given direction.
|
|
10
|
+
*/
|
|
11
|
+
export declare function Slide({ status, duration, style, direction, children }: SlideProps): JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect, useMemo } from "react";
|
|
2
|
+
import { Animated, Platform, Dimensions } from "react-native";
|
|
3
|
+
const WEB = Platform.OS === "web";
|
|
4
|
+
/**
|
|
5
|
+
* A slide left/right transition translating its children based on their status and a given direction.
|
|
6
|
+
*/
|
|
7
|
+
export function Slide({ status, duration, style, direction = "left", children }) {
|
|
8
|
+
const [width, setWidth] = useState(Dimensions.get("window").width);
|
|
9
|
+
const styleRef = useRef(new Animated.Value(0)).current;
|
|
10
|
+
const previousStatus = useRef(null);
|
|
11
|
+
useEffect(() => () => {
|
|
12
|
+
previousStatus.current = status;
|
|
13
|
+
}, [status]);
|
|
14
|
+
const animateIn = useMemo(() => Animated.timing(styleRef, {
|
|
15
|
+
toValue: 0,
|
|
16
|
+
duration,
|
|
17
|
+
useNativeDriver: true,
|
|
18
|
+
}), [duration, styleRef]);
|
|
19
|
+
const animateOut = useMemo(() => Animated.timing(styleRef, {
|
|
20
|
+
toValue: direction === "left" ? -1 : 1,
|
|
21
|
+
duration,
|
|
22
|
+
useNativeDriver: true,
|
|
23
|
+
}), [direction, duration, styleRef]);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (status === "entering") {
|
|
26
|
+
if (previousStatus.current !== "exiting") {
|
|
27
|
+
styleRef.setValue(direction === "left" ? 1 : -1);
|
|
28
|
+
}
|
|
29
|
+
animateIn.start();
|
|
30
|
+
}
|
|
31
|
+
if (status === "exiting") {
|
|
32
|
+
animateOut.start();
|
|
33
|
+
}
|
|
34
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
|
+
}, [status]);
|
|
36
|
+
return (React.createElement(Animated.View, { style: [
|
|
37
|
+
{
|
|
38
|
+
transform: [
|
|
39
|
+
{
|
|
40
|
+
translateX: styleRef.interpolate({
|
|
41
|
+
inputRange: [-1, 1],
|
|
42
|
+
outputRange: WEB ? ["-100%", "100%"] : [-width, width],
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
style,
|
|
48
|
+
], onLayout: ({ nativeEvent }) => setWidth(nativeEvent.layout.width) }, children));
|
|
49
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { TransitionStatus } from "./index";
|
|
2
|
+
export interface Props {
|
|
3
|
+
/**
|
|
4
|
+
* Show the component. Triggers the enter or exit states.
|
|
5
|
+
*/
|
|
6
|
+
in: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* By default the child component is mounted immediately along with the parent Transition component.
|
|
9
|
+
* If you want to "lazy mount" the component on the first in={true} you can set mountOnEnter.
|
|
10
|
+
* After the first enter transition the component will stay mounted, even on "exited",
|
|
11
|
+
* unless you also specify unmountOnExit.
|
|
12
|
+
*/
|
|
13
|
+
mountOnEnter?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* By default the child component stays mounted after it reaches the 'exited' state.
|
|
16
|
+
* Set unmountOnExit if you'd prefer to unmount the component after it finishes exiting.
|
|
17
|
+
*/
|
|
18
|
+
unmountOnExit?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Enable or disable enter transitions.
|
|
21
|
+
*/
|
|
22
|
+
enter?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Enable or disable exit transitions.
|
|
25
|
+
*/
|
|
26
|
+
exit?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The duration of the transition, in milliseconds.
|
|
29
|
+
*
|
|
30
|
+
* You may specify a single timeout for all transitions using a string or or individually using an object.
|
|
31
|
+
*/
|
|
32
|
+
timeout: number | {
|
|
33
|
+
enter?: number;
|
|
34
|
+
exit?: number;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* A function child can be used instead of a React element.
|
|
38
|
+
* This function is called with the current transition status ('entering', 'entered', 'exiting', 'exited'),
|
|
39
|
+
* which can be used to apply context specific props to a component.
|
|
40
|
+
*/
|
|
41
|
+
children: (status: TransitionStatus) => JSX.Element | null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Mimics the [Transition](https://reactcommunity.org/react-transition-group/transition) component
|
|
45
|
+
* from [react-transition-group](https://reactcommunity.org/react-transition-group).
|
|
46
|
+
*
|
|
47
|
+
* Supports a minimal set of options but works with react-native.
|
|
48
|
+
*/
|
|
49
|
+
export declare function Transition({ in: inValue, timeout, mountOnEnter, unmountOnExit, enter, exit, children, }: Props): JSX.Element | null;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useState, useEffect, useRef, useMemo } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Mimics the [Transition](https://reactcommunity.org/react-transition-group/transition) component
|
|
4
|
+
* from [react-transition-group](https://reactcommunity.org/react-transition-group).
|
|
5
|
+
*
|
|
6
|
+
* Supports a minimal set of options but works with react-native.
|
|
7
|
+
*/
|
|
8
|
+
export function Transition({ in: inValue, timeout, mountOnEnter, unmountOnExit, enter = true, exit = true, children, }) {
|
|
9
|
+
const [status, setStatus] = useState(inValue ? "entered" : "exited");
|
|
10
|
+
const canMount = useRef(!mountOnEnter);
|
|
11
|
+
canMount.current = canMount.current || inValue;
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if ((inValue && status === "entered") || (!inValue && status === "exited")) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (inValue && !enter) {
|
|
17
|
+
return setStatus("entered");
|
|
18
|
+
}
|
|
19
|
+
if (!inValue && !exit) {
|
|
20
|
+
return setStatus("exited");
|
|
21
|
+
}
|
|
22
|
+
const timeoutValue = typeof timeout === "number" ? timeout : timeout[inValue ? "enter" : "exit"];
|
|
23
|
+
setStatus(inValue ? "entering" : "exiting");
|
|
24
|
+
const timeoutRef = setTimeout(() => {
|
|
25
|
+
setStatus(inValue ? "entered" : "exited");
|
|
26
|
+
}, timeoutValue);
|
|
27
|
+
return () => {
|
|
28
|
+
clearTimeout(timeoutRef);
|
|
29
|
+
};
|
|
30
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31
|
+
}, [inValue, timeout]);
|
|
32
|
+
const result = useMemo(() => {
|
|
33
|
+
if (!canMount.current || (unmountOnExit && status === "exited")) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return children(status);
|
|
37
|
+
}, [children, status, unmountOnExit]);
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
export declare type TransitionStatus = "entering" | "entered" | "exiting" | "exited";
|
|
4
|
+
export interface TransitionProps {
|
|
5
|
+
/**
|
|
6
|
+
* The status of the transition, either "entered", "entering", "exiting" or "exited".
|
|
7
|
+
*/
|
|
8
|
+
status: TransitionStatus;
|
|
9
|
+
/**
|
|
10
|
+
* Duration used to transition between statuses.
|
|
11
|
+
*/
|
|
12
|
+
duration: number;
|
|
13
|
+
/**
|
|
14
|
+
* Additional styles to pass to the underlying View wrapper.
|
|
15
|
+
*/
|
|
16
|
+
style?: StyleProp<ViewStyle>;
|
|
17
|
+
/**
|
|
18
|
+
* Children that will get controlled by the transition.
|
|
19
|
+
*/
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/native-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Ledger Live - Desktop UI",
|
|
5
5
|
"repository": "https://github.com/LedgerHQ/ui",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"index.js"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@ledgerhq/icons-ui": "^0.2.
|
|
19
|
-
"@ledgerhq/ui-shared": "^0.1.
|
|
18
|
+
"@ledgerhq/icons-ui": "^0.2.2",
|
|
19
|
+
"@ledgerhq/ui-shared": "^0.1.5",
|
|
20
20
|
"@types/color": "^3.0.2",
|
|
21
|
-
"@types/react": "^17.0.
|
|
21
|
+
"@types/react": "^17.0.37",
|
|
22
22
|
"@types/react-native": "^0.65.9",
|
|
23
23
|
"@types/styled-components-react-native": "^5.1.3",
|
|
24
24
|
"@types/styled-system": "^5.1.13",
|
|
@@ -9,5 +9,5 @@ declare module "styled-components" {
|
|
|
9
9
|
interface DefaultTheme extends Theme {
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
export declare const StyleProvider: ({ children, selectedPalette
|
|
12
|
+
export declare const StyleProvider: ({ children, selectedPalette }: Props) => React.ReactElement;
|
|
13
13
|
export {};
|
package/styles/StyleProvider.js
CHANGED
|
@@ -2,7 +2,7 @@ import React, { useMemo } from "react";
|
|
|
2
2
|
import { ThemeProvider } from "styled-components/native";
|
|
3
3
|
import defaultTheme from "./theme";
|
|
4
4
|
import { palettes } from "@ledgerhq/ui-shared";
|
|
5
|
-
export const StyleProvider = ({ children, selectedPalette
|
|
5
|
+
export const StyleProvider = ({ children, selectedPalette }) => {
|
|
6
6
|
const theme = useMemo(() => (Object.assign(Object.assign({}, defaultTheme), { colors: Object.assign(Object.assign(Object.assign({}, defaultTheme.colors), palettes[selectedPalette]), { palette: palettes[selectedPalette] }), theme: selectedPalette })), [selectedPalette]);
|
|
7
7
|
return React.createElement(ThemeProvider, { theme: theme }, children);
|
|
8
8
|
};
|
package/styles/helpers.js
CHANGED
|
@@ -5,9 +5,7 @@ export const darken = (c, a) => Color(c).darken(a).toString();
|
|
|
5
5
|
export const lighten = (c, a) => Color(c).lighten(a).toString();
|
|
6
6
|
export const mix = (c, b, a) => Color(c).mix(Color(b), a).toString();
|
|
7
7
|
const get = (object, path) => {
|
|
8
|
-
const p = typeof path === "string"
|
|
9
|
-
? path.split(".").filter((key) => key.length)
|
|
10
|
-
: path;
|
|
8
|
+
const p = typeof path === "string" ? path.split(".").filter((key) => key.length) : path;
|
|
11
9
|
return p.reduce((dive, key) => dive && dive[key], object);
|
|
12
10
|
};
|
|
13
11
|
export const getColor = (p, color) => {
|
package/styles/theme.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { palettes } from "@ledgerhq/ui-shared";
|
|
2
|
+
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
|
2
3
|
export const space = [0, 2, 4, 8, 12, 14, 16, 24, 32, 40, 48, 64, 80, 96, 120];
|
|
4
|
+
// 0 1 2 3 4 5 6 7 8
|
|
3
5
|
export const fontSizes = [10, 11, 12, 13, 14, 16, 18, 24, 28];
|
|
4
6
|
[
|
|
5
7
|
fontSizes.tiny,
|
package/assets/fonts/.DS_Store
DELETED
|
Binary file
|
|
Binary file
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/// <reference types="styled-components-react-native" />
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { TouchableOpacity } from "react-native";
|
|
4
|
-
export declare type ToggleGroupProps = {
|
|
5
|
-
labels: string[];
|
|
6
|
-
activeIndex: number;
|
|
7
|
-
onChange: (newIndex: number) => void;
|
|
8
|
-
};
|
|
9
|
-
export declare const ToggleGroupContainer: import("styled-components").StyledComponent<typeof import("react-native").View, import("styled-components").DefaultTheme, import("../../Layout/Flex").Props & {
|
|
10
|
-
flexDirection: string;
|
|
11
|
-
alignItems: string;
|
|
12
|
-
}, "alignItems" | "flexDirection">;
|
|
13
|
-
export declare const ToggleBox: import("styled-components").StyledComponent<typeof TouchableOpacity, import("styled-components").DefaultTheme, {}, never>;
|
|
14
|
-
declare const ToggleGroup: (props: ToggleGroupProps) => React.ReactElement;
|
|
15
|
-
export default ToggleGroup;
|