@ledgerhq/native-ui 0.10.0-nightly.1 → 0.10.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/Icon/CryptoIcon.d.ts +5 -1
- package/lib/components/Icon/CryptoIcon.js +60 -6
- package/lib/components/Tabs/Graph/index.js +10 -11
- package/lib/components/cta/Button/index.d.ts +2 -4
- package/lib/components/cta/QuickAction/QuickActionButton/index.d.ts +14 -0
- package/lib/components/cta/QuickAction/QuickActionButton/index.js +34 -0
- package/lib/components/cta/QuickAction/QuickActionList/index.d.ts +6 -0
- package/lib/components/cta/QuickAction/QuickActionList/index.js +22 -0
- package/lib/components/cta/QuickAction/index.d.ts +2 -0
- package/lib/components/cta/QuickAction/index.js +2 -0
- package/lib/components/cta/index.d.ts +1 -0
- package/lib/components/cta/index.js +1 -0
- package/lib/components/tags/Tag/index.d.ts +3 -1
- package/lib/components/tags/Tag/index.js +2 -2
- package/package.json +1 -1
|
@@ -4,7 +4,11 @@ export declare type Props = {
|
|
|
4
4
|
size?: number;
|
|
5
5
|
color?: string;
|
|
6
6
|
backgroundColor?: string;
|
|
7
|
+
circleIcon?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
tokenIcon?: string;
|
|
10
|
+
fallbackIcon?: JSX.Element;
|
|
7
11
|
};
|
|
8
12
|
export declare const iconNames: string[];
|
|
9
|
-
declare const CryptoIcon: ({ name, size, color, backgroundColor }: Props) => JSX.Element
|
|
13
|
+
declare const CryptoIcon: ({ name, size, color, backgroundColor, circleIcon, disabled, tokenIcon, fallbackIcon, }: Props) => JSX.Element;
|
|
10
14
|
export default CryptoIcon;
|
|
@@ -1,23 +1,77 @@
|
|
|
1
1
|
import * as icons from "@ledgerhq/crypto-icons-ui/native";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { ensureContrast } from "../../styles";
|
|
4
|
-
import { useTheme } from "styled-components/native";
|
|
4
|
+
import styled, { useTheme } from "styled-components/native";
|
|
5
|
+
import Text from "../Text/index";
|
|
6
|
+
import Flex from "../Layout/Flex";
|
|
5
7
|
export const iconNames = Array.from(Object.keys(icons).reduce((set, rawKey) => {
|
|
6
8
|
const key = rawKey;
|
|
7
9
|
if (!set.has(key))
|
|
8
10
|
set.add(key);
|
|
9
11
|
return set;
|
|
10
12
|
}, new Set()));
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
+
const Container = styled(Flex).attrs((p) => ({
|
|
14
|
+
heigth: p.size,
|
|
15
|
+
width: p.size,
|
|
16
|
+
alignItems: "center",
|
|
17
|
+
justifyContent: "center",
|
|
18
|
+
position: "relative",
|
|
19
|
+
})) ``;
|
|
20
|
+
const Circle = styled(Flex).attrs((p) => ({
|
|
21
|
+
heigth: p.size,
|
|
22
|
+
width: p.size,
|
|
23
|
+
alignItems: "center",
|
|
24
|
+
justifyContent: "center",
|
|
25
|
+
position: "relative",
|
|
26
|
+
borderRadius: "50%",
|
|
27
|
+
backgroundColor: p.backgroundColor,
|
|
28
|
+
})) ``;
|
|
29
|
+
const TokenContainer = styled(Flex).attrs((p) => ({
|
|
30
|
+
position: "absolute",
|
|
31
|
+
bottom: "-2px",
|
|
32
|
+
right: "-5px",
|
|
33
|
+
alignItems: "center",
|
|
34
|
+
justifyContent: "center",
|
|
35
|
+
heigth: p.size,
|
|
36
|
+
width: p.size,
|
|
37
|
+
borderRadius: "50%",
|
|
38
|
+
border: `2px solid ${p.borderColor}`,
|
|
39
|
+
backgroundColor: p.backgroundColor,
|
|
40
|
+
zIndex: 0,
|
|
41
|
+
})) ``;
|
|
42
|
+
function Fallback({ name }) {
|
|
43
|
+
return (React.createElement(Text, { uppercase: true, color: "neutral.c70" }, name.slice(0, 1)));
|
|
44
|
+
}
|
|
45
|
+
const IconBox = ({ children, color, backgroundColor, disabled, size = 16, tokenIcon = "", }) => {
|
|
46
|
+
const { colors } = useTheme();
|
|
47
|
+
if (tokenIcon in icons) {
|
|
48
|
+
// @ts-expect-error FIXME I don't know how to make you happy ts
|
|
49
|
+
const Component = icons[tokenIcon];
|
|
50
|
+
const defaultColor = Component.DefaultColor;
|
|
51
|
+
const iconColor = disabled ? colors.neutral.c70 : color || defaultColor;
|
|
52
|
+
const contrastedColor = ensureContrast(iconColor, backgroundColor || colors.background.main);
|
|
53
|
+
return (React.createElement(Container, { size: size },
|
|
54
|
+
children,
|
|
55
|
+
tokenIcon && (React.createElement(TokenContainer, { size: size / 3, borderColor: colors.background.main, backgroundColor: contrastedColor },
|
|
56
|
+
React.createElement(Component, { size: size, color: colors.background.main })))));
|
|
57
|
+
}
|
|
58
|
+
return children;
|
|
59
|
+
};
|
|
60
|
+
const CryptoIcon = ({ name, size = 16, color, backgroundColor, circleIcon, disabled, tokenIcon, fallbackIcon, }) => {
|
|
13
61
|
const { colors } = useTheme();
|
|
62
|
+
const maybeIconName = `${name}`;
|
|
14
63
|
if (maybeIconName in icons) {
|
|
15
64
|
// @ts-expect-error FIXME I don't know how to make you happy ts
|
|
16
65
|
const Component = icons[maybeIconName];
|
|
17
66
|
const defaultColor = Component.DefaultColor;
|
|
18
|
-
const
|
|
19
|
-
|
|
67
|
+
const iconColor = disabled ? colors.neutral.c70 : color || defaultColor;
|
|
68
|
+
const contrastedColor = ensureContrast(iconColor, backgroundColor || colors.background.main);
|
|
69
|
+
return (React.createElement(IconBox, { size: size, tokenIcon: tokenIcon, color: color, disabled: disabled, name: name }, tokenIcon || circleIcon ? (React.createElement(Circle, { backgroundColor: contrastedColor, size: size },
|
|
70
|
+
React.createElement(Component, { size: size, color: colors.background.main }))) : (React.createElement(Component, { size: size, color: contrastedColor }))));
|
|
71
|
+
}
|
|
72
|
+
if (fallbackIcon) {
|
|
73
|
+
return fallbackIcon;
|
|
20
74
|
}
|
|
21
|
-
return
|
|
75
|
+
return React.createElement(Fallback, { name: name });
|
|
22
76
|
};
|
|
23
77
|
export default CryptoIcon;
|
|
@@ -4,26 +4,25 @@ import Text from "../../Text";
|
|
|
4
4
|
import TemplateTabs from "../TemplateTabs";
|
|
5
5
|
const TabBox = styled.TouchableOpacity `
|
|
6
6
|
text-align: center;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
border-radius: 48px;
|
|
7
|
+
border-radius: 4px;
|
|
8
|
+
box-sizing: border-box;
|
|
10
9
|
overflow: hidden;
|
|
10
|
+
margin-left: 2px;
|
|
11
11
|
`;
|
|
12
12
|
const TabText = styled(Text).attrs((p) => ({
|
|
13
13
|
// Avoid conflict with styled-system's size property by nulling size and renaming it
|
|
14
14
|
size: undefined,
|
|
15
|
-
lineHeight: p.size === "medium" ? "
|
|
15
|
+
lineHeight: p.size === "medium" ? "40px" : "26px",
|
|
16
16
|
textAlign: "center",
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
height: p.size === "medium" ? "40px" : "26px",
|
|
18
|
+
width: 40,
|
|
19
19
|
})) ``;
|
|
20
20
|
const StyledTabs = styled(TemplateTabs) `
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
padding: ${(p) => `${p.theme.space[p.size === "medium" ? 2 : 1]}px`};
|
|
21
|
+
display: flex;
|
|
22
|
+
justify-content: center;
|
|
24
23
|
`;
|
|
25
|
-
export const GraphTab = ({ onPress, isActive, label, activeColor = "neutral.c100", activeBg = "
|
|
26
|
-
return (React.createElement(TabBox, { onPress: onPress, disabled: disabled }, isActive ? (React.createElement(TabText, { variant: "small", size: size, bg: activeBg, color: disabled ? "neutral.c70" : activeColor, fontWeight: "semiBold" }, label)) : (React.createElement(TabText, { variant: "small", size: size, color: disabled ? "neutral.c70" : "neutral.c90" }, label))));
|
|
24
|
+
export const GraphTab = ({ onPress, isActive, label, activeColor = "neutral.c100", activeBg = "neutral.c30", size = "medium", disabled, }) => {
|
|
25
|
+
return (React.createElement(TabBox, { onPress: onPress, disabled: disabled }, isActive ? (React.createElement(TabText, { variant: "small", size: size, bg: activeBg, color: disabled ? "neutral.c70" : activeColor, fontWeight: "semiBold", uppercase: true }, label)) : (React.createElement(TabText, { variant: "small", size: size, color: disabled ? "neutral.c70" : "neutral.c90", uppercase: true }, label))));
|
|
27
26
|
};
|
|
28
27
|
const GraphTabs = (props) => (React.createElement(StyledTabs, Object.assign({}, props, { Item: GraphTab })));
|
|
29
28
|
export default GraphTabs;
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { TouchableOpacity, TouchableOpacityProps } from "react-native";
|
|
4
4
|
import { BaseStyledProps } from "../../styled";
|
|
5
|
+
import { IconType } from "../../Icon/type";
|
|
5
6
|
export declare type ButtonProps = TouchableOpacityProps & BaseStyledProps & {
|
|
6
|
-
Icon?:
|
|
7
|
-
size: number;
|
|
8
|
-
color: string;
|
|
9
|
-
}> | null;
|
|
7
|
+
Icon?: IconType;
|
|
10
8
|
iconName?: string;
|
|
11
9
|
type?: "main" | "shade" | "error" | "color" | "default";
|
|
12
10
|
size?: "small" | "medium" | "large";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TouchableOpacity, TouchableOpacityProps } from "react-native";
|
|
3
|
+
import { IconType } from "src/components/Icon/type";
|
|
4
|
+
import { BaseStyledProps } from "../../../styled";
|
|
5
|
+
export declare type QuickActionButtonProps = TouchableOpacityProps & BaseStyledProps & {
|
|
6
|
+
Icon: IconType;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
onPressWhenDisabled?: TouchableOpacityProps["onPress"];
|
|
9
|
+
};
|
|
10
|
+
export declare const Base: import("styled-components").StyledComponent<typeof TouchableOpacity, import("styled-components").DefaultTheme, TouchableOpacityProps & {
|
|
11
|
+
visuallyDisabled?: boolean | undefined;
|
|
12
|
+
}, never>;
|
|
13
|
+
declare const QuickActionButton: ({ Icon, children, disabled, onPress, onPressWhenDisabled, ...otherProps }: QuickActionButtonProps) => React.ReactElement;
|
|
14
|
+
export default QuickActionButton;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from "react";
|
|
13
|
+
import { TouchableOpacity } from "react-native";
|
|
14
|
+
import Text from "../../../Text";
|
|
15
|
+
import baseStyled from "../../../styled";
|
|
16
|
+
export const Base = baseStyled(TouchableOpacity) `
|
|
17
|
+
height: 80px;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
text-align: center;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
border-radius: ${(p) => p.theme.radii[2]}px;
|
|
23
|
+
padding: 0 ${(p) => p.theme.space[6]}px;
|
|
24
|
+
${({ visuallyDisabled, theme }) => visuallyDisabled
|
|
25
|
+
? `border: 1px solid ${theme.colors.neutral.c30};`
|
|
26
|
+
: `background-color: ${theme.colors.neutral.c20};`}
|
|
27
|
+
`;
|
|
28
|
+
const QuickActionButton = (_a) => {
|
|
29
|
+
var { Icon, children, disabled, onPress, onPressWhenDisabled } = _a, otherProps = __rest(_a, ["Icon", "children", "disabled", "onPress", "onPressWhenDisabled"]);
|
|
30
|
+
return (React.createElement(Base, Object.assign({ disabled: onPressWhenDisabled ? false : disabled, onPress: disabled ? onPressWhenDisabled : onPress, visuallyDisabled: disabled }, otherProps),
|
|
31
|
+
React.createElement(Icon, { size: 24, color: disabled ? "neutral.c50" : "neutral.c100" }),
|
|
32
|
+
React.createElement(Text, { variant: "body", fontWeight: "semiBold", color: disabled ? "neutral.c50" : "neutral.c100", mt: 2 }, children)));
|
|
33
|
+
};
|
|
34
|
+
export default QuickActionButton;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FlatListProps } from "react-native";
|
|
3
|
+
import { QuickActionButtonProps } from "../QuickActionButton";
|
|
4
|
+
export declare type QuickActionListProps = Omit<FlatListProps<QuickActionButtonProps>, "renderItem">;
|
|
5
|
+
declare const QuickActionList: ({ numColumns, data, ...otherProps }: QuickActionListProps) => React.ReactElement;
|
|
6
|
+
export default QuickActionList;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React, { useCallback } from "react";
|
|
13
|
+
import { FlatList } from "react-native";
|
|
14
|
+
import QuickActionButton from "../QuickActionButton";
|
|
15
|
+
const QuickActionList = (_a) => {
|
|
16
|
+
var { numColumns = 3, data } = _a, otherProps = __rest(_a, ["numColumns", "data"]);
|
|
17
|
+
const renderItem = useCallback(({ item, index }) => {
|
|
18
|
+
return (React.createElement(QuickActionButton, Object.assign({}, item, { flex: 1, mr: (index + 1) % numColumns > 0 && data && index !== data.length - 1 ? 4 : 0, mb: (data === null || data === void 0 ? void 0 : data.length) && index + numColumns < data.length ? 4 : 0 })));
|
|
19
|
+
}, []);
|
|
20
|
+
return (React.createElement(FlatList, Object.assign({}, otherProps, { data: data, horizontal: false, renderItem: renderItem, numColumns: numColumns, style: { width: "100%" } })));
|
|
21
|
+
};
|
|
22
|
+
export default QuickActionList;
|
|
@@ -7,5 +7,7 @@ export interface TagProps extends FlexBoxProps {
|
|
|
7
7
|
Icon?: IconType;
|
|
8
8
|
uppercase?: boolean;
|
|
9
9
|
children?: React.ReactNode;
|
|
10
|
+
numberOfLines?: number;
|
|
11
|
+
ellipsizeMode?: "head" | "middle" | "tail" | "clip";
|
|
10
12
|
}
|
|
11
|
-
export default function Tag({ type, size, uppercase, Icon, children, ...props }: TagProps): JSX.Element;
|
|
13
|
+
export default function Tag({ type, size, uppercase, Icon, children, numberOfLines, ellipsizeMode, ...props }: TagProps): JSX.Element;
|
|
@@ -19,9 +19,9 @@ const typeColor = {
|
|
|
19
19
|
warning: "warning.c100",
|
|
20
20
|
};
|
|
21
21
|
export default function Tag(_a) {
|
|
22
|
-
var { type = "shade", size = "small", uppercase, Icon, children } = _a, props = __rest(_a, ["type", "size", "uppercase", "Icon", "children"]);
|
|
22
|
+
var { type = "shade", size = "small", uppercase, Icon, children, numberOfLines, ellipsizeMode } = _a, props = __rest(_a, ["type", "size", "uppercase", "Icon", "children", "numberOfLines", "ellipsizeMode"]);
|
|
23
23
|
return (React.createElement(Flex, Object.assign({ px: size === "small" ? "6px" : 3, alignItems: "center", justifyContent: "center", flexDirection: "row", borderRadius: 6, bg: typeColor[type], height: size === "small" ? "18px" : "28px" }, props),
|
|
24
24
|
Icon && (React.createElement(Box, { pr: 2 },
|
|
25
25
|
React.createElement(Icon, { size: size === "small" ? 16 : 20, color: type === "shade" ? "neutral.c90" : "neutral.c00" }))),
|
|
26
|
-
React.createElement(Text, { variant: size === "small" ? "subtitle" : "small", fontWeight: "bold", uppercase: uppercase !== false, textAlign: "center", color: type === "shade" ? "neutral.c90" : "neutral.c00" }, children)));
|
|
26
|
+
React.createElement(Text, { variant: size === "small" ? "subtitle" : "small", fontWeight: "bold", uppercase: uppercase !== false, textAlign: "center", color: type === "shade" ? "neutral.c90" : "neutral.c00", numberOfLines: numberOfLines, ellipsizeMode: ellipsizeMode }, children)));
|
|
27
27
|
}
|