@ledgerhq/native-ui 0.18.1-nightly.0 → 0.19.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.
@@ -1,5 +1,6 @@
1
+ /// <reference types="styled-components-react-native" />
1
2
  import React from "react";
2
- type AlertType = "info" | "warning" | "error";
3
+ type AlertType = "info" | "secondary" | "success" | "warning" | "error";
3
4
  export type IconProps = {
4
5
  size?: number;
5
6
  color?: string;
@@ -15,13 +16,18 @@ export interface AlertProps {
15
16
  title?: React.ReactNode;
16
17
  showIcon?: boolean;
17
18
  children?: React.ReactNode;
18
- /**
19
- * Alternative to using the `children` prop in order to render something using the value of `textColor`
20
- * that is passed as a parameter.
21
- */
22
- renderContent?: ({ textColor }: {
23
- textColor: string;
24
- }) => React.ReactNode | null;
25
19
  }
26
- export default function Alert({ type, Icon, title, showIcon, children, renderContent, }: AlertProps): JSX.Element;
27
- export {};
20
+ declare function Alert({ type, Icon, title, showIcon, children }: AlertProps): JSX.Element;
21
+ declare namespace Alert {
22
+ var BodyText: import("styled-components").StyledComponent<({ children, bracket, textAlign, ...props }: import("../../Text").BaseTextProps) => JSX.Element, import("styled-components").DefaultTheme, {
23
+ flexShrink: 1;
24
+ variant: "bodyLineHeight";
25
+ fontWeight: "semiBold";
26
+ }, "fontWeight" | "variant" | "flexShrink">;
27
+ var UnderlinedText: import("styled-components").StyledComponent<({ children, bracket, textAlign, ...props }: import("../../Text").BaseTextProps) => JSX.Element, import("styled-components").DefaultTheme, {
28
+ flexShrink: 1;
29
+ variant: "bodyLineHeight";
30
+ fontWeight: "semiBold";
31
+ }, "fontWeight" | "variant" | "flexShrink">;
32
+ }
33
+ export default Alert;
@@ -1,51 +1,72 @@
1
1
  import React from "react";
2
2
  import styled, { useTheme } from "styled-components/native";
3
- import InfoMedium from "@ledgerhq/icons-ui/native/InfoMedium";
4
- import CircledCrossMedium from "@ledgerhq/icons-ui/native/CircledCrossMedium";
5
- import CircledAlertMedium from "@ledgerhq/icons-ui/native/CircledAlertMedium";
3
+ import InfoAltFillMedium from "@ledgerhq/icons-ui/native/InfoAltFillMedium";
4
+ import CircledCheckSolidMedium from "@ledgerhq/icons-ui/native/CircledCheckSolidMedium";
5
+ import WarningSolidMedium from "@ledgerhq/icons-ui/native/WarningSolidMedium";
6
+ import CircledCrossSolidMedium from "@ledgerhq/icons-ui/native/CircledCrossSolidMedium";
6
7
  import Text from "../../Text";
7
- import { getColor } from "../../../styles";
8
8
  import FlexBox from "../../Layout/Flex";
9
+ import { getColor } from "../../../styles";
9
10
  const icons = {
10
- info: InfoMedium,
11
- warning: CircledAlertMedium,
12
- error: CircledCrossMedium,
11
+ info: InfoAltFillMedium,
12
+ secondary: InfoAltFillMedium,
13
+ success: CircledCheckSolidMedium,
14
+ warning: WarningSolidMedium,
15
+ error: CircledCrossSolidMedium,
13
16
  };
14
17
  const alertColors = {
15
18
  info: {
16
- backgroundColor: "primary.c20",
17
- color: "primary.c90",
19
+ backgroundColor: "primary.c10",
20
+ iconColor: "primary.c80",
21
+ },
22
+ secondary: {
23
+ backgroundColor: "opacityDefault.c05",
24
+ iconColor: "neutral.c80",
25
+ },
26
+ success: {
27
+ backgroundColor: "success.c10",
28
+ iconColor: "success.c50",
18
29
  },
19
30
  warning: {
20
- backgroundColor: "warning.c20",
21
- color: "warning.c90",
31
+ backgroundColor: "warning.c10",
32
+ iconColor: "warning.c70",
22
33
  },
23
34
  error: {
24
- backgroundColor: "error.c20",
25
- color: "error.c90",
35
+ backgroundColor: "error.c10",
36
+ iconColor: "error.c50",
26
37
  },
27
38
  };
28
- const StyledIconContainer = styled.View `
29
- margin-right: 12px;
30
- display: flex;
31
- align-items: center;
32
- `;
39
+ const StyledIconContainer = styled(FlexBox).attrs({
40
+ mr: 4,
41
+ alignItems: "center",
42
+ }) ``;
33
43
  const StyledAlertContainer = styled(FlexBox).attrs((p) => ({
34
44
  backgroundColor: alertColors[p.type || "info"].backgroundColor,
45
+ p: 6,
35
46
  })) `
36
47
  width: 100%;
37
- border-radius: ${(p) => `${p.theme.radii[1]}px`};
38
- padding: 16px;
48
+ border-radius: ${(p) => `${p.theme.radii[2]}px`};
39
49
  flex-direction: row;
40
- align-items: center;
50
+ align-items: flex-start;
51
+ `;
52
+ const AlertBodyText = styled(Text).attrs({
53
+ flexShrink: 1,
54
+ variant: "bodyLineHeight",
55
+ fontWeight: "semiBold",
56
+ }) ``;
57
+ const AlertUnderlinedText = styled(AlertBodyText) `
58
+ text-decoration-line: underline;
41
59
  `;
42
- export default function Alert({ type = "info", Icon, title, showIcon = true, children, renderContent, }) {
60
+ function Alert({ type = "info", Icon, title, showIcon = true, children }) {
43
61
  const theme = useTheme();
44
- const textColor = getColor(theme, alertColors[type || "info"].color);
45
- const iconProps = { size: 20, color: textColor };
62
+ const textColor = "neutral.c100";
63
+ const IconComponent = Icon !== null && Icon !== void 0 ? Icon : icons[type];
46
64
  return (React.createElement(StyledAlertContainer, { type: type },
47
- showIcon && !!icons[type] && (React.createElement(StyledIconContainer, null, Icon ? React.createElement(Icon, Object.assign({}, iconProps)) : icons[type || "info"](iconProps))),
48
- title && (React.createElement(Text, { color: textColor, flexShrink: 1 }, title)),
49
- children,
50
- renderContent && renderContent({ textColor })));
65
+ showIcon && !!icons[type] && (React.createElement(StyledIconContainer, null,
66
+ React.createElement(IconComponent, { size: 20, color: getColor(theme, alertColors[type || "info"].iconColor) }))),
67
+ title ? (React.createElement(Text, { color: textColor, flexShrink: 1, variant: "bodyLineHeight", fontWeight: "semiBold" }, title)) : null,
68
+ children));
51
69
  }
70
+ Alert.BodyText = AlertBodyText;
71
+ Alert.UnderlinedText = AlertUnderlinedText;
72
+ export default Alert;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/native-ui",
3
- "version": "0.18.1-nightly.0",
3
+ "version": "0.19.0-nightly.1",
4
4
  "description": "Ledger Live - Mobile UI",
5
5
  "repository": {
6
6
  "type": "git",