@ledgerhq/native-ui 0.8.3 → 0.9.0-nightly.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/lib/assets/cryptoIcons.d.ts +1 -0
- package/lib/assets/cryptoIcons.js +1 -0
- package/lib/assets/index.d.ts +1 -0
- package/lib/assets/index.js +2 -0
- package/lib/components/Icon/CryptoIcon.d.ts +10 -0
- package/lib/components/Icon/CryptoIcon.js +23 -0
- package/lib/components/Icon/index.d.ts +1 -0
- package/lib/components/Icon/index.js +1 -0
- package/lib/components/Layout/Divider/index.d.ts +14 -0
- package/lib/components/Layout/Divider/index.js +8 -0
- package/lib/components/Layout/index.d.ts +1 -0
- package/lib/components/Layout/index.js +1 -0
- package/lib/components/Text/getTextStyle.d.ts +2 -0
- package/lib/components/Text/getTextStyle.js +7 -0
- package/lib/components/tags/Tag/index.d.ts +6 -3
- package/lib/components/tags/Tag/index.js +11 -3
- package/lib/styles/helpers.d.ts +1 -0
- package/lib/styles/helpers.js +9 -0
- package/lib/styles/theme.d.ts +3 -2
- package/lib/styles/theme.js +19 -2
- package/package.json +3 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@ledgerhq/crypto-icons-ui/native";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@ledgerhq/crypto-icons-ui/native";
|
package/lib/assets/index.d.ts
CHANGED
package/lib/assets/index.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare type Props = {
|
|
3
|
+
name: string;
|
|
4
|
+
size?: number;
|
|
5
|
+
color?: string;
|
|
6
|
+
backgroundColor?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const iconNames: string[];
|
|
9
|
+
declare const CryptoIcon: ({ name, size, color, backgroundColor }: Props) => JSX.Element | null;
|
|
10
|
+
export default CryptoIcon;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as icons from "@ledgerhq/crypto-icons-ui/native";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { ensureContrast } from "../../styles";
|
|
4
|
+
import { useTheme } from "styled-components/native";
|
|
5
|
+
export const iconNames = Array.from(Object.keys(icons).reduce((set, rawKey) => {
|
|
6
|
+
const key = rawKey;
|
|
7
|
+
if (!set.has(key))
|
|
8
|
+
set.add(key);
|
|
9
|
+
return set;
|
|
10
|
+
}, new Set()));
|
|
11
|
+
const CryptoIcon = ({ name, size = 16, color, backgroundColor }) => {
|
|
12
|
+
const maybeIconName = `${name}`;
|
|
13
|
+
const { colors } = useTheme();
|
|
14
|
+
if (maybeIconName in icons) {
|
|
15
|
+
// @ts-expect-error FIXME I don't know how to make you happy ts
|
|
16
|
+
const Component = icons[maybeIconName];
|
|
17
|
+
const defaultColor = Component.DefaultColor;
|
|
18
|
+
const contrastedColor = ensureContrast(color || defaultColor, backgroundColor || colors.background.main);
|
|
19
|
+
return React.createElement(Component, { size: size, color: contrastedColor });
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
};
|
|
23
|
+
export default CryptoIcon;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="styled-components-react-native" />
|
|
2
|
+
declare const Divider: import("styled-components").StyledComponent<typeof import("react-native").View, import("styled-components").DefaultTheme, import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").OverflowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> & {
|
|
3
|
+
columnGap?: string | number | undefined;
|
|
4
|
+
rowGap?: string | number | undefined;
|
|
5
|
+
color?: string | undefined;
|
|
6
|
+
display?: string | undefined;
|
|
7
|
+
position?: string | undefined;
|
|
8
|
+
maxHeight?: number | undefined;
|
|
9
|
+
} & {
|
|
10
|
+
my: number;
|
|
11
|
+
height: number;
|
|
12
|
+
backgroundColor: string;
|
|
13
|
+
}, "height" | "backgroundColor" | "my">;
|
|
14
|
+
export default Divider;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as Accordion } from "./Collapse/Accordion";
|
|
2
2
|
export { default as Flex } from "./Flex";
|
|
3
3
|
export { default as Box } from "./Box";
|
|
4
|
+
export { default as Divider } from "./Divider";
|
|
4
5
|
export * from "./Modals";
|
|
5
6
|
export { default as ScrollContainer } from "./ScrollContainer";
|
|
6
7
|
export { default as ScrollContainerHeader } from "./ScrollContainerHeader";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as Accordion } from "./Collapse/Accordion";
|
|
2
2
|
export { default as Flex } from "./Flex";
|
|
3
3
|
export { default as Box } from "./Box";
|
|
4
|
+
export { default as Divider } from "./Divider";
|
|
4
5
|
export * from "./Modals";
|
|
5
6
|
export { default as ScrollContainer } from "./ScrollContainer";
|
|
6
7
|
export { default as ScrollContainerHeader } from "./ScrollContainerHeader";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TextVariants } from "../../styles/theme";
|
|
2
2
|
import { BaseTextProps } from "./index";
|
|
3
3
|
export declare type FontWeightTypes = "medium" | "semiBold" | "bold";
|
|
4
|
+
export declare const fontWeightTypes: FontWeightTypes[];
|
|
4
5
|
export declare function getBracketSize({ variant }: {
|
|
5
6
|
variant?: TextVariants;
|
|
6
7
|
}): number;
|
|
@@ -11,6 +12,7 @@ export declare function getTextTypeStyle({ bracket }: {
|
|
|
11
12
|
lineHeight?: string;
|
|
12
13
|
paddingTop?: number;
|
|
13
14
|
textTransform?: string;
|
|
15
|
+
letterSpacing?: number;
|
|
14
16
|
}>;
|
|
15
17
|
export declare function getTextStyle({ variant, bracket, fontWeight, }: Partial<BaseTextProps>): {
|
|
16
18
|
fontFamily: string;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
export const fontWeightTypes = ["medium", "semiBold", "bold"];
|
|
1
2
|
const bracketSizes = {
|
|
2
3
|
h1: 32,
|
|
4
|
+
h1Inter: 32,
|
|
3
5
|
h2: 28,
|
|
4
6
|
h3: 20,
|
|
5
7
|
h4: 18,
|
|
@@ -24,6 +26,11 @@ export function getTextTypeStyle({ bracket }) {
|
|
|
24
26
|
paddingTop: bracket ? 5 : 0,
|
|
25
27
|
textTransform: "uppercase",
|
|
26
28
|
},
|
|
29
|
+
h1Inter: {
|
|
30
|
+
fontFamily: "Inter",
|
|
31
|
+
lineHeight: "42px",
|
|
32
|
+
letterSpacing: -1,
|
|
33
|
+
},
|
|
27
34
|
h2: {
|
|
28
35
|
fontFamily: "Alpha",
|
|
29
36
|
lineHeight: "28px",
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FlexBoxProps } from "../../Layout/Flex";
|
|
3
|
+
import { IconType } from "../../Icon/type";
|
|
3
4
|
export interface TagProps extends FlexBoxProps {
|
|
4
|
-
|
|
5
|
+
type?: "shade" | "color" | "warning";
|
|
6
|
+
size?: "small" | "medium";
|
|
7
|
+
Icon?: IconType;
|
|
5
8
|
uppercase?: boolean;
|
|
6
|
-
children
|
|
9
|
+
children?: React.ReactNode;
|
|
7
10
|
}
|
|
8
|
-
export default function Tag({
|
|
11
|
+
export default function Tag({ type, size, uppercase, Icon, children, ...props }: TagProps): JSX.Element;
|
|
@@ -12,8 +12,16 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import React from "react";
|
|
13
13
|
import Flex from "../../Layout/Flex";
|
|
14
14
|
import Text from "../../Text";
|
|
15
|
+
import { Box } from "../../Layout";
|
|
16
|
+
const typeColor = {
|
|
17
|
+
color: "primary.c80",
|
|
18
|
+
shade: "neutral.c30",
|
|
19
|
+
warning: "warning.c100",
|
|
20
|
+
};
|
|
15
21
|
export default function Tag(_a) {
|
|
16
|
-
var {
|
|
17
|
-
return (React.createElement(Flex, Object.assign({ px:
|
|
18
|
-
React.createElement(
|
|
22
|
+
var { type = "shade", size = "small", uppercase, Icon, children } = _a, props = __rest(_a, ["type", "size", "uppercase", "Icon", "children"]);
|
|
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
|
+
Icon && (React.createElement(Box, { pr: 2 },
|
|
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)));
|
|
19
27
|
}
|
package/lib/styles/helpers.d.ts
CHANGED
package/lib/styles/helpers.js
CHANGED
|
@@ -12,3 +12,12 @@ export const getColor = (p, color) => {
|
|
|
12
12
|
const c = get(p.colors, color);
|
|
13
13
|
return c;
|
|
14
14
|
};
|
|
15
|
+
export const ensureContrast = (color1, color2) => {
|
|
16
|
+
const colorL1 = Color(color1).luminosity() + 0.05;
|
|
17
|
+
const colorL2 = Color(color2).luminosity() + 0.05;
|
|
18
|
+
const lRatio = colorL1 > colorL2 ? colorL1 / colorL2 : colorL2 / colorL1;
|
|
19
|
+
if (lRatio < 1.5) {
|
|
20
|
+
return Color(color1).rotate(180).negate().string();
|
|
21
|
+
}
|
|
22
|
+
return color1;
|
|
23
|
+
};
|
package/lib/styles/theme.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ColorPalette } from "@ledgerhq/ui-shared";
|
|
2
2
|
export declare const space: number[];
|
|
3
|
-
export declare
|
|
3
|
+
export declare const textVariants: readonly ["h1", "h1Inter", "h2", "h3", "h4", "h5", "large", "body", "bodyLineHeight", "paragraph", "paragraphLineHeight", "small", "subtitle", "tiny"];
|
|
4
|
+
export declare type TextVariants = typeof textVariants[number];
|
|
4
5
|
export declare type ThemeScale<Type, Aliases extends string> = Array<Type> & Record<Aliases, Type>;
|
|
5
|
-
export declare const fontSizes: ThemeScale<number,
|
|
6
|
+
export declare const fontSizes: ThemeScale<number, "h1" | "h1Inter" | "h2" | "h3" | "h4" | "h5" | "large" | "body" | "bodyLineHeight" | "paragraph" | "paragraphLineHeight" | "small" | "subtitle" | "tiny">;
|
|
6
7
|
export declare const radii: number[];
|
|
7
8
|
export declare const zIndexes: number[];
|
|
8
9
|
export declare type Theme = {
|
package/lib/styles/theme.js
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
import { palettes } from "@ledgerhq/ui-shared";
|
|
2
2
|
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
|
3
3
|
export const space = [0, 2, 4, 8, 12, 14, 16, 24, 32, 40, 48, 64, 80, 96, 120];
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export const textVariants = [
|
|
5
|
+
"h1",
|
|
6
|
+
"h1Inter",
|
|
7
|
+
"h2",
|
|
8
|
+
"h3",
|
|
9
|
+
"h4",
|
|
10
|
+
"h5",
|
|
11
|
+
"large",
|
|
12
|
+
"body",
|
|
13
|
+
"bodyLineHeight",
|
|
14
|
+
"paragraph",
|
|
15
|
+
"paragraphLineHeight",
|
|
16
|
+
"small",
|
|
17
|
+
"subtitle",
|
|
18
|
+
"tiny",
|
|
19
|
+
];
|
|
20
|
+
// 0 1 2 3 4 5 6 7 8 9
|
|
21
|
+
export const fontSizes = [10, 11, 12, 13, 14, 16, 18, 24, 28, 32];
|
|
6
22
|
[
|
|
7
23
|
fontSizes.tiny,
|
|
8
24
|
fontSizes.subtitle,
|
|
@@ -13,6 +29,7 @@ export const fontSizes = [10, 11, 12, 13, 14, 16, 18, 24, 28];
|
|
|
13
29
|
fontSizes.h3,
|
|
14
30
|
fontSizes.h2,
|
|
15
31
|
fontSizes.h1,
|
|
32
|
+
fontSizes.h1Inter,
|
|
16
33
|
] = fontSizes;
|
|
17
34
|
fontSizes.bodyLineHeight = fontSizes.body;
|
|
18
35
|
fontSizes.paragraphLineHeight = fontSizes.paragraph;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/native-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0-nightly.2",
|
|
4
4
|
"description": "Ledger Live - Mobile UI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"lib/**/*"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"@ledgerhq/crypto-icons-ui": "^0.2.0-nightly.0",
|
|
35
36
|
"@ledgerhq/icons-ui": "^0.2.7",
|
|
36
37
|
"@ledgerhq/ui-shared": "^0.1.9",
|
|
37
38
|
"@types/color": "^3.0.3",
|
|
@@ -140,7 +141,7 @@
|
|
|
140
141
|
"scripts": {
|
|
141
142
|
"android": "expo start --android",
|
|
142
143
|
"build": "tsc -p tsconfig.prod.json && node scripts/postBuild",
|
|
143
|
-
"prebuild:storybook": "pnpm -F ui-shared -F icons-ui build",
|
|
144
|
+
"prebuild:storybook": "pnpm -F ui-shared -F icons-ui -F crypto-icons-ui build",
|
|
144
145
|
"build:storybook": "pnpm build-storybook -o web-build",
|
|
145
146
|
"watch": "tsc -p tsconfig.prod.json --watch",
|
|
146
147
|
"clean": "rimraf lib",
|