@ledgerhq/native-ui 0.8.4-nightly.0 → 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.
- 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/styles/helpers.d.ts +1 -0
- package/lib/styles/helpers.js +9 -0
- 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;
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/native-ui",
|
|
3
|
-
"version": "0.
|
|
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",
|