@ledgerhq/native-ui 0.45.0 → 0.46.0-nightly.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.
- package/lib/pre-ldls/components/AccountItem/AccountItem.d.ts +2 -1
- package/lib/pre-ldls/components/AccountItem/AccountItem.d.ts.map +1 -1
- package/lib/pre-ldls/components/AccountItem/AccountItem.js +2 -2
- package/lib/pre-ldls/components/AccountItem/AccountItem.stories.d.ts.map +1 -1
- package/lib/pre-ldls/components/AccountItem/AccountItem.stories.js +7 -0
- package/lib/pre-ldls/components/Address/Address.d.ts +2 -1
- package/lib/pre-ldls/components/Address/Address.d.ts.map +1 -1
- package/lib/pre-ldls/components/Address/Address.js +2 -2
- package/lib/pre-ldls/components/MarketPercentIndicator/MarketPercentIndicator.d.ts +5 -0
- package/lib/pre-ldls/components/MarketPercentIndicator/MarketPercentIndicator.d.ts.map +1 -0
- package/lib/pre-ldls/components/MarketPercentIndicator/MarketPercentIndicator.js +40 -0
- package/lib/pre-ldls/components/MarketPercentIndicator/MarketPercentIndicator.stories.d.ts +10 -0
- package/lib/pre-ldls/components/MarketPercentIndicator/MarketPercentIndicator.stories.d.ts.map +1 -0
- package/lib/pre-ldls/components/MarketPercentIndicator/MarketPercentIndicator.stories.js +20 -0
- package/lib/pre-ldls/components/MarketPriceIndicator/MarketPriceIndicator.d.ts +6 -0
- package/lib/pre-ldls/components/MarketPriceIndicator/MarketPriceIndicator.d.ts.map +1 -0
- package/lib/pre-ldls/components/MarketPriceIndicator/MarketPriceIndicator.js +35 -0
- package/lib/pre-ldls/components/MarketPriceIndicator/MarketPriceIndicator.stories.d.ts +10 -0
- package/lib/pre-ldls/components/MarketPriceIndicator/MarketPriceIndicator.stories.d.ts.map +1 -0
- package/lib/pre-ldls/components/MarketPriceIndicator/MarketPriceIndicator.stories.js +20 -0
- package/lib/pre-ldls/components/index.d.ts +2 -0
- package/lib/pre-ldls/components/index.d.ts.map +1 -1
- package/lib/pre-ldls/components/index.js +2 -0
- package/package.json +3 -3
|
@@ -32,6 +32,7 @@ export type AccountItemProps = {
|
|
|
32
32
|
rightElement?: RightElement;
|
|
33
33
|
showIcon?: boolean;
|
|
34
34
|
backgroundColor?: string;
|
|
35
|
+
cryptoIconBackgroundColor: string;
|
|
35
36
|
};
|
|
36
|
-
export declare const AccountItem: ({ onClick, account, rightElement, showIcon, backgroundColor, }: AccountItemProps) => React.JSX.Element;
|
|
37
|
+
export declare const AccountItem: ({ onClick, account, rightElement, showIcon, backgroundColor, cryptoIconBackgroundColor, }: AccountItemProps) => React.JSX.Element;
|
|
37
38
|
//# sourceMappingURL=AccountItem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountItem.d.ts","sourceRoot":"","sources":["../../../../src/pre-ldls/components/AccountItem/AccountItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QACR,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,iBAAiB,GAAG,oBAAoB,GAAG,gBAAgB,CAAC;AAEvF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,EAAE,SAAS,CAAC;IACnB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"AccountItem.d.ts","sourceRoot":"","sources":["../../../../src/pre-ldls/components/AccountItem/AccountItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QACR,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,iBAAiB,GAAG,oBAAoB,GAAG,gBAAgB,CAAC;AAEvF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,EAAE,SAAS,CAAC;IACnB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yBAAyB,EAAE,MAAM,CAAC;CACnC,CAAC;AAkGF,eAAO,MAAM,WAAW,8FAOrB,gBAAgB,sBA8FlB,CAAC"}
|
|
@@ -70,7 +70,7 @@ const RightElementRenderer = ({ rightElement, tokens, onEditPress }) => {
|
|
|
70
70
|
rightElement.type === "edit" && (React.createElement(IconButton, { onPress: onEditPress, testID: "right-element-edit-icon" },
|
|
71
71
|
React.createElement(PenMedium, { size: 16, color: String(tokens["colors-content-default-default"]) })))));
|
|
72
72
|
};
|
|
73
|
-
export const AccountItem = ({ onClick, account, rightElement, showIcon = true, backgroundColor, }) => {
|
|
73
|
+
export const AccountItem = ({ onClick, account, rightElement, showIcon = true, backgroundColor, cryptoIconBackgroundColor, }) => {
|
|
74
74
|
const theme = useTheme();
|
|
75
75
|
const colorType = theme.colors.type === "dark" ? "dark" : "light";
|
|
76
76
|
const tokens = useTokens(colorType, [
|
|
@@ -106,7 +106,7 @@ export const AccountItem = ({ onClick, account, rightElement, showIcon = true, b
|
|
|
106
106
|
React.createElement(Text, { variant: "largeLineHeight", fontWeight: "semiBold", color: String(tokens["colors-content-default-default"]), fontSize: "18px", numberOfLines: 1, ellipsizeMode: "tail" }, name)),
|
|
107
107
|
protocol && (React.createElement(TagWrapper, { style: { marginLeft: Number(tokens["spacing-xs"]) } },
|
|
108
108
|
React.createElement(Tag, { textTransform: "uppercase" }, protocol)))),
|
|
109
|
-
React.createElement(Address, { address: address, cryptoId: cryptoId, ticker: ticker, parentId: parentId, showIcon: showIcon })),
|
|
109
|
+
React.createElement(Address, { address: address, cryptoId: cryptoId, ticker: ticker, parentId: parentId, showIcon: showIcon, backgroundColor: cryptoIconBackgroundColor })),
|
|
110
110
|
React.createElement(BalanceContainer, { style: { gap: Number(tokens["spacing-xxxs"]) } },
|
|
111
111
|
fiatValue && (React.createElement(Text, { fontSize: "18px", color: String(tokens["colors-content-default-default"]) }, fiatValue)),
|
|
112
112
|
balance && (React.createElement(Text, { fontSize: "14px", color: String(tokens["colors-content-subdued-default-default"]) }, balance))),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountItem.stories.d.ts","sourceRoot":"","sources":["../../../../src/pre-ldls/components/AccountItem/AccountItem.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,WAAW,
|
|
1
|
+
{"version":3,"file":"AccountItem.stories.d.ts","sourceRoot":"","sources":["../../../../src/pre-ldls/components/AccountItem/AccountItem.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,WAAW,CAyBlC,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,WAAW,CAAC,CAAC;AAE1C,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC;AAEjC,eAAO,MAAM,WAAW,EAAE,KAezB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KAcjC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,KAapC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAqB9B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAe3B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAiB1B,CAAC"}
|
|
@@ -14,6 +14,7 @@ const meta = {
|
|
|
14
14
|
id: "12345",
|
|
15
15
|
name: "Main BTC",
|
|
16
16
|
ticker: "btc",
|
|
17
|
+
cryptoIconBackgroundColor: "red",
|
|
17
18
|
},
|
|
18
19
|
},
|
|
19
20
|
parameters: {
|
|
@@ -38,6 +39,7 @@ export const TestAccount = {
|
|
|
38
39
|
name: "Main BTC",
|
|
39
40
|
protocol: "Native Segwit",
|
|
40
41
|
ticker: "btc",
|
|
42
|
+
cryptoIconBackgroundColor: "red",
|
|
41
43
|
},
|
|
42
44
|
},
|
|
43
45
|
};
|
|
@@ -52,6 +54,7 @@ export const TestWithoutProtocol = {
|
|
|
52
54
|
id: "21345",
|
|
53
55
|
name: "Main BTC",
|
|
54
56
|
ticker: "btc",
|
|
57
|
+
cryptoIconBackgroundColor: "red",
|
|
55
58
|
},
|
|
56
59
|
},
|
|
57
60
|
};
|
|
@@ -64,6 +67,7 @@ export const TestWithoutAddressIcon = {
|
|
|
64
67
|
fiatValue: "$5,969.83",
|
|
65
68
|
id: "bitcoin",
|
|
66
69
|
name: "Main BTC",
|
|
70
|
+
cryptoIconBackgroundColor: "red",
|
|
67
71
|
},
|
|
68
72
|
showIcon: false,
|
|
69
73
|
},
|
|
@@ -78,6 +82,7 @@ export const TestWithCheckbox = {
|
|
|
78
82
|
id: "12345",
|
|
79
83
|
name: "Main BTC",
|
|
80
84
|
ticker: "btc",
|
|
85
|
+
cryptoIconBackgroundColor: "red",
|
|
81
86
|
},
|
|
82
87
|
onClick: onClick,
|
|
83
88
|
rightElement: {
|
|
@@ -98,6 +103,7 @@ export const TestWithArrow = {
|
|
|
98
103
|
id: "12345",
|
|
99
104
|
name: "Main BTC",
|
|
100
105
|
ticker: "btc",
|
|
106
|
+
cryptoIconBackgroundColor: "red",
|
|
101
107
|
},
|
|
102
108
|
rightElement: {
|
|
103
109
|
type: "arrow",
|
|
@@ -113,6 +119,7 @@ export const TestWithEdit = {
|
|
|
113
119
|
id: "12345",
|
|
114
120
|
name: "Main BTC",
|
|
115
121
|
ticker: "btc",
|
|
122
|
+
cryptoIconBackgroundColor: "red",
|
|
116
123
|
},
|
|
117
124
|
onClick: undefined,
|
|
118
125
|
rightElement: {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const Address: ({ address, showIcon, cryptoId, ticker, parentId, }: {
|
|
2
|
+
export declare const Address: ({ address, showIcon, cryptoId, ticker, parentId, backgroundColor, }: {
|
|
3
3
|
address: string;
|
|
4
4
|
showIcon: boolean;
|
|
5
5
|
cryptoId?: string | undefined;
|
|
6
6
|
ticker?: string | undefined;
|
|
7
7
|
parentId?: string | undefined;
|
|
8
|
+
backgroundColor: string;
|
|
8
9
|
}) => React.JSX.Element;
|
|
9
10
|
//# sourceMappingURL=Address.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Address.d.ts","sourceRoot":"","sources":["../../../../src/pre-ldls/components/Address/Address.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,eAAO,MAAM,OAAO;
|
|
1
|
+
{"version":3,"file":"Address.d.ts","sourceRoot":"","sources":["../../../../src/pre-ldls/components/Address/Address.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,eAAO,MAAM,OAAO;aAQT,MAAM;cACL,OAAO;;;;qBAIA,MAAM;uBA2BxB,CAAC"}
|
|
@@ -8,11 +8,11 @@ const Wrapper = styled(View) `
|
|
|
8
8
|
flex-direction: row;
|
|
9
9
|
align-items: center;
|
|
10
10
|
`;
|
|
11
|
-
export const Address = ({ address, showIcon, cryptoId, ticker, parentId, }) => {
|
|
11
|
+
export const Address = ({ address, showIcon, cryptoId, ticker, parentId, backgroundColor, }) => {
|
|
12
12
|
const { theme } = useTheme();
|
|
13
13
|
const colorType = theme;
|
|
14
14
|
const tokens = useTokens(colorType, ["spacing-xxxs", "colors-content-subdued-default-default"]);
|
|
15
15
|
return (React.createElement(Wrapper, null,
|
|
16
16
|
React.createElement(Text, { fontSize: "14px", color: String(tokens["colors-content-subdued-default-default"]), marginRight: showIcon ? Number(tokens["spacing-xxxs"]) : 0 }, address),
|
|
17
|
-
showIcon && React.createElement(CryptoIcon, { ledgerId: cryptoId, network: parentId, ticker: ticker, size: 20 })));
|
|
17
|
+
showIcon && (React.createElement(CryptoIcon, { ledgerId: cryptoId, network: parentId, ticker: ticker, size: 20, theme: theme, backgroundColor: backgroundColor }))));
|
|
18
18
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarketPercentIndicator.d.ts","sourceRoot":"","sources":["../../../../src/pre-ldls/components/MarketPercentIndicator/MarketPercentIndicator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AA2B1B,eAAO,MAAM,sBAAsB;aAA4B,MAAM;uBA6BpE,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Flex, Text } from "../../../components";
|
|
3
|
+
import { useTokens } from "../../libs";
|
|
4
|
+
import { useTheme } from "styled-components/native";
|
|
5
|
+
const getPercentageDisplay = (percent, tokens) => {
|
|
6
|
+
if (percent > 0) {
|
|
7
|
+
return {
|
|
8
|
+
backgroundColor: String(tokens["colors-surface-status-success-default"]),
|
|
9
|
+
color: String(tokens["colors-surface-status-success-strong-default"]),
|
|
10
|
+
text: `+${percent}%`,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
if (percent < 0) {
|
|
14
|
+
return {
|
|
15
|
+
backgroundColor: String(tokens["colors-surface-status-error-default"]),
|
|
16
|
+
color: String(tokens["colors-surface-status-error-strong-default"]),
|
|
17
|
+
text: `-${Math.abs(percent)}%`,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
backgroundColor: String(tokens["colors-surface-transparent-hover"]),
|
|
22
|
+
color: String(tokens["colors-content-default-default"]),
|
|
23
|
+
text: `${percent}%`,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export const MarketPercentIndicator = ({ percent }) => {
|
|
27
|
+
const { theme } = useTheme();
|
|
28
|
+
const colorType = theme;
|
|
29
|
+
const tokens = useTokens(colorType, [
|
|
30
|
+
"colors-surface-status-success-default",
|
|
31
|
+
"colors-surface-status-success-strong-default",
|
|
32
|
+
"colors-surface-status-error-default",
|
|
33
|
+
"colors-surface-status-error-strong-default",
|
|
34
|
+
"colors-surface-transparent-hover",
|
|
35
|
+
"colors-content-default-default",
|
|
36
|
+
]);
|
|
37
|
+
const percentageDisplay = getPercentageDisplay(percent, tokens);
|
|
38
|
+
return (React.createElement(Flex, { "data-testid": "market-percent-indicator", flexDirection: "column", alignItems: "flex-end", width: "fit-content", p: "4px", borderRadius: "4px", backgroundColor: percentageDisplay.backgroundColor },
|
|
39
|
+
React.createElement(Text, { color: percentageDisplay.color, fontSize: "12px" }, percentageDisplay.text)));
|
|
40
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Meta, type StoryObj } from "@storybook/react";
|
|
2
|
+
import { MarketPercentIndicator } from "./MarketPercentIndicator";
|
|
3
|
+
declare const meta: Meta<typeof MarketPercentIndicator>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof MarketPercentIndicator>;
|
|
6
|
+
export declare const Positive: Story;
|
|
7
|
+
export declare const Negative: Story;
|
|
8
|
+
export declare const Zero: Story;
|
|
9
|
+
export declare const TestMarketPercentIndicator: Story;
|
|
10
|
+
//# sourceMappingURL=MarketPercentIndicator.stories.d.ts.map
|
package/lib/pre-ldls/components/MarketPercentIndicator/MarketPercentIndicator.stories.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarketPercentIndicator.stories.d.ts","sourceRoot":"","sources":["../../../../src/pre-ldls/components/MarketPercentIndicator/MarketPercentIndicator.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,sBAAsB,CAK7C,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAErD,eAAO,MAAM,QAAQ,EAAE,KAAiC,CAAC;AACzD,eAAO,MAAM,QAAQ,EAAE,KAAkC,CAAC;AAC1D,eAAO,MAAM,IAAI,EAAE,KAAgC,CAAC;AAEpD,eAAO,MAAM,0BAA0B,EAAE,KAMxC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MarketPercentIndicator } from "./MarketPercentIndicator";
|
|
2
|
+
import { expect } from "@storybook/jest";
|
|
3
|
+
import { within } from "@storybook/testing-library";
|
|
4
|
+
const meta = {
|
|
5
|
+
component: MarketPercentIndicator,
|
|
6
|
+
title: "PreLdls/Components/MarketPercentIndicator",
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
args: { percent: 30 },
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
export const Positive = { args: { percent: 30 } };
|
|
12
|
+
export const Negative = { args: { percent: -30 } };
|
|
13
|
+
export const Zero = { args: { percent: 0 } };
|
|
14
|
+
export const TestMarketPercentIndicator = {
|
|
15
|
+
play: async ({ canvasElement }) => {
|
|
16
|
+
const canvas = within(canvasElement);
|
|
17
|
+
const input = canvas.getByTestId("market-percent-indicator");
|
|
18
|
+
await expect(input).toHaveTextContent("+30%");
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarketPriceIndicator.d.ts","sourceRoot":"","sources":["../../../../src/pre-ldls/components/MarketPriceIndicator/MarketPriceIndicator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAwB1B,eAAO,MAAM,oBAAoB;aAAmC,MAAM;WAAS,MAAM;uBA0BxF,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useTokens } from "../../libs";
|
|
3
|
+
import { useTheme } from "styled-components/native";
|
|
4
|
+
import { Flex, Text } from "../../../components";
|
|
5
|
+
const getPercentageDisplay = (percent, tokens) => {
|
|
6
|
+
if (percent > 0) {
|
|
7
|
+
return {
|
|
8
|
+
color: String(tokens["colors-surface-status-success-strong-default"]),
|
|
9
|
+
text: `+${percent}%`,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
if (percent < 0) {
|
|
13
|
+
return {
|
|
14
|
+
color: String(tokens["colors-surface-status-error-strong-default"]),
|
|
15
|
+
text: `-${Math.abs(percent)}%`,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
color: String(tokens["colors-content-default-default"]),
|
|
20
|
+
text: `${percent}%`,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export const MarketPriceIndicator = ({ percent, price }) => {
|
|
24
|
+
const { theme } = useTheme();
|
|
25
|
+
const colorType = theme;
|
|
26
|
+
const tokens = useTokens(colorType, [
|
|
27
|
+
"colors-surface-status-success-strong-default",
|
|
28
|
+
"colors-surface-status-error-strong-default",
|
|
29
|
+
"colors-content-default-default",
|
|
30
|
+
]);
|
|
31
|
+
const percentageDisplay = getPercentageDisplay(percent, tokens);
|
|
32
|
+
return (React.createElement(Flex, { "data-testid": "market-price-indicator", flexDirection: "column", alignItems: "flex-end", width: "fit-content" },
|
|
33
|
+
React.createElement(Text, { variant: "body", fontWeight: "semiBold", mb: "4px" }, price),
|
|
34
|
+
React.createElement(Text, { color: percentageDisplay.color, fontSize: "12px" }, percentageDisplay.text)));
|
|
35
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Meta, type StoryObj } from "@storybook/react";
|
|
2
|
+
import { MarketPriceIndicator } from "./MarketPriceIndicator";
|
|
3
|
+
declare const meta: Meta<typeof MarketPriceIndicator>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof MarketPriceIndicator>;
|
|
6
|
+
export declare const Positive: Story;
|
|
7
|
+
export declare const Negative: Story;
|
|
8
|
+
export declare const Zero: Story;
|
|
9
|
+
export declare const TestMarketPriceIndicator: Story;
|
|
10
|
+
//# sourceMappingURL=MarketPriceIndicator.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarketPriceIndicator.stories.d.ts","sourceRoot":"","sources":["../../../../src/pre-ldls/components/MarketPriceIndicator/MarketPriceIndicator.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAI9D,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,oBAAoB,CAK3C,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEnD,eAAO,MAAM,QAAQ,EAAE,KAAuD,CAAC;AAC/E,eAAO,MAAM,QAAQ,EAAE,KAAwD,CAAC;AAChF,eAAO,MAAM,IAAI,EAAE,KAAsD,CAAC;AAE1E,eAAO,MAAM,wBAAwB,EAAE,KAMtC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MarketPriceIndicator } from "./MarketPriceIndicator";
|
|
2
|
+
import { expect } from "@storybook/jest";
|
|
3
|
+
import { within } from "@storybook/testing-library";
|
|
4
|
+
const meta = {
|
|
5
|
+
component: MarketPriceIndicator,
|
|
6
|
+
title: "PreLdls/Components/MarketPriceIndicator",
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
args: { percent: 30, price: "$100,000.00" },
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
export const Positive = { args: { percent: 30, price: "$100,000.00" } };
|
|
12
|
+
export const Negative = { args: { percent: -30, price: "$100,000.00" } };
|
|
13
|
+
export const Zero = { args: { percent: 0, price: "$100,000.00" } };
|
|
14
|
+
export const TestMarketPriceIndicator = {
|
|
15
|
+
play: async ({ canvasElement }) => {
|
|
16
|
+
const canvas = within(canvasElement);
|
|
17
|
+
const input = canvas.getByTestId("market-price-indicator");
|
|
18
|
+
await expect(input).toHaveTextContent("$100,000.00");
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -2,6 +2,8 @@ export * from "./Input/Input";
|
|
|
2
2
|
export * from "./AssetItem/AssetItem";
|
|
3
3
|
export * from "./AssetTypeList/AssetList";
|
|
4
4
|
export * from "./ApyIndicator/ApyIndicator";
|
|
5
|
+
export * from "./MarketPriceIndicator/MarketPriceIndicator";
|
|
6
|
+
export * from "./MarketPercentIndicator/MarketPercentIndicator";
|
|
5
7
|
export * from "./NetworkItem/NetworkItem";
|
|
6
8
|
export * from "./NetworkList/NetworkList";
|
|
7
9
|
export * from "./Tag/Tag";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pre-ldls/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,qCAAqC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pre-ldls/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6CAA6C,CAAC;AAC5D,cAAc,iDAAiD,CAAC;AAChE,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,qCAAqC,CAAC"}
|
|
@@ -2,6 +2,8 @@ export * from "./Input/Input";
|
|
|
2
2
|
export * from "./AssetItem/AssetItem";
|
|
3
3
|
export * from "./AssetTypeList/AssetList";
|
|
4
4
|
export * from "./ApyIndicator/ApyIndicator";
|
|
5
|
+
export * from "./MarketPriceIndicator/MarketPriceIndicator";
|
|
6
|
+
export * from "./MarketPercentIndicator/MarketPercentIndicator";
|
|
5
7
|
export * from "./NetworkItem/NetworkItem";
|
|
6
8
|
export * from "./NetworkList/NetworkList";
|
|
7
9
|
export * from "./Tag/Tag";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/native-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.0-nightly.0",
|
|
4
4
|
"description": "Ledger Live - Mobile UI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"react-native-modal": "14.0.0-rc.1",
|
|
41
41
|
"rn-range-slider": "2.1.1",
|
|
42
42
|
"styled-system": "^5.1.5",
|
|
43
|
-
"@ledgerhq/crypto-icons-ui": "^1.
|
|
44
|
-
"@ledgerhq/icons-ui": "^0.
|
|
43
|
+
"@ledgerhq/crypto-icons-ui": "^1.19.0-nightly.1",
|
|
44
|
+
"@ledgerhq/icons-ui": "^0.14.0-nightly.0",
|
|
45
45
|
"@ledgerhq/ui-shared": "^0.4.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|