@ledgerhq/native-ui 0.8.2-yolo.0 → 0.8.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,12 +1,13 @@
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
4
  declare type Props = {
4
5
  Icon?: React.ComponentType<{
5
6
  size: number;
6
7
  color?: string;
7
8
  }>;
8
9
  iconColor?: string;
9
- variant?: "primary" | "secondary";
10
+ variant?: NotificationVariant;
10
11
  title: string;
11
12
  subtitle?: string;
12
13
  numberOfLines?: TextProps["numberOfLines"];
@@ -7,18 +7,50 @@ import CloseMedium from "@ledgerhq/icons-ui/native/CloseMedium";
7
7
  import { Flex } from "../../Layout";
8
8
  import { space } from "styled-system";
9
9
  import { ExternalLinkMedium } from "@ledgerhq/icons-ui/native";
10
- const NotificationContainer = styled.View `
11
- display: flex;
12
- width: 100%;
13
- flex-direction: row;
14
- align-items: center;
15
- ${(p) => p.variant === "primary" &&
16
- `
17
- padding: 16px;
18
- `}
19
- background-color: ${(p) => p.variant === "primary" ? p.theme.colors.primary.c90 : "transparent"};
20
- border-radius: ${(p) => `${p.theme.radii[1]}px`};
21
- `;
10
+ const variantProps = {
11
+ primary: {
12
+ bg: "primary.c90",
13
+ color: "neutral.c00",
14
+ padding: 6,
15
+ },
16
+ success: {
17
+ bg: "success.c100",
18
+ color: "neutral.c00",
19
+ padding: 6,
20
+ },
21
+ warning: {
22
+ bg: "warning.c100",
23
+ color: "neutral.c00",
24
+ padding: 6,
25
+ },
26
+ error: {
27
+ bg: "error.c100",
28
+ color: "neutral.c00",
29
+ padding: 6,
30
+ },
31
+ neutral: {
32
+ bg: "neutral.c30",
33
+ color: "neutral.c100",
34
+ linkColor: "primary.c80",
35
+ padding: 6,
36
+ },
37
+ secondary: {
38
+ bg: "transparent",
39
+ color: "neutral.c100",
40
+ padding: 0,
41
+ },
42
+ };
43
+ const NotificationContainer = styled(FlexBox).attrs((p) => {
44
+ var _a, _b, _c;
45
+ return ({
46
+ width: "100%",
47
+ flexDirection: "row",
48
+ alignItems: "center",
49
+ bg: (_b = (_a = variantProps[p.variant]) === null || _a === void 0 ? void 0 : _a.bg) !== null && _b !== void 0 ? _b : variantProps.primary.bg,
50
+ p: (_c = variantProps[p.variant]) === null || _c === void 0 ? void 0 : _c.padding,
51
+ borderRadius: 1,
52
+ });
53
+ }) ``;
22
54
  const ClosePressableExtendedBounds = styled.TouchableOpacity.attrs({
23
55
  p: 5,
24
56
  m: -5,
@@ -26,8 +58,10 @@ const ClosePressableExtendedBounds = styled.TouchableOpacity.attrs({
26
58
  ${space};
27
59
  `;
28
60
  export default function Notification({ Icon, iconColor, variant = "primary", numberOfLines, title, subtitle, onClose, linkText, onLinkPress, }) {
61
+ var _a, _b, _c;
29
62
  const { colors } = useTheme();
30
- const textColor = variant === "primary" ? colors.neutral.c00 : colors.neutral.c100;
63
+ const textColor = (_b = (_a = variantProps[variant]) === null || _a === void 0 ? void 0 : _a.color) !== null && _b !== void 0 ? _b : variantProps.primary.color;
64
+ const linkColor = ((_c = variantProps[variant]) === null || _c === void 0 ? void 0 : _c.linkColor) || textColor;
31
65
  return (React.createElement(NotificationContainer, { variant: variant },
32
66
  Icon && (React.createElement(FlexBox, { mr: 16 },
33
67
  React.createElement(Icon, { size: 20, color: iconColor || textColor }))),
@@ -37,8 +71,8 @@ export default function Notification({ Icon, iconColor, variant = "primary", num
37
71
  linkText && onLinkPress && (React.createElement(Flex, { mt: 3 },
38
72
  React.createElement(TouchableOpacity, { onPress: onLinkPress },
39
73
  React.createElement(Flex, { flexDirection: "row", alignItems: "center" },
40
- React.createElement(Text, { variant: "body", fontWeight: "semiBold", color: textColor, mr: 3 }, linkText),
41
- React.createElement(ExternalLinkMedium, { size: 16, color: textColor })))))),
74
+ React.createElement(Text, { variant: "body", fontWeight: "semiBold", color: linkColor, mr: 3 }, linkText),
75
+ React.createElement(ExternalLinkMedium, { size: 16, color: linkColor })))))),
42
76
  onClose && (React.createElement(FlexBox, { marginLeft: "auto", pl: 16 },
43
77
  React.createElement(ClosePressableExtendedBounds, { onPress: onClose },
44
78
  React.createElement(CloseMedium, { size: 14, color: textColor }))))));
package/package.json CHANGED
@@ -1,8 +1,15 @@
1
1
  {
2
2
  "name": "@ledgerhq/native-ui",
3
- "version": "0.8.2-yolo.0",
3
+ "version": "0.8.2",
4
4
  "description": "Ledger Live - Mobile UI",
5
- "repository": "https://github.com/LedgerHQ/ui",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/LedgerHQ/ledger-live.git"
8
+ },
9
+ "bugs": {
10
+ "url": "https://github.com/LedgerHQ/ledger-live/issues"
11
+ },
12
+ "homepage": "https://github.com/LedgerHQ/ledger-live/tree/develop/libs/ui/packages/native",
6
13
  "license": "MIT",
7
14
  "author": "Ledger Live Team <team-live@ledger.fr>",
8
15
  "main": "lib/index.js",
@@ -25,7 +32,7 @@
25
32
  "lib/**/*"
26
33
  ],
27
34
  "dependencies": {
28
- "@ledgerhq/icons-ui": "^0.2.7-yolo.0",
35
+ "@ledgerhq/icons-ui": "^0.2.7",
29
36
  "@ledgerhq/ui-shared": "^0.1.9",
30
37
  "@types/color": "^3.0.3",
31
38
  "@types/react": "^17.0.39",