@ledgerhq/native-ui 0.8.4-nightly.0 → 0.9.0-next.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.
@@ -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";
@@ -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;
@@ -0,0 +1,8 @@
1
+ import { Flex } from "../index";
2
+ import styled from "styled-components/native";
3
+ const Divider = styled(Flex).attrs(() => ({
4
+ my: 4,
5
+ height: 1,
6
+ backgroundColor: "neutral.c40",
7
+ })) ``;
8
+ 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";
@@ -4,9 +4,9 @@ import Animated, { useAnimatedStyle, withTiming, useSharedValue, Easing, } from
4
4
  import { Flex } from "../../Layout";
5
5
  const ProgressBar = styled.View `
6
6
  background-color: ${(p) => p.theme.colors.primary.c100};
7
+ border-radius: ${(p) => p.theme.radii[2]}px;
7
8
  height: 100%;
8
9
  width: 100%;
9
- border-radius: ${(p) => p.theme.radii[2]}px;
10
10
  `;
11
11
  const AnimatedProgressBar = Animated.createAnimatedComponent(ProgressBar);
12
12
  function ActiveProgressBar({ duration }) {
@@ -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
- active?: boolean;
5
+ type?: "shade" | "color" | "warning";
6
+ size?: "small" | "medium";
7
+ Icon?: IconType;
5
8
  uppercase?: boolean;
6
- children: React.ReactNode;
9
+ children?: React.ReactNode;
7
10
  }
8
- export default function Tag({ active, uppercase, children, ...props }: TagProps): JSX.Element;
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 { active, uppercase, children } = _a, props = __rest(_a, ["active", "uppercase", "children"]);
17
- return (React.createElement(Flex, Object.assign({ px: 2, alignItems: "center", justifyContent: "center", borderRadius: 4, borderWidth: 1, borderColor: active ? "primary.c50" : "neutral.c40" }, props),
18
- React.createElement(Text, { variant: "tiny", fontWeight: "semiBold", lineHeight: "16px", uppercase: uppercase !== false, textAlign: "center", color: active ? "primary.c70" : "neutral.c80" }, children)));
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
  }
@@ -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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/native-ui",
3
- "version": "0.8.4-nightly.0",
3
+ "version": "0.9.0-next.0",
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-next.0",
35
36
  "@ledgerhq/icons-ui": "^0.2.7",
36
37
  "@ledgerhq/ui-shared": "^0.1.9",
37
38
  "@types/color": "^3.0.3",
@@ -135,12 +136,16 @@
135
136
  "styled-components": "^5.3.3",
136
137
  "typescript": "^4.4.4",
137
138
  "victory": "^35.5.5",
138
- "webpack": "^4.46.0"
139
+ "webpack": "^4.46.0",
140
+ "stylelint": "^14.9.1",
141
+ "stylelint-config-recommended": "^8.0.0",
142
+ "stylelint-config-styled-components": "^0.1.1",
143
+ "stylelint-processor-styled-components": "^1.10.0"
139
144
  },
140
145
  "scripts": {
141
146
  "android": "expo start --android",
142
147
  "build": "tsc -p tsconfig.prod.json && node scripts/postBuild",
143
- "prebuild:storybook": "pnpm -F ui-shared -F icons-ui build",
148
+ "prebuild:storybook": "pnpm -F ui-shared -F icons-ui -F crypto-icons-ui build",
144
149
  "build:storybook": "pnpm build-storybook -o web-build",
145
150
  "watch": "tsc -p tsconfig.prod.json --watch",
146
151
  "clean": "rimraf lib",
@@ -148,6 +153,7 @@
148
153
  "ios": "expo start --ios",
149
154
  "lint": "eslint src storybook --ext .ts,.tsx,.js,.jsx --cache",
150
155
  "lint:fix": "pnpm lint --fix",
156
+ "lint:css": "stylelint './src/**/*.{js,jsx,ts,tsx}'",
151
157
  "release": "yarn publish ./lib --access public",
152
158
  "expo": "expo start",
153
159
  "storybook": "start-storybook -p 6006",