@ledgerhq/native-ui 0.9.0 → 0.10.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.
@@ -7,6 +7,7 @@ const bracketSizes = {
7
7
  h4: 18,
8
8
  h5: 18,
9
9
  large: 20,
10
+ largeLineHeight: 20,
10
11
  body: 20,
11
12
  bodyLineHeight: 20,
12
13
  paragraph: 20,
@@ -52,6 +53,10 @@ export function getTextTypeStyle({ bracket }) {
52
53
  large: {
53
54
  fontFamily: "Inter",
54
55
  },
56
+ largeLineHeight: {
57
+ fontFamily: "Inter",
58
+ lineHeight: "27.2px",
59
+ },
55
60
  body: {
56
61
  fontFamily: "Inter",
57
62
  },
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { TextProps, TouchableOpacityProps } from "react-native";
3
- declare type NotificationVariant = "primary" | "secondary" | "success" | "warning" | "error" | string;
3
+ declare type NotificationVariant = "primary" | "secondary" | "success" | "warning" | "error" | "plain" | string;
4
4
  declare type Props = {
5
5
  Icon?: React.ComponentType<{
6
6
  size: number;
@@ -39,16 +39,27 @@ const variantProps = {
39
39
  color: "neutral.c100",
40
40
  padding: 0,
41
41
  },
42
+ plain: {
43
+ bg: "neutral.c100",
44
+ color: "neutral.c00",
45
+ padding: 6,
46
+ iconMarginRight: "10px",
47
+ closeIconSize: 20,
48
+ closeIconColor: "neutral.c70",
49
+ textVariant: "bodyLineHeight",
50
+ textFontWeight: "semiBold",
51
+ borderRadius: 8,
52
+ },
42
53
  };
43
54
  const NotificationContainer = styled(FlexBox).attrs((p) => {
44
- var _a, _b, _c;
55
+ var _a, _b, _c, _d, _e;
45
56
  return ({
46
57
  width: "100%",
47
58
  flexDirection: "row",
48
59
  alignItems: "center",
49
60
  bg: (_b = (_a = variantProps[p.variant]) === null || _a === void 0 ? void 0 : _a.bg) !== null && _b !== void 0 ? _b : variantProps.primary.bg,
50
61
  p: (_c = variantProps[p.variant]) === null || _c === void 0 ? void 0 : _c.padding,
51
- borderRadius: 1,
62
+ borderRadius: (_e = (_d = variantProps[p.variant]) === null || _d === void 0 ? void 0 : _d.borderRadius) !== null && _e !== void 0 ? _e : 1,
52
63
  });
53
64
  }) ``;
54
65
  const ClosePressableExtendedBounds = styled.TouchableOpacity.attrs({
@@ -58,22 +69,27 @@ const ClosePressableExtendedBounds = styled.TouchableOpacity.attrs({
58
69
  ${space};
59
70
  `;
60
71
  export default function Notification({ Icon, iconColor, variant = "primary", numberOfLines, title, subtitle, onClose, linkText, onLinkPress, }) {
61
- var _a, _b, _c;
72
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
62
73
  const { colors } = useTheme();
63
74
  const textColor = (_b = (_a = variantProps[variant]) === null || _a === void 0 ? void 0 : _a.color) !== null && _b !== void 0 ? _b : variantProps.primary.color;
64
75
  const linkColor = ((_c = variantProps[variant]) === null || _c === void 0 ? void 0 : _c.linkColor) || textColor;
76
+ const iconMarginRight = (_e = (_d = variantProps[variant]) === null || _d === void 0 ? void 0 : _d.iconMarginRight) !== null && _e !== void 0 ? _e : 16;
77
+ const closeIconSize = (_g = (_f = variantProps[variant]) === null || _f === void 0 ? void 0 : _f.closeIconSize) !== null && _g !== void 0 ? _g : 14;
78
+ const closeIconColor = (_j = (_h = variantProps[variant]) === null || _h === void 0 ? void 0 : _h.closeIconColor) !== null && _j !== void 0 ? _j : textColor;
79
+ const textVariant = (_l = (_k = variantProps[variant]) === null || _k === void 0 ? void 0 : _k.textVariant) !== null && _l !== void 0 ? _l : "body";
80
+ const textFontWeight = (_o = (_m = variantProps[variant]) === null || _m === void 0 ? void 0 : _m.textFontWeight) !== null && _o !== void 0 ? _o : "medium";
65
81
  return (React.createElement(NotificationContainer, { variant: variant },
66
- Icon && (React.createElement(FlexBox, { mr: 16 },
82
+ Icon && (React.createElement(FlexBox, { mr: iconMarginRight },
67
83
  React.createElement(Icon, { size: 20, color: iconColor || textColor }))),
68
84
  React.createElement(FlexBox, { flexShrink: 1 },
69
85
  React.createElement(Text, { variant: "body", fontWeight: "medium", color: textColor, numberOfLines: numberOfLines }, title),
70
- !!subtitle && (React.createElement(Text, { variant: "body", fontWeight: "medium", color: variant === "primary" ? colors.neutral.c00 : colors.neutral.c80, mt: 2 }, subtitle)),
86
+ !!subtitle && (React.createElement(Text, { variant: textVariant, fontWeight: textFontWeight, color: variant === "primary" ? colors.neutral.c00 : colors.neutral.c80, mt: 2 }, subtitle)),
71
87
  linkText && onLinkPress && (React.createElement(Flex, { mt: 3 },
72
88
  React.createElement(TouchableOpacity, { onPress: onLinkPress },
73
89
  React.createElement(Flex, { flexDirection: "row", alignItems: "center" },
74
- React.createElement(Text, { variant: "body", fontWeight: "semiBold", color: linkColor, mr: 3 }, linkText),
90
+ React.createElement(Text, { variant: textVariant, fontWeight: "semiBold", color: linkColor, mr: 3 }, linkText),
75
91
  React.createElement(ExternalLinkMedium, { size: 16, color: linkColor })))))),
76
92
  onClose && (React.createElement(FlexBox, { marginLeft: "auto", pl: 16 },
77
93
  React.createElement(ClosePressableExtendedBounds, { onPress: onClose },
78
- React.createElement(CloseMedium, { size: 14, color: textColor }))))));
94
+ React.createElement(CloseMedium, { size: closeIconSize, color: closeIconColor }))))));
79
95
  }
@@ -1,6 +1,12 @@
1
1
  /// <reference types="react" />
2
2
  import { TransitionProps } from "./types";
3
+ export interface FadeProps extends TransitionProps {
4
+ /**
5
+ * Delay before starting the transition.
6
+ */
7
+ delay?: number;
8
+ }
3
9
  /**
4
10
  * A fade-in / fade-out transition changing the opacity of its children based on their status.
5
11
  */
6
- export declare function Fade({ status, duration, style, children }: TransitionProps): JSX.Element;
12
+ export declare function Fade({ status, delay, duration, style, children }: FadeProps): JSX.Element;
@@ -1,29 +1,44 @@
1
- import React, { useRef, useMemo, useEffect } from "react";
1
+ import React, { useRef, useMemo, useEffect, useState } from "react";
2
2
  import { Animated } from "react-native";
3
3
  /**
4
4
  * A fade-in / fade-out transition changing the opacity of its children based on their status.
5
5
  */
6
- export function Fade({ status, duration, style, children }) {
7
- const fadeAnim = useRef(new Animated.Value(status === "entered" ? 1 : 0)).current;
6
+ export function Fade({ status, delay = 0, duration, style, children }) {
7
+ const [visible, setVisible] = useState(status === "exiting");
8
+ const fadeAnim = useRef(new Animated.Value(["entered", "exiting"].includes(status) ? 1 : 0)).current;
8
9
  const fadeIn = useMemo(() => Animated.timing(fadeAnim, {
9
10
  toValue: 1,
11
+ delay,
10
12
  duration,
11
13
  useNativeDriver: true,
12
- }), [duration, fadeAnim]);
14
+ }), [duration, delay, fadeAnim]);
13
15
  const fadeOut = useMemo(() => Animated.timing(fadeAnim, {
14
16
  toValue: 0,
17
+ delay,
15
18
  duration,
16
19
  useNativeDriver: true,
17
- }), [duration, fadeAnim]);
20
+ }), [duration, delay, fadeAnim]);
18
21
  useEffect(() => {
22
+ let dead = false;
19
23
  if (status === "entering") {
20
- fadeIn.start();
24
+ fadeIn.start(() => {
25
+ if (dead)
26
+ return;
27
+ setVisible(true);
28
+ });
21
29
  }
22
30
  if (status === "exiting") {
23
- fadeOut.start();
31
+ fadeOut.start(() => {
32
+ if (dead)
33
+ return;
34
+ setVisible(false);
35
+ });
24
36
  }
25
- }, [fadeIn, fadeOut, status]);
26
- return (React.createElement(Animated.View, { style: [
37
+ return () => {
38
+ dead = true;
39
+ };
40
+ }, [fadeIn, fadeOut, status, setVisible]);
41
+ return (React.createElement(Animated.View, { pointerEvents: visible ? "auto" : "none", style: [
27
42
  {
28
43
  opacity: fadeAnim,
29
44
  },
@@ -1,9 +1,9 @@
1
1
  import { ColorPalette } from "@ledgerhq/ui-shared";
2
2
  export declare const space: number[];
3
- export declare const textVariants: readonly ["h1", "h1Inter", "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", "largeLineHeight", "body", "bodyLineHeight", "paragraph", "paragraphLineHeight", "small", "subtitle", "tiny"];
4
4
  export declare type TextVariants = typeof textVariants[number];
5
5
  export declare type ThemeScale<Type, Aliases extends string> = Array<Type> & Record<Aliases, Type>;
6
- export declare const fontSizes: ThemeScale<number, "h1" | "h1Inter" | "h2" | "h3" | "h4" | "h5" | "large" | "body" | "bodyLineHeight" | "paragraph" | "paragraphLineHeight" | "small" | "subtitle" | "tiny">;
6
+ export declare const fontSizes: ThemeScale<number, "h1" | "h1Inter" | "h2" | "h3" | "h4" | "h5" | "large" | "largeLineHeight" | "body" | "bodyLineHeight" | "paragraph" | "paragraphLineHeight" | "small" | "subtitle" | "tiny">;
7
7
  export declare const radii: number[];
8
8
  export declare const zIndexes: number[];
9
9
  export declare type Theme = {
@@ -9,6 +9,7 @@ export const textVariants = [
9
9
  "h4",
10
10
  "h5",
11
11
  "large",
12
+ "largeLineHeight",
12
13
  "body",
13
14
  "bodyLineHeight",
14
15
  "paragraph",
@@ -33,6 +34,7 @@ export const fontSizes = [10, 11, 12, 13, 14, 16, 18, 24, 28, 32];
33
34
  ] = fontSizes;
34
35
  fontSizes.bodyLineHeight = fontSizes.body;
35
36
  fontSizes.paragraphLineHeight = fontSizes.paragraph;
37
+ fontSizes.largeLineHeight = fontSizes.large;
36
38
  fontSizes.h4 = fontSizes.h2;
37
39
  fontSizes.h5 = fontSizes.h3;
38
40
  export const radii = [0, 4, 8];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/native-ui",
3
- "version": "0.9.0",
3
+ "version": "0.10.0-nightly.1",
4
4
  "description": "Ledger Live - Mobile UI",
5
5
  "repository": {
6
6
  "type": "git",