@transferwise/components 0.0.0-experimental-35e180c → 0.0.0-experimental-85a752f
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/build/main.css +59 -0
- package/build/styles/item/Item.css +59 -0
- package/build/styles/main.css +59 -0
- package/build/types/item/Item.d.ts +3 -0
- package/build/types/item/Item.d.ts.map +1 -0
- package/build/types/item/Item.types.d.ts +22 -0
- package/build/types/item/Item.types.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/item/Item.css +59 -0
- package/src/item/Item.less +68 -0
- package/src/item/Item.story.tsx +203 -0
- package/src/item/Item.tsx +88 -0
- package/src/item/Item.types.ts +39 -0
- package/src/main.css +59 -0
- package/src/main.less +1 -0
package/build/main.css
CHANGED
|
@@ -2626,6 +2626,65 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
2626
2626
|
border-radius: 9999px !important;
|
|
2627
2627
|
border-radius: var(--radius-full) !important;
|
|
2628
2628
|
}
|
|
2629
|
+
.item {
|
|
2630
|
+
padding: 16px;
|
|
2631
|
+
border-radius: 16px;
|
|
2632
|
+
border-radius: var(--radius-medium);
|
|
2633
|
+
background-color: #ffffff;
|
|
2634
|
+
background-color: var(--color-background-screen);
|
|
2635
|
+
display: flex;
|
|
2636
|
+
gap: 16px;
|
|
2637
|
+
align-items: center;
|
|
2638
|
+
flex-direction: row;
|
|
2639
|
+
}
|
|
2640
|
+
.item:disabled {
|
|
2641
|
+
opacity: 0.45;
|
|
2642
|
+
mix-blend-mode: luminosity;
|
|
2643
|
+
}
|
|
2644
|
+
.item:hover {
|
|
2645
|
+
background-color: var(--color-background-screen-hover);
|
|
2646
|
+
}
|
|
2647
|
+
.item:active {
|
|
2648
|
+
background-color: var(--color-background-screen-active);
|
|
2649
|
+
}
|
|
2650
|
+
.item-media {
|
|
2651
|
+
flex: 0 0 auto;
|
|
2652
|
+
align-items: flex-start;
|
|
2653
|
+
}
|
|
2654
|
+
.startValue {
|
|
2655
|
+
flex: 1;
|
|
2656
|
+
}
|
|
2657
|
+
.endValue {
|
|
2658
|
+
flex: 1;
|
|
2659
|
+
text-align: end;
|
|
2660
|
+
}
|
|
2661
|
+
.endValue.positive {
|
|
2662
|
+
color: var(--color-sentiment-positive) !important;
|
|
2663
|
+
}
|
|
2664
|
+
.endValue.negative {
|
|
2665
|
+
color: var(--color-sentiment-negative) !important;
|
|
2666
|
+
}
|
|
2667
|
+
.endValue.positive .item-title {
|
|
2668
|
+
color: var(--color-sentiment-positive) !important;
|
|
2669
|
+
}
|
|
2670
|
+
.endValue.negative .item-title {
|
|
2671
|
+
color: var(--color-sentiment-negative) !important;
|
|
2672
|
+
}
|
|
2673
|
+
.endValue.strikethrough {
|
|
2674
|
+
-webkit-text-decoration: line-through;
|
|
2675
|
+
text-decoration: line-through;
|
|
2676
|
+
}
|
|
2677
|
+
.item-title {
|
|
2678
|
+
color: #37517e;
|
|
2679
|
+
color: var(--color-content-primary);
|
|
2680
|
+
}
|
|
2681
|
+
.item-additionalInfo {
|
|
2682
|
+
color: #768e9c;
|
|
2683
|
+
color: var(--color-content-tertiary);
|
|
2684
|
+
}
|
|
2685
|
+
.item-action {
|
|
2686
|
+
flex: 0 0 auto;
|
|
2687
|
+
}
|
|
2629
2688
|
.np-field-control {
|
|
2630
2689
|
margin-top: 4px;
|
|
2631
2690
|
margin-top: var(--size-4);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
.item {
|
|
2
|
+
padding: 16px;
|
|
3
|
+
border-radius: 16px;
|
|
4
|
+
border-radius: var(--radius-medium);
|
|
5
|
+
background-color: #ffffff;
|
|
6
|
+
background-color: var(--color-background-screen);
|
|
7
|
+
display: flex;
|
|
8
|
+
gap: 16px;
|
|
9
|
+
align-items: center;
|
|
10
|
+
flex-direction: row;
|
|
11
|
+
}
|
|
12
|
+
.item:disabled {
|
|
13
|
+
opacity: 0.45;
|
|
14
|
+
mix-blend-mode: luminosity;
|
|
15
|
+
}
|
|
16
|
+
.item:hover {
|
|
17
|
+
background-color: var(--color-background-screen-hover);
|
|
18
|
+
}
|
|
19
|
+
.item:active {
|
|
20
|
+
background-color: var(--color-background-screen-active);
|
|
21
|
+
}
|
|
22
|
+
.item-media {
|
|
23
|
+
flex: 0 0 auto;
|
|
24
|
+
align-items: flex-start;
|
|
25
|
+
}
|
|
26
|
+
.startValue {
|
|
27
|
+
flex: 1;
|
|
28
|
+
}
|
|
29
|
+
.endValue {
|
|
30
|
+
flex: 1;
|
|
31
|
+
text-align: end;
|
|
32
|
+
}
|
|
33
|
+
.endValue.positive {
|
|
34
|
+
color: var(--color-sentiment-positive) !important;
|
|
35
|
+
}
|
|
36
|
+
.endValue.negative {
|
|
37
|
+
color: var(--color-sentiment-negative) !important;
|
|
38
|
+
}
|
|
39
|
+
.endValue.positive .item-title {
|
|
40
|
+
color: var(--color-sentiment-positive) !important;
|
|
41
|
+
}
|
|
42
|
+
.endValue.negative .item-title {
|
|
43
|
+
color: var(--color-sentiment-negative) !important;
|
|
44
|
+
}
|
|
45
|
+
.endValue.strikethrough {
|
|
46
|
+
-webkit-text-decoration: line-through;
|
|
47
|
+
text-decoration: line-through;
|
|
48
|
+
}
|
|
49
|
+
.item-title {
|
|
50
|
+
color: #37517e;
|
|
51
|
+
color: var(--color-content-primary);
|
|
52
|
+
}
|
|
53
|
+
.item-additionalInfo {
|
|
54
|
+
color: #768e9c;
|
|
55
|
+
color: var(--color-content-tertiary);
|
|
56
|
+
}
|
|
57
|
+
.item-action {
|
|
58
|
+
flex: 0 0 auto;
|
|
59
|
+
}
|
package/build/styles/main.css
CHANGED
|
@@ -2626,6 +2626,65 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
2626
2626
|
border-radius: 9999px !important;
|
|
2627
2627
|
border-radius: var(--radius-full) !important;
|
|
2628
2628
|
}
|
|
2629
|
+
.item {
|
|
2630
|
+
padding: 16px;
|
|
2631
|
+
border-radius: 16px;
|
|
2632
|
+
border-radius: var(--radius-medium);
|
|
2633
|
+
background-color: #ffffff;
|
|
2634
|
+
background-color: var(--color-background-screen);
|
|
2635
|
+
display: flex;
|
|
2636
|
+
gap: 16px;
|
|
2637
|
+
align-items: center;
|
|
2638
|
+
flex-direction: row;
|
|
2639
|
+
}
|
|
2640
|
+
.item:disabled {
|
|
2641
|
+
opacity: 0.45;
|
|
2642
|
+
mix-blend-mode: luminosity;
|
|
2643
|
+
}
|
|
2644
|
+
.item:hover {
|
|
2645
|
+
background-color: var(--color-background-screen-hover);
|
|
2646
|
+
}
|
|
2647
|
+
.item:active {
|
|
2648
|
+
background-color: var(--color-background-screen-active);
|
|
2649
|
+
}
|
|
2650
|
+
.item-media {
|
|
2651
|
+
flex: 0 0 auto;
|
|
2652
|
+
align-items: flex-start;
|
|
2653
|
+
}
|
|
2654
|
+
.startValue {
|
|
2655
|
+
flex: 1;
|
|
2656
|
+
}
|
|
2657
|
+
.endValue {
|
|
2658
|
+
flex: 1;
|
|
2659
|
+
text-align: end;
|
|
2660
|
+
}
|
|
2661
|
+
.endValue.positive {
|
|
2662
|
+
color: var(--color-sentiment-positive) !important;
|
|
2663
|
+
}
|
|
2664
|
+
.endValue.negative {
|
|
2665
|
+
color: var(--color-sentiment-negative) !important;
|
|
2666
|
+
}
|
|
2667
|
+
.endValue.positive .item-title {
|
|
2668
|
+
color: var(--color-sentiment-positive) !important;
|
|
2669
|
+
}
|
|
2670
|
+
.endValue.negative .item-title {
|
|
2671
|
+
color: var(--color-sentiment-negative) !important;
|
|
2672
|
+
}
|
|
2673
|
+
.endValue.strikethrough {
|
|
2674
|
+
-webkit-text-decoration: line-through;
|
|
2675
|
+
text-decoration: line-through;
|
|
2676
|
+
}
|
|
2677
|
+
.item-title {
|
|
2678
|
+
color: #37517e;
|
|
2679
|
+
color: var(--color-content-primary);
|
|
2680
|
+
}
|
|
2681
|
+
.item-additionalInfo {
|
|
2682
|
+
color: #768e9c;
|
|
2683
|
+
color: var(--color-content-tertiary);
|
|
2684
|
+
}
|
|
2685
|
+
.item-action {
|
|
2686
|
+
flex: 0 0 auto;
|
|
2687
|
+
}
|
|
2629
2688
|
.np-field-control {
|
|
2630
2689
|
margin-top: 4px;
|
|
2631
2690
|
margin-top: var(--size-4);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../../src/item/Item.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzC,eAAO,MAAM,IAAI,0EAQd,SAAS,gCAmEX,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Sentiment } from '../common';
|
|
3
|
+
export type ItemTypes = 'NonInteractive' | 'Navigation' | 'Radio' | 'Checkbox' | 'Switch' | 'Button' | 'IconButton';
|
|
4
|
+
export type EndValueProps = {
|
|
5
|
+
title?: string;
|
|
6
|
+
subtitle?: string;
|
|
7
|
+
sentiment?: Sentiment.POSITIVE | Sentiment.NEGATIVE;
|
|
8
|
+
strikethrough?: boolean;
|
|
9
|
+
bold?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export interface ItemProps {
|
|
12
|
+
type: ItemTypes;
|
|
13
|
+
media?: {
|
|
14
|
+
value: ReactNode;
|
|
15
|
+
};
|
|
16
|
+
title: string;
|
|
17
|
+
subtitle?: string;
|
|
18
|
+
additionalInfo?: string;
|
|
19
|
+
inverted?: boolean;
|
|
20
|
+
endValue?: EndValueProps;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=Item.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Item.types.d.ts","sourceRoot":"","sources":["../../../src/item/Item.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,SAAS,GACjB,gBAAgB,GAChB,YAAY,GACZ,OAAO,GACP,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,YAAY,CAAC;AAEjB,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;IACpD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,SAAS,CAAC;IAEhB,KAAK,CAAC,EAAE;QAEN,KAAK,EAAE,SAAS,CAAC;KAClB,CAAC;IACF,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,aAAa,CAAC;CAI1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-85a752f",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
"rollup-preserve-directives": "^1.1.1",
|
|
93
93
|
"storybook": "^8.2.2",
|
|
94
94
|
"@transferwise/less-config": "3.1.0",
|
|
95
|
-
"@
|
|
96
|
-
"@
|
|
95
|
+
"@wise/components-theming": "1.6.1",
|
|
96
|
+
"@transferwise/neptune-css": "14.22.0"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"@transferwise/icons": "^3.13.1",
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
.item {
|
|
2
|
+
padding: 16px;
|
|
3
|
+
border-radius: 16px;
|
|
4
|
+
border-radius: var(--radius-medium);
|
|
5
|
+
background-color: #ffffff;
|
|
6
|
+
background-color: var(--color-background-screen);
|
|
7
|
+
display: flex;
|
|
8
|
+
gap: 16px;
|
|
9
|
+
align-items: center;
|
|
10
|
+
flex-direction: row;
|
|
11
|
+
}
|
|
12
|
+
.item:disabled {
|
|
13
|
+
opacity: 0.45;
|
|
14
|
+
mix-blend-mode: luminosity;
|
|
15
|
+
}
|
|
16
|
+
.item:hover {
|
|
17
|
+
background-color: var(--color-background-screen-hover);
|
|
18
|
+
}
|
|
19
|
+
.item:active {
|
|
20
|
+
background-color: var(--color-background-screen-active);
|
|
21
|
+
}
|
|
22
|
+
.item-media {
|
|
23
|
+
flex: 0 0 auto;
|
|
24
|
+
align-items: flex-start;
|
|
25
|
+
}
|
|
26
|
+
.startValue {
|
|
27
|
+
flex: 1;
|
|
28
|
+
}
|
|
29
|
+
.endValue {
|
|
30
|
+
flex: 1;
|
|
31
|
+
text-align: end;
|
|
32
|
+
}
|
|
33
|
+
.endValue.positive {
|
|
34
|
+
color: var(--color-sentiment-positive) !important;
|
|
35
|
+
}
|
|
36
|
+
.endValue.negative {
|
|
37
|
+
color: var(--color-sentiment-negative) !important;
|
|
38
|
+
}
|
|
39
|
+
.endValue.positive .item-title {
|
|
40
|
+
color: var(--color-sentiment-positive) !important;
|
|
41
|
+
}
|
|
42
|
+
.endValue.negative .item-title {
|
|
43
|
+
color: var(--color-sentiment-negative) !important;
|
|
44
|
+
}
|
|
45
|
+
.endValue.strikethrough {
|
|
46
|
+
-webkit-text-decoration: line-through;
|
|
47
|
+
text-decoration: line-through;
|
|
48
|
+
}
|
|
49
|
+
.item-title {
|
|
50
|
+
color: #37517e;
|
|
51
|
+
color: var(--color-content-primary);
|
|
52
|
+
}
|
|
53
|
+
.item-additionalInfo {
|
|
54
|
+
color: #768e9c;
|
|
55
|
+
color: var(--color-content-tertiary);
|
|
56
|
+
}
|
|
57
|
+
.item-action {
|
|
58
|
+
flex: 0 0 auto;
|
|
59
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
.item {
|
|
2
|
+
padding: 16px;
|
|
3
|
+
border-radius: var(--radius-medium);
|
|
4
|
+
background-color: var(--color-background-screen);
|
|
5
|
+
display: flex;
|
|
6
|
+
gap: 16px;
|
|
7
|
+
align-items: center;
|
|
8
|
+
flex-direction: row;
|
|
9
|
+
|
|
10
|
+
&:disabled {
|
|
11
|
+
opacity: 0.45;
|
|
12
|
+
mix-blend-mode: luminosity;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&:hover {
|
|
16
|
+
background-color: var(--color-background-screen-hover);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&:active {
|
|
20
|
+
background-color: var(--color-background-screen-active);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// all inverted logic can be way simpler
|
|
24
|
+
.item-media {
|
|
25
|
+
flex: 0 0 auto;
|
|
26
|
+
align-items: flex-start;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.startValue {
|
|
30
|
+
flex: 1;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.endValue {
|
|
34
|
+
flex: 1;
|
|
35
|
+
text-align: end;
|
|
36
|
+
|
|
37
|
+
&.positive {
|
|
38
|
+
color: var(--color-sentiment-positive) !important;
|
|
39
|
+
}
|
|
40
|
+
&.negative {
|
|
41
|
+
color: var(--color-sentiment-negative) !important;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
.endValue.positive {
|
|
45
|
+
.item-title {
|
|
46
|
+
color: var(--color-sentiment-positive) !important;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
.endValue.negative {
|
|
50
|
+
.item-title {
|
|
51
|
+
color: var(--color-sentiment-negative) !important;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
.endValue.strikethrough {
|
|
55
|
+
text-decoration: line-through;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.item-title {
|
|
59
|
+
color: var(--color-content-primary)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.item-additionalInfo {
|
|
63
|
+
color: var(--color-content-tertiary)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.item-action {
|
|
67
|
+
flex: 0 0 auto;
|
|
68
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { Item } from './Item';
|
|
2
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import AvatarView from '../avatarView';
|
|
4
|
+
import { Sentiment } from '../common';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { ItemProps } from './Item.types';
|
|
7
|
+
|
|
8
|
+
type ItemStoryProps = Omit<ItemProps, 'media'> & {
|
|
9
|
+
mediaSize?: number;
|
|
10
|
+
media?: {
|
|
11
|
+
value: React.ReactElement;
|
|
12
|
+
};
|
|
13
|
+
endValueTitle?: string;
|
|
14
|
+
endValueSubtitle?: string;
|
|
15
|
+
endValueInverted?: boolean;
|
|
16
|
+
endValueStrikethrough?: boolean;
|
|
17
|
+
endValueSentiment?: Sentiment.NEGATIVE | Sentiment.POSITIVE | undefined;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
component: Item,
|
|
22
|
+
title: 'Content/Item',
|
|
23
|
+
args: {
|
|
24
|
+
type: 'Navigation',
|
|
25
|
+
title: 'Title',
|
|
26
|
+
subtitle: 'Subtitle',
|
|
27
|
+
additionalInfo: 'Additional Info',
|
|
28
|
+
inverted: false,
|
|
29
|
+
media: {
|
|
30
|
+
value: <AvatarView profileName="H D" />,
|
|
31
|
+
},
|
|
32
|
+
mediaSize: 48,
|
|
33
|
+
endValueTitle: '427,386.39 JPY',
|
|
34
|
+
endValueSubtitle: '2197.06 GBP',
|
|
35
|
+
endValueStrikethrough: false,
|
|
36
|
+
endValueSentiment: undefined,
|
|
37
|
+
},
|
|
38
|
+
} satisfies Meta<ItemStoryProps>;
|
|
39
|
+
|
|
40
|
+
type Story = StoryObj<ItemStoryProps>;
|
|
41
|
+
|
|
42
|
+
export const Playground: Story = {
|
|
43
|
+
parameters: {
|
|
44
|
+
controls: {
|
|
45
|
+
exclude: ['media', 'endValue'],
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
argTypes: {
|
|
49
|
+
type: {
|
|
50
|
+
control: 'radio',
|
|
51
|
+
options: ['NonInteractive', 'Navigation', 'Switch', 'Checkbox', 'Radio', 'IconButton'],
|
|
52
|
+
table: {
|
|
53
|
+
category: 'Type',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
mediaSize: {
|
|
57
|
+
control: 'radio',
|
|
58
|
+
options: [0, 32, 40, 48, 56, 72],
|
|
59
|
+
defaultValue: 48,
|
|
60
|
+
},
|
|
61
|
+
title: {
|
|
62
|
+
control: 'text',
|
|
63
|
+
table: {
|
|
64
|
+
category: 'Start Value Controls',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
subtitle: {
|
|
68
|
+
control: 'text',
|
|
69
|
+
table: {
|
|
70
|
+
category: 'Start Value Controls',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
additionalInfo: {
|
|
74
|
+
control: 'text',
|
|
75
|
+
table: {
|
|
76
|
+
category: 'Start Value Controls',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
inverted: {
|
|
80
|
+
control: 'boolean',
|
|
81
|
+
table: {
|
|
82
|
+
category: 'Global Control',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
endValueTitle: {
|
|
87
|
+
control: 'text',
|
|
88
|
+
table: {
|
|
89
|
+
category: 'End Value Controls',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
endValueSubtitle: {
|
|
93
|
+
control: 'text',
|
|
94
|
+
table: {
|
|
95
|
+
category: 'End Value Controls',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
endValueStrikethrough: {
|
|
99
|
+
control: 'boolean',
|
|
100
|
+
table: {
|
|
101
|
+
category: 'End Value Controls',
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
endValueSentiment: {
|
|
105
|
+
control: 'radio',
|
|
106
|
+
options: ['POSITIVE', 'NEGATIVE', 'none'],
|
|
107
|
+
defaultValue: 'none',
|
|
108
|
+
mapping: {
|
|
109
|
+
POSITIVE: Sentiment.POSITIVE,
|
|
110
|
+
NEGATIVE: Sentiment.NEGATIVE,
|
|
111
|
+
none: undefined,
|
|
112
|
+
},
|
|
113
|
+
table: {
|
|
114
|
+
category: 'End Value Controls',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
render: (args) => {
|
|
119
|
+
const {
|
|
120
|
+
mediaSize,
|
|
121
|
+
media,
|
|
122
|
+
endValueTitle,
|
|
123
|
+
endValueSubtitle,
|
|
124
|
+
endValueStrikethrough,
|
|
125
|
+
endValueSentiment,
|
|
126
|
+
...restProps
|
|
127
|
+
} = args;
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<Item
|
|
131
|
+
{...restProps}
|
|
132
|
+
media={
|
|
133
|
+
mediaSize === 0 || !media
|
|
134
|
+
? undefined
|
|
135
|
+
: {
|
|
136
|
+
value: React.cloneElement(media.value, { size: mediaSize }),
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
endValue={{
|
|
140
|
+
title: endValueTitle,
|
|
141
|
+
subtitle: endValueSubtitle,
|
|
142
|
+
strikethrough: endValueStrikethrough,
|
|
143
|
+
sentiment: endValueSentiment,
|
|
144
|
+
}}
|
|
145
|
+
/>
|
|
146
|
+
);
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
export const Variants: Story = {
|
|
150
|
+
render: () => (
|
|
151
|
+
<>
|
|
152
|
+
<Item type="NonInteractive" title="Title" />
|
|
153
|
+
<Item
|
|
154
|
+
media={{ value: <AvatarView size={48} profileName="H D" /> }}
|
|
155
|
+
type="Navigation"
|
|
156
|
+
title="Title"
|
|
157
|
+
/>
|
|
158
|
+
<Item
|
|
159
|
+
type="Navigation"
|
|
160
|
+
title="Title"
|
|
161
|
+
subtitle="Subtitle"
|
|
162
|
+
media={{ value: <AvatarView size={32} profileName="H D" /> }}
|
|
163
|
+
endValue={{ title: '427,386.39 JPY', sentiment: Sentiment.NEGATIVE }}
|
|
164
|
+
/>
|
|
165
|
+
<Item
|
|
166
|
+
type="Switch"
|
|
167
|
+
title="Title"
|
|
168
|
+
subtitle="Subtitle"
|
|
169
|
+
additionalInfo="Additional Info"
|
|
170
|
+
media={{ value: <AvatarView size={40} profileName="H D" /> }}
|
|
171
|
+
endValue={{
|
|
172
|
+
title: '427,386.39 JPY',
|
|
173
|
+
subtitle: '2197.06 GBP',
|
|
174
|
+
sentiment: Sentiment.POSITIVE,
|
|
175
|
+
}}
|
|
176
|
+
/>
|
|
177
|
+
<Item
|
|
178
|
+
type="Checkbox"
|
|
179
|
+
title="Title Inverted"
|
|
180
|
+
subtitle="Subtitle"
|
|
181
|
+
additionalInfo="Additional Info"
|
|
182
|
+
inverted
|
|
183
|
+
media={{ value: <AvatarView size={48} profileName="H D" /> }}
|
|
184
|
+
endValue={{ title: 'Title Inverted', subtitle: 'Subtitle' }}
|
|
185
|
+
/>
|
|
186
|
+
<Item
|
|
187
|
+
type="Radio"
|
|
188
|
+
title="Title Inverted"
|
|
189
|
+
subtitle="Subtitle"
|
|
190
|
+
inverted
|
|
191
|
+
media={{ value: <AvatarView size={56} profileName="H D" /> }}
|
|
192
|
+
endValue={{ title: 'Title Inverted' }}
|
|
193
|
+
/>
|
|
194
|
+
<Item
|
|
195
|
+
type="IconButton"
|
|
196
|
+
title="Title Inverted"
|
|
197
|
+
inverted
|
|
198
|
+
media={{ value: <AvatarView size={72} profileName="H D" /> }}
|
|
199
|
+
endValue={{ subtitle: 'Subtitle Inverted' }}
|
|
200
|
+
/>
|
|
201
|
+
</>
|
|
202
|
+
),
|
|
203
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import RadioButton from '../common/RadioButton';
|
|
3
|
+
import { Position, Sentiment, Typography } from '../common';
|
|
4
|
+
import Button from '../button';
|
|
5
|
+
import CheckboxButton from '../checkboxButton';
|
|
6
|
+
import Chevron from '../chevron';
|
|
7
|
+
import IconButton from '../iconButton';
|
|
8
|
+
import Switch from '../switch';
|
|
9
|
+
import { ItemProps } from './Item.types';
|
|
10
|
+
import Body from '../body';
|
|
11
|
+
import { InfoCircle } from '@transferwise/icons';
|
|
12
|
+
|
|
13
|
+
export const Item = ({
|
|
14
|
+
type,
|
|
15
|
+
title,
|
|
16
|
+
subtitle,
|
|
17
|
+
additionalInfo,
|
|
18
|
+
inverted,
|
|
19
|
+
media,
|
|
20
|
+
endValue,
|
|
21
|
+
}: ItemProps) => {
|
|
22
|
+
const returnType = (): ReactNode => {
|
|
23
|
+
switch (type) {
|
|
24
|
+
case 'Navigation':
|
|
25
|
+
return <Chevron orientation={Position.RIGHT} disabled />;
|
|
26
|
+
case 'Radio':
|
|
27
|
+
return <RadioButton name="Hello" checked />;
|
|
28
|
+
case 'Checkbox':
|
|
29
|
+
return <CheckboxButton name="Hello" checked />;
|
|
30
|
+
case 'Switch':
|
|
31
|
+
return <Switch onClick={() => console.log('clicked')} />;
|
|
32
|
+
case 'Button':
|
|
33
|
+
return <Button v2>Hello</Button>;
|
|
34
|
+
case 'IconButton':
|
|
35
|
+
return (
|
|
36
|
+
<IconButton priority="minimal">
|
|
37
|
+
<InfoCircle />
|
|
38
|
+
</IconButton>
|
|
39
|
+
);
|
|
40
|
+
case 'NonInteractive':
|
|
41
|
+
default:
|
|
42
|
+
return <></>;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// clean up how classes are applied
|
|
47
|
+
return (
|
|
48
|
+
<div className={`item ${inverted ? 'inverted' : ''}`}>
|
|
49
|
+
{media && <div className="item-media">{media?.value}</div>}
|
|
50
|
+
<div className="startValue">
|
|
51
|
+
<Body
|
|
52
|
+
className={!inverted ? 'item-title' : ''}
|
|
53
|
+
type={!inverted ? Typography.BODY_LARGE_BOLD : Typography.BODY_DEFAULT}
|
|
54
|
+
>
|
|
55
|
+
{title}
|
|
56
|
+
</Body>
|
|
57
|
+
<Body
|
|
58
|
+
className={inverted ? 'item-title' : ''}
|
|
59
|
+
type={!inverted ? Typography.BODY_DEFAULT : Typography.BODY_LARGE_BOLD}
|
|
60
|
+
>
|
|
61
|
+
{subtitle}
|
|
62
|
+
</Body>
|
|
63
|
+
<Body className="item-additionalInfo" type={Typography.BODY_DEFAULT}>
|
|
64
|
+
{subtitle && additionalInfo}
|
|
65
|
+
</Body>
|
|
66
|
+
</div>
|
|
67
|
+
{endValue && (
|
|
68
|
+
<div
|
|
69
|
+
className={`endValue ${endValue.sentiment} ${endValue.strikethrough ? 'strikethrough' : ''}`}
|
|
70
|
+
>
|
|
71
|
+
<Body
|
|
72
|
+
className={!inverted ? 'item-title' : endValue.sentiment}
|
|
73
|
+
type={!inverted ? Typography.BODY_LARGE_BOLD : Typography.BODY_DEFAULT}
|
|
74
|
+
>
|
|
75
|
+
{endValue.title}
|
|
76
|
+
</Body>
|
|
77
|
+
<Body
|
|
78
|
+
className={inverted ? 'item-title' : endValue.sentiment}
|
|
79
|
+
type={!inverted ? Typography.BODY_DEFAULT : Typography.BODY_LARGE_BOLD}
|
|
80
|
+
>
|
|
81
|
+
{endValue.subtitle}
|
|
82
|
+
</Body>
|
|
83
|
+
</div>
|
|
84
|
+
)}
|
|
85
|
+
{type !== 'NonInteractive' && <div className="item-action">{returnType()}</div>}
|
|
86
|
+
</div>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Sentiment } from '../common';
|
|
3
|
+
|
|
4
|
+
export type ItemTypes =
|
|
5
|
+
| 'NonInteractive'
|
|
6
|
+
| 'Navigation'
|
|
7
|
+
| 'Radio'
|
|
8
|
+
| 'Checkbox'
|
|
9
|
+
| 'Switch'
|
|
10
|
+
| 'Button'
|
|
11
|
+
| 'IconButton';
|
|
12
|
+
|
|
13
|
+
export type EndValueProps = {
|
|
14
|
+
title?: string;
|
|
15
|
+
subtitle?: string;
|
|
16
|
+
sentiment?: Sentiment.POSITIVE | Sentiment.NEGATIVE;
|
|
17
|
+
strikethrough?: boolean;
|
|
18
|
+
bold?: boolean;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export interface ItemProps {
|
|
22
|
+
type: ItemTypes;
|
|
23
|
+
// as: NonInteractive | Interactive; // is this enough to handle Interaction
|
|
24
|
+
media?: {
|
|
25
|
+
// type?: 'Image' | 'Avatar';
|
|
26
|
+
value: ReactNode; // should we restrict sizes?? how to set default to 48
|
|
27
|
+
};
|
|
28
|
+
title: string;
|
|
29
|
+
subtitle?: string;
|
|
30
|
+
additionalInfo?: string;
|
|
31
|
+
inverted?: boolean;
|
|
32
|
+
endValue?: EndValueProps;
|
|
33
|
+
// prompt?: any; // a lot of work to do here. start with this?
|
|
34
|
+
// spotlight?: 'Active' | 'Inactive';
|
|
35
|
+
// children?: ReactNode;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// type NonInteractive = 'div' | 'span';
|
|
39
|
+
// type Interactive = 'a' | 'button';
|
package/src/main.css
CHANGED
|
@@ -2626,6 +2626,65 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
2626
2626
|
border-radius: 9999px !important;
|
|
2627
2627
|
border-radius: var(--radius-full) !important;
|
|
2628
2628
|
}
|
|
2629
|
+
.item {
|
|
2630
|
+
padding: 16px;
|
|
2631
|
+
border-radius: 16px;
|
|
2632
|
+
border-radius: var(--radius-medium);
|
|
2633
|
+
background-color: #ffffff;
|
|
2634
|
+
background-color: var(--color-background-screen);
|
|
2635
|
+
display: flex;
|
|
2636
|
+
gap: 16px;
|
|
2637
|
+
align-items: center;
|
|
2638
|
+
flex-direction: row;
|
|
2639
|
+
}
|
|
2640
|
+
.item:disabled {
|
|
2641
|
+
opacity: 0.45;
|
|
2642
|
+
mix-blend-mode: luminosity;
|
|
2643
|
+
}
|
|
2644
|
+
.item:hover {
|
|
2645
|
+
background-color: var(--color-background-screen-hover);
|
|
2646
|
+
}
|
|
2647
|
+
.item:active {
|
|
2648
|
+
background-color: var(--color-background-screen-active);
|
|
2649
|
+
}
|
|
2650
|
+
.item-media {
|
|
2651
|
+
flex: 0 0 auto;
|
|
2652
|
+
align-items: flex-start;
|
|
2653
|
+
}
|
|
2654
|
+
.startValue {
|
|
2655
|
+
flex: 1;
|
|
2656
|
+
}
|
|
2657
|
+
.endValue {
|
|
2658
|
+
flex: 1;
|
|
2659
|
+
text-align: end;
|
|
2660
|
+
}
|
|
2661
|
+
.endValue.positive {
|
|
2662
|
+
color: var(--color-sentiment-positive) !important;
|
|
2663
|
+
}
|
|
2664
|
+
.endValue.negative {
|
|
2665
|
+
color: var(--color-sentiment-negative) !important;
|
|
2666
|
+
}
|
|
2667
|
+
.endValue.positive .item-title {
|
|
2668
|
+
color: var(--color-sentiment-positive) !important;
|
|
2669
|
+
}
|
|
2670
|
+
.endValue.negative .item-title {
|
|
2671
|
+
color: var(--color-sentiment-negative) !important;
|
|
2672
|
+
}
|
|
2673
|
+
.endValue.strikethrough {
|
|
2674
|
+
-webkit-text-decoration: line-through;
|
|
2675
|
+
text-decoration: line-through;
|
|
2676
|
+
}
|
|
2677
|
+
.item-title {
|
|
2678
|
+
color: #37517e;
|
|
2679
|
+
color: var(--color-content-primary);
|
|
2680
|
+
}
|
|
2681
|
+
.item-additionalInfo {
|
|
2682
|
+
color: #768e9c;
|
|
2683
|
+
color: var(--color-content-tertiary);
|
|
2684
|
+
}
|
|
2685
|
+
.item-action {
|
|
2686
|
+
flex: 0 0 auto;
|
|
2687
|
+
}
|
|
2629
2688
|
.np-field-control {
|
|
2630
2689
|
margin-top: 4px;
|
|
2631
2690
|
margin-top: var(--size-4);
|
package/src/main.less
CHANGED