@ledgerhq/native-ui 0.6.7 → 0.7.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.
@@ -1,11 +1,13 @@
1
1
  import React from "react";
2
2
  declare type Props = {
3
3
  progress?: number;
4
+ infinite: boolean;
4
5
  onPress?: () => void;
5
- Icon?: React.ComponentType<{
6
- color: string;
7
- size: number;
8
- }>;
6
+ mainColor: string;
7
+ secondaryColor: string;
8
+ radius: number;
9
+ strokeWidth: number;
10
+ children: React.ReactNode;
9
11
  };
10
- declare const ProgressLoader: ({ progress, onPress, Icon }: Props) => React.ReactElement;
12
+ declare const ProgressLoader: ({ progress, infinite, mainColor, secondaryColor, onPress, radius, strokeWidth, children, }: Props) => React.ReactElement;
11
13
  export default ProgressLoader;
@@ -1,24 +1,47 @@
1
- import React from "react";
1
+ import React, { useEffect } from "react";
2
2
  import { Svg, Circle, G } from "react-native-svg";
3
3
  import { useTheme } from "styled-components/native";
4
4
  import { TouchableOpacity } from "react-native";
5
- const radius = 25;
6
- const strokeWidth = 2;
7
- const normalizedRadius = radius - strokeWidth / 2;
8
- const circumference = normalizedRadius * 2 * Math.PI;
9
- const iconSize = radius * 0.88;
10
- const iconOffset = radius - iconSize / 2;
11
- const ProgressLoader = ({ progress = 0, onPress, Icon }) => {
5
+ import { Flex } from "../../Layout";
6
+ import Animated, { useAnimatedStyle, useSharedValue, withRepeat, withTiming, cancelAnimation, Easing, } from "react-native-reanimated";
7
+ const ProgressLoader = ({ progress = 0, infinite, mainColor, secondaryColor, onPress, radius = 48, strokeWidth = 4, children, }) => {
12
8
  const { colors } = useTheme();
13
- const backgroundColor = colors.primary.c20;
14
- const progressColor = colors.primary.c90;
9
+ const backgroundColor = secondaryColor || colors.neutral.c40;
10
+ const progressColor = mainColor || colors.primary.c80;
11
+ const normalizedRadius = radius - strokeWidth / 2;
12
+ const circumference = normalizedRadius * 2 * Math.PI;
15
13
  const strokeDashoffset = circumference - progress * circumference;
16
- return (React.createElement(TouchableOpacity, { disabled: !onPress, onPress: onPress },
17
- React.createElement(Svg, { width: radius * 2, height: radius * 2 },
18
- React.createElement(Circle, { cx: radius, cy: radius, r: radius * 0.92, fill: "transparent", stroke: backgroundColor, strokeDashoffset: 0, strokeWidth: strokeWidth }),
19
- React.createElement(G, { transform: `rotate(-90) translate(-${radius * 2}, 0)` },
20
- React.createElement(Circle, { cx: radius, cy: radius, r: radius * 0.92, fill: "transparent", stroke: progressColor, strokeWidth: strokeWidth, strokeDasharray: `${circumference} ${circumference}`, strokeDashoffset: strokeDashoffset })),
21
- Icon ? (React.createElement(G, { transform: `translate(${iconOffset}, ${iconOffset})` },
22
- React.createElement(Icon, { color: progressColor, size: iconSize }))) : null)));
14
+ const rotation = useSharedValue(0);
15
+ const animatedStyles = useAnimatedStyle(() => ({
16
+ transform: [
17
+ {
18
+ rotateZ: `${rotation.value}deg`,
19
+ },
20
+ ],
21
+ }), [rotation.value]);
22
+ useEffect(() => {
23
+ rotation.value = withRepeat(withTiming(360, {
24
+ duration: 1000,
25
+ easing: Easing.linear,
26
+ }), -1);
27
+ return () => cancelAnimation(rotation);
28
+ // eslint-disable-next-line react-hooks/exhaustive-deps
29
+ }, []);
30
+ if (infinite) {
31
+ return (React.createElement(TouchableOpacity, { disabled: !onPress, onPress: onPress, activeOpacity: 1 },
32
+ React.createElement(Flex, { alignItems: "center", justifyContent: "center" },
33
+ React.createElement(Animated.View, { style: animatedStyles },
34
+ React.createElement(Svg, { width: radius * 2, height: radius * 2 },
35
+ React.createElement(Circle, { cx: radius, cy: radius, fill: "transparent", r: radius * 0.92, stroke: backgroundColor, strokeWidth: strokeWidth }),
36
+ React.createElement(Circle, { cx: radius, cy: radius, fill: "transparent", r: radius * 0.92, stroke: mainColor, strokeWidth: strokeWidth, strokeDasharray: `${circumference / 4}, ${circumference}`, strokeDashoffset: "500", strokeLinecap: "round" }))),
37
+ React.createElement(Flex, { position: "absolute" }, children))));
38
+ }
39
+ return (React.createElement(TouchableOpacity, { disabled: !onPress, onPress: onPress, activeOpacity: 1 },
40
+ React.createElement(Flex, { alignItems: "center", justifyContent: "center" },
41
+ React.createElement(Svg, { width: radius * 2, height: radius * 2 },
42
+ React.createElement(Circle, { cx: radius, cy: radius, r: radius * 0.92, fill: "transparent", stroke: backgroundColor, strokeDashoffset: 0, strokeWidth: strokeWidth }),
43
+ React.createElement(G, { transform: `rotate(-90) translate(-${radius * 2}, 0)` },
44
+ React.createElement(Circle, { cx: radius, cy: radius, r: radius * 0.92, fill: "transparent", stroke: progressColor, strokeWidth: strokeWidth, strokeDasharray: `${circumference} ${circumference}`, strokeDashoffset: strokeDashoffset }))),
45
+ React.createElement(Flex, { position: "absolute" }, children))));
23
46
  };
24
47
  export default ProgressLoader;
@@ -1,2 +1,2 @@
1
- export { default as Loader } from "./ProgressLoader";
1
+ export { default as ProgressLoader } from "./ProgressLoader";
2
2
  export { default as InfiniteLoader } from "./InfiniteLoader";
@@ -1,2 +1,2 @@
1
- export { default as Loader } from "./ProgressLoader";
1
+ export { default as ProgressLoader } from "./ProgressLoader";
2
2
  export { default as InfiniteLoader } from "./InfiniteLoader";
@@ -1,16 +1,19 @@
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 function getBracketSize({ variant }: {
5
+ variant?: TextVariants;
6
+ }): number;
4
7
  export declare function getTextTypeStyle({ bracket }: {
5
8
  bracket?: boolean;
6
9
  }): Record<TextVariants, {
7
10
  fontFamily: string;
8
- lineHeight?: number;
11
+ lineHeight?: string;
9
12
  paddingTop?: number;
10
13
  textTransform?: string;
11
14
  }>;
12
15
  export declare function getTextStyle({ variant, bracket, fontWeight, }: Partial<BaseTextProps>): {
13
16
  fontFamily: string;
14
- lineHeight?: number;
17
+ lineHeight?: string;
15
18
  paddingTop?: number;
16
19
  };
@@ -1,20 +1,37 @@
1
+ const bracketSizes = {
2
+ h1: 32,
3
+ h2: 28,
4
+ h3: 20,
5
+ h4: 18,
6
+ large: 20,
7
+ body: 20,
8
+ bodyLineHeight: 20,
9
+ paragraph: 20,
10
+ paragraphLineHeight: 18,
11
+ small: 16,
12
+ subtitle: 16,
13
+ tiny: 16,
14
+ };
15
+ export function getBracketSize({ variant }) {
16
+ return variant ? bracketSizes[variant] : 20;
17
+ }
1
18
  export function getTextTypeStyle({ bracket }) {
2
19
  return {
3
20
  h1: {
4
21
  fontFamily: "Alpha",
5
- lineHeight: 32,
6
- paddingTop: bracket ? 15 : 0,
22
+ lineHeight: "32px",
23
+ paddingTop: bracket ? 5 : 0,
7
24
  textTransform: "uppercase",
8
25
  },
9
26
  h2: {
10
27
  fontFamily: "Alpha",
11
- lineHeight: 28,
12
- paddingTop: bracket ? 10 : 0,
28
+ lineHeight: "28px",
29
+ paddingTop: bracket ? 3 : 0,
13
30
  textTransform: "uppercase",
14
31
  },
15
32
  h3: {
16
33
  fontFamily: "Alpha",
17
- lineHeight: 20,
34
+ lineHeight: "20px",
18
35
  paddingTop: bracket ? 5 : 0,
19
36
  textTransform: "uppercase",
20
37
  },
@@ -30,14 +47,14 @@ export function getTextTypeStyle({ bracket }) {
30
47
  },
31
48
  bodyLineHeight: {
32
49
  fontFamily: "Inter",
33
- lineHeight: 20,
50
+ lineHeight: "20px",
34
51
  },
35
52
  paragraph: {
36
53
  fontFamily: "Inter",
37
54
  },
38
55
  paragraphLineHeight: {
39
56
  fontFamily: "Inter",
40
- lineHeight: 18,
57
+ lineHeight: "18px",
41
58
  },
42
59
  small: {
43
60
  fontFamily: "Inter",
@@ -10,7 +10,7 @@ export interface BaseTextProps extends TextProps, BaseStyledProps, FontSizeProps
10
10
  fontFamily?: string;
11
11
  fontSize?: number | string | TextVariants;
12
12
  color?: string;
13
- lineHeight?: number | string;
13
+ lineHeight?: string;
14
14
  bracket?: boolean;
15
15
  textTransform?: TextStyle["textTransform"];
16
16
  uppercase?: boolean;
@@ -16,7 +16,7 @@ import baseStyled from "../styled";
16
16
  import BracketRight from "../../icons/BracketLeft";
17
17
  import BracketLeft from "../../icons/BracketRight";
18
18
  import { getColor } from "../../styles";
19
- import { getTextStyle } from "./getTextStyle";
19
+ import { getTextStyle, getBracketSize } from "./getTextStyle";
20
20
  const uppercase = system({
21
21
  uppercase: {
22
22
  property: "textTransform",
@@ -46,8 +46,8 @@ const T = styled.View `
46
46
  align-items: center;
47
47
  `;
48
48
  const BracketText = (_a) => {
49
- var { children, color = "neutral.c100", lineHeight } = _a, props = __rest(_a, ["children", "color", "lineHeight"]);
50
- const size = lineHeight || getTextStyle(props).lineHeight;
49
+ var { children, color = "neutral.c100" } = _a, props = __rest(_a, ["children", "color"]);
50
+ const size = getBracketSize(props);
51
51
  const theme = useTheme();
52
52
  const c = theme ? getColor(theme, color) : "transparent";
53
53
  return (React.createElement(T, null,
@@ -38,7 +38,7 @@ const Chart = ({ data, color, tickFormat = "MMM", valueKey = "value", height = 1
38
38
  tickLabels: {
39
39
  fill: theme.colors.neutral.c80,
40
40
  fontSize: 12,
41
- lineHeight: 14.52,
41
+ lineHeight: "14.52px",
42
42
  },
43
43
  grid: { display: "none" },
44
44
  } }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/native-ui",
3
- "version": "0.6.7",
3
+ "version": "0.7.2",
4
4
  "description": "Ledger Live - Desktop UI",
5
5
  "repository": "https://github.com/LedgerHQ/ui",
6
6
  "license": "MIT",
@@ -24,14 +24,14 @@
24
24
  "@types/styled-system": "^5.1.13",
25
25
  "color": "^3.1.3",
26
26
  "moment": "^2.29.1",
27
- "react-native-modal": "^12.0.3",
27
+ "react-native-modal": "^13.0.0",
28
28
  "rn-range-slider": "^2.1.1",
29
29
  "styled-system": "^5.1.5",
30
30
  "victory-native": "^35.5.5"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react": "^17.0.2",
34
- "react-native": "^0.64.0",
34
+ "react-native": "^0.65.0",
35
35
  "react-native-reanimated": "^2.2.4",
36
36
  "react-native-svg": "^12.1.1",
37
37
  "styled-components": "^5.3.3"