@ledgerhq/native-ui 0.8.3-next.1 → 0.9.0-nightly.1

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.
@@ -0,0 +1 @@
1
+ export * from "@ledgerhq/crypto-icons-ui/native";
@@ -0,0 +1 @@
1
+ export * from "@ledgerhq/crypto-icons-ui/native";
@@ -1,2 +1,3 @@
1
1
  export * as Icons from "@ledgerhq/icons-ui/native";
2
2
  export * as Logos from "./logos";
3
+ export * as CryptoIcons from "@ledgerhq/crypto-icons-ui/native";
@@ -2,3 +2,5 @@ import * as Icons_1 from "@ledgerhq/icons-ui/native";
2
2
  export { Icons_1 as Icons };
3
3
  import * as Logos_1 from "./logos";
4
4
  export { Logos_1 as Logos };
5
+ import * as CryptoIcons_1 from "@ledgerhq/crypto-icons-ui/native";
6
+ export { CryptoIcons_1 as CryptoIcons };
@@ -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;
@@ -1,3 +1,4 @@
1
1
  export { default as IconBox } from "./IconBox";
2
2
  export { default as BoxedIcon } from "./BoxedIcon";
3
3
  export { default as Icon } from "./Icon";
4
+ export { default as CryptoIcon } from "./CryptoIcon";
@@ -1,3 +1,4 @@
1
1
  export { default as IconBox } from "./IconBox";
2
2
  export { default as BoxedIcon } from "./BoxedIcon";
3
3
  export { default as Icon } from "./Icon";
4
+ export { default as CryptoIcon } from "./CryptoIcon";
@@ -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",
@@ -6,3 +6,4 @@ export declare const mix: (c: string, b: string, a: number) => string;
6
6
  export declare const getColor: (p: {
7
7
  colors: unknown;
8
8
  }, color: string) => string;
9
+ export declare const ensureContrast: (color1: string, color2: string) => string;
@@ -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
+ };
@@ -1,8 +1,9 @@
1
1
  import { ColorPalette } from "@ledgerhq/ui-shared";
2
2
  export declare const space: number[];
3
- export declare type TextVariants = "h1" | "h2" | "h3" | "h4" | "h5" | "large" | "body" | "bodyLineHeight" | "paragraph" | "paragraphLineHeight" | "small" | "subtitle" | "tiny";
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, TextVariants>;
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 = {
@@ -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
- // 0 1 2 3 4 5 6 7 8
5
- export const fontSizes = [10, 11, 12, 13, 14, 16, 18, 24, 28];
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.8.3-next.1",
3
+ "version": "0.9.0-nightly.1",
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",