@transferwise/components 0.0.0-experimental-e8e1885 → 0.0.0-experimental-d06238a

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.
Files changed (60) hide show
  1. package/build/i18n/cs.json +9 -9
  2. package/build/i18n/cs.json.js +9 -9
  3. package/build/i18n/cs.json.mjs +9 -9
  4. package/build/index.js +1 -0
  5. package/build/index.js.map +1 -1
  6. package/build/index.mjs +1 -1
  7. package/build/main.css +183 -0
  8. package/build/styles/item/Item.css +183 -0
  9. package/build/styles/main.css +183 -0
  10. package/build/test-utils/assets/apple-pay-logo.svg +84 -0
  11. package/build/types/index.d.ts +2 -0
  12. package/build/types/index.d.ts.map +1 -1
  13. package/build/types/item/Item.d.ts +44 -0
  14. package/build/types/item/Item.d.ts.map +1 -0
  15. package/build/types/item/ItemAdditionalInfo.d.ts +9 -0
  16. package/build/types/item/ItemAdditionalInfo.d.ts.map +1 -0
  17. package/build/types/item/ItemButton.d.ts +4 -0
  18. package/build/types/item/ItemButton.d.ts.map +1 -0
  19. package/build/types/item/ItemCheckbox.d.ts +4 -0
  20. package/build/types/item/ItemCheckbox.d.ts.map +1 -0
  21. package/build/types/item/ItemIconButton.d.ts +7 -0
  22. package/build/types/item/ItemIconButton.d.ts.map +1 -0
  23. package/build/types/item/ItemMedia.d.ts +19 -0
  24. package/build/types/item/ItemMedia.d.ts.map +1 -0
  25. package/build/types/item/ItemNavigation.d.ts +4 -0
  26. package/build/types/item/ItemNavigation.d.ts.map +1 -0
  27. package/build/types/item/ItemSwitch.d.ts +3 -0
  28. package/build/types/item/ItemSwitch.d.ts.map +1 -0
  29. package/build/types/item/index.d.ts +6 -0
  30. package/build/types/item/index.d.ts.map +1 -0
  31. package/build/types/item/prompt/Prompt.d.ts +12 -0
  32. package/build/types/item/prompt/Prompt.d.ts.map +1 -0
  33. package/build/types/item/useItemControl.d.ts +5 -0
  34. package/build/types/item/useItemControl.d.ts.map +1 -0
  35. package/build/types/test-utils/fake-data.d.ts +2 -0
  36. package/build/types/test-utils/fake-data.d.ts.map +1 -1
  37. package/package.json +1 -1
  38. package/src/i18n/cs.json +9 -9
  39. package/src/index.ts +2 -0
  40. package/src/item/Item.css +183 -0
  41. package/src/item/Item.less +177 -0
  42. package/src/item/Item.story.tsx +188 -0
  43. package/src/item/Item.tsx +177 -0
  44. package/src/item/ItemAdditionalInfo.tsx +31 -0
  45. package/src/item/ItemButton.spec.tsx +90 -0
  46. package/src/item/ItemButton.tsx +18 -0
  47. package/src/item/ItemCheckbox.tsx +11 -0
  48. package/src/item/ItemIconButton.tsx +13 -0
  49. package/src/item/ItemMedia.tsx +52 -0
  50. package/src/item/ItemNavigation.tsx +11 -0
  51. package/src/item/ItemSwitch.tsx +8 -0
  52. package/src/item/index.ts +6 -0
  53. package/src/item/prompt/Prompt.spec.tsx +77 -0
  54. package/src/item/prompt/Prompt.story.tsx +170 -0
  55. package/src/item/prompt/Prompt.tsx +44 -0
  56. package/src/item/useItemControl.tsx +12 -0
  57. package/src/main.css +183 -0
  58. package/src/main.less +1 -0
  59. package/src/test-utils/assets/apple-pay-logo.svg +84 -0
  60. package/src/test-utils/fake-data.ts +5 -0
@@ -0,0 +1,183 @@
1
+ .np-item {
2
+ padding: 16px;
3
+ padding: var(--size-16);
4
+ border-radius: 24px;
5
+ border-radius: var(--radius-large);
6
+ background-color: #ffffff;
7
+ background-color: var(--color-background-screen);
8
+ gap: 16px;
9
+ gap: var(--size-16);
10
+ cursor: pointer;
11
+ }
12
+ .np-item:hover {
13
+ background-color: var(--color-background-screen-hover);
14
+ }
15
+ .np-item:active {
16
+ background-color: var(--color-background-screen-active);
17
+ }
18
+ .np-item-media-image {
19
+ width: var(--item-media-image-size);
20
+ height: var(--item-media-image-size);
21
+ }
22
+ .np-item-title {
23
+ color: #37517e;
24
+ color: var(--color-content-primary);
25
+ }
26
+ .np-item-additional-info {
27
+ color: #768e9c;
28
+ color: var(--color-content-tertiary);
29
+ }
30
+ .np-item-value {
31
+ flex: 0 0 auto;
32
+ }
33
+ .np-item-control {
34
+ flex: 0 0 auto;
35
+ }
36
+ .np-item-spotlight-active {
37
+ background-color: rgba(134,167,189,0.10196);
38
+ background-color: var(--color-background-neutral);
39
+ }
40
+ .np-item-spotlight-active:hover {
41
+ background-color: var(--color-background-neutral-hover);
42
+ }
43
+ .np-item-spotlight-active:active {
44
+ background-color: var(--color-background-neutral-active);
45
+ }
46
+ .np-item-spotlight-inactive {
47
+ background-color: rgba(134, 167, 189, 0.025);
48
+ border: 1px dashed rgba(0,0,0,0.10196);
49
+ border: 1px dashed var(--color-border-neutral);
50
+ }
51
+ @supports (color: color-mix(in lch, red, blue)) {
52
+ .np-item-spotlight-inactive {
53
+ background-color: color-mix(in srgb, var(--color-background-neutral) 25%, transparent);
54
+ }
55
+ }
56
+ .np-item-spotlight-inactive:hover {
57
+ background-color: color-mix(in srgb, var(--color-background-neutral-hover) 25%, transparent);
58
+ }
59
+ .np-item-spotlight-inactive:active {
60
+ background-color: color-mix(in srgb, var(--color-background-neutral-active) 25%, transparent);
61
+ }
62
+ .np-item-prompt {
63
+ display: inline-flex;
64
+ padding-top: calc(8px / 2);
65
+ padding-top: calc(var(--padding-x-small) / 2);
66
+ padding-bottom: calc(8px / 2);
67
+ padding-bottom: calc(var(--padding-x-small) / 2);
68
+ padding-left: calc(8px - 1px);
69
+ padding-left: calc(var(--padding-x-small) - 1px);
70
+ padding-right: 8px;
71
+ padding-right: var(--padding-x-small);
72
+ border-radius: 10px;
73
+ border-radius: var(--radius-small);
74
+ word-break: break-word;
75
+ word-wrap: break-word;
76
+ }
77
+ .np-item-prompt .np-prompt-icon {
78
+ padding-right: calc(12px / 2);
79
+ padding-right: calc(var(--size-12) / 2);
80
+ padding-top: calc(4px - 1px);
81
+ padding-top: calc(var(--size-4) - 1px);
82
+ padding-bottom: calc(4px - 1px);
83
+ padding-bottom: calc(var(--size-4) - 1px);
84
+ }
85
+ .np-item-prompt .np-prompt-icon .tw-icon-tags,
86
+ .np-item-prompt .np-prompt-icon .tw-icon-confetti {
87
+ color: var(--color-sentiment-positive-primary);
88
+ }
89
+ .np-item-prompt a {
90
+ text-underline-offset: calc(4px / 2);
91
+ text-underline-offset: calc(var(--size-4) / 2);
92
+ }
93
+ .np-item-prompt.np-prompt-interactive {
94
+ -webkit-text-decoration: none;
95
+ text-decoration: none;
96
+ cursor: pointer;
97
+ border: none;
98
+ }
99
+ .np-item-prompt.negative {
100
+ background-color: var(--color-sentiment-negative-secondary);
101
+ color: var(--color-sentiment-negative-primary);
102
+ }
103
+ .np-item-prompt.negative a {
104
+ color: var(--color-sentiment-negative-primary);
105
+ }
106
+ .np-item-prompt.negative a:hover {
107
+ color: var(--color-sentiment-negative-primary-hover);
108
+ }
109
+ .np-item-prompt.negative a:active {
110
+ color: var(--color-sentiment-negative-primary-active);
111
+ }
112
+ .np-prompt-interactive.np-item-prompt.negative:hover {
113
+ background-color: color-mix(in srgb, var(--color-sentiment-negative-secondary) 95%, var(--color-sentiment-negative-primary));
114
+ }
115
+ .np-prompt-interactive.np-item-prompt.negative:active {
116
+ background-color: color-mix(in srgb, var(--color-sentiment-negative-secondary) 90%, var(--color-sentiment-negative-primary));
117
+ }
118
+ .np-item-prompt.positive,
119
+ .np-item-prompt.discount,
120
+ .np-item-prompt.savings {
121
+ background-color: var(--color-sentiment-positive-secondary);
122
+ color: var(--color-sentiment-positive-primary);
123
+ }
124
+ .np-item-prompt.positive a,
125
+ .np-item-prompt.discount a,
126
+ .np-item-prompt.savings a {
127
+ color: var(--color-sentiment-positive-primary);
128
+ }
129
+ .np-item-prompt.positive a:hover,
130
+ .np-item-prompt.discount a:hover,
131
+ .np-item-prompt.savings a:hover {
132
+ color: var(--color-sentiment-positive-primary-hover);
133
+ }
134
+ .np-item-prompt.positive a:active,
135
+ .np-item-prompt.discount a:active,
136
+ .np-item-prompt.savings a:active {
137
+ color: var(--color-sentiment-positive-primary-active);
138
+ }
139
+ .np-prompt-interactive.np-item-prompt.positive:hover,
140
+ .np-prompt-interactive.np-item-prompt.discount:hover,
141
+ .np-prompt-interactive.np-item-prompt.savings:hover {
142
+ background-color: color-mix(in srgb, var(--color-sentiment-positive-secondary) 95%, var(--color-sentiment-positive-primary));
143
+ }
144
+ .np-prompt-interactive.np-item-prompt.positive:active,
145
+ .np-prompt-interactive.np-item-prompt.discount:active,
146
+ .np-prompt-interactive.np-item-prompt.savings:active {
147
+ background-color: color-mix(in srgb, var(--color-sentiment-positive-secondary) 90%, var(--color-sentiment-positive-primary));
148
+ }
149
+ .np-item-prompt.neutral {
150
+ background-color: rgba(134,167,189,0.10196);
151
+ background-color: var(--color-background-neutral);
152
+ color: #37517e;
153
+ color: var(--color-content-primary);
154
+ }
155
+ .np-item-prompt.neutral a {
156
+ color: #37517e;
157
+ color: var(--color-content-primary);
158
+ }
159
+ .np-prompt-interactive.np-item-prompt.neutral:hover {
160
+ background-color: var(--color-background-neutral-hover);
161
+ }
162
+ .np-prompt-interactive.np-item-prompt.neutral:active {
163
+ background-color: var(--color-background-neutral-active);
164
+ }
165
+ .np-item-prompt.warning {
166
+ background-color: var(--color-sentiment-warning-secondary);
167
+ color: var(--color-sentiment-warning-content);
168
+ }
169
+ .np-item-prompt.warning a {
170
+ color: var(--color-sentiment-warning-content);
171
+ }
172
+ .np-item-prompt.warning a:hover {
173
+ color: var(--color-sentiment-warning-content-hover);
174
+ }
175
+ .np-item-prompt.warning a:active {
176
+ color: var(--color-sentiment-warning-content-active);
177
+ }
178
+ .np-prompt-interactive.np-item-prompt.warning:hover {
179
+ background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 90%, var(--color-sentiment-warning-primary));
180
+ }
181
+ .np-prompt-interactive.np-item-prompt.warning:active {
182
+ background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 80%, var(--color-sentiment-warning-primary));
183
+ }
@@ -0,0 +1,177 @@
1
+ .np-item {
2
+ padding: var(--size-16);
3
+ border-radius: var(--radius-large);
4
+ background-color: var(--color-background-screen);
5
+ gap: var(--size-16);
6
+ cursor: pointer;
7
+
8
+ &:hover {
9
+ background-color: var(--color-background-screen-hover);
10
+ }
11
+
12
+ &:active {
13
+ background-color: var(--color-background-screen-active);
14
+ }
15
+
16
+ &-media {
17
+
18
+ &-image {
19
+ width: var(--item-media-image-size);
20
+ height: var(--item-media-image-size);
21
+ }
22
+ }
23
+
24
+ &-title {
25
+ color: var(--color-content-primary);
26
+ }
27
+
28
+ &-additional-info {
29
+ color: var(--color-content-tertiary);
30
+ }
31
+
32
+ &-value {
33
+ flex: 0 0 auto;
34
+ }
35
+
36
+ &-control {
37
+ flex: 0 0 auto;
38
+ }
39
+
40
+ &-spotlight {
41
+ &-active {
42
+ background-color: var(--color-background-neutral);
43
+
44
+ &:hover {
45
+ background-color: var(--color-background-neutral-hover);
46
+ }
47
+ &:active {
48
+ background-color: var(--color-background-neutral-active);
49
+ }
50
+ }
51
+
52
+ &-inactive {
53
+ background-color: color-mix(in srgb, var(--color-background-neutral) 25%, transparent);
54
+ border: 1px dashed var(--color-border-neutral);
55
+
56
+ &:hover {
57
+ background-color: color-mix(in srgb, var(--color-background-neutral-hover) 25%, transparent);
58
+ }
59
+ &:active {
60
+ background-color: color-mix(in srgb, var(--color-background-neutral-active) 25%, transparent);
61
+ }
62
+ }
63
+ }
64
+
65
+ &-prompt {
66
+ display: inline-flex;
67
+ padding-top: calc(var(--padding-x-small) / 2);
68
+ padding-bottom: calc(var(--padding-x-small) / 2);
69
+ padding-left: calc(var(--padding-x-small) - 1px);
70
+ padding-right: var(--padding-x-small);
71
+ border-radius: var(--radius-small);
72
+ word-break: break-word;
73
+ overflow-wrap: break-word;
74
+
75
+ .np-prompt-icon {
76
+ padding-right: calc(var(--size-12) / 2);
77
+ padding-top: calc(var(--size-4) - 1px);
78
+ padding-bottom: calc(var(--size-4) - 1px);
79
+
80
+ .tw-icon-tags,
81
+ .tw-icon-confetti {
82
+ color: var(--color-sentiment-positive-primary);
83
+ }
84
+ }
85
+
86
+ a {
87
+ text-underline-offset: calc(var(--size-4) / 2);
88
+ }
89
+
90
+ &.np-prompt-interactive {
91
+ text-decoration: none;
92
+ cursor: pointer;
93
+ border: none;
94
+ }
95
+
96
+ &.negative {
97
+ background-color: var(--color-sentiment-negative-secondary);
98
+ color: var(--color-sentiment-negative-primary);
99
+ a {
100
+ color: var(--color-sentiment-negative-primary);
101
+ &:hover {
102
+ color: var(--color-sentiment-negative-primary-hover);
103
+ }
104
+ &:active {
105
+ color: var(--color-sentiment-negative-primary-active);
106
+ }
107
+ }
108
+ .np-prompt-interactive& {
109
+ &:hover {
110
+ background-color: color-mix(in srgb, var(--color-sentiment-negative-secondary) 95%, var(--color-sentiment-negative-primary));
111
+ }
112
+ &:active {
113
+ background-color: color-mix(in srgb, var(--color-sentiment-negative-secondary) 90%, var(--color-sentiment-negative-primary));
114
+ }
115
+ }
116
+ }
117
+ &.positive,
118
+ &.discount,
119
+ &.savings {
120
+ background-color: var(--color-sentiment-positive-secondary);
121
+ color: var(--color-sentiment-positive-primary);
122
+ a {
123
+ color: var(--color-sentiment-positive-primary);
124
+ &:hover {
125
+ color: var(--color-sentiment-positive-primary-hover);
126
+ }
127
+ &:active {
128
+ color: var(--color-sentiment-positive-primary-active);
129
+ }
130
+ }
131
+ .np-prompt-interactive& {
132
+ &:hover {
133
+ background-color: color-mix(in srgb, var(--color-sentiment-positive-secondary) 95%, var(--color-sentiment-positive-primary));
134
+ }
135
+ &:active {
136
+ background-color: color-mix(in srgb, var(--color-sentiment-positive-secondary) 90%, var(--color-sentiment-positive-primary));
137
+ }
138
+ }
139
+ }
140
+ &.neutral {
141
+ background-color: var(--color-background-neutral);
142
+ color: var(--color-content-primary);
143
+ a {
144
+ color: var(--color-content-primary);
145
+ }
146
+ .np-prompt-interactive& {
147
+ &:hover {
148
+ background-color: var(--color-background-neutral-hover);
149
+ }
150
+ &:active {
151
+ background-color: var(--color-background-neutral-active);
152
+ }
153
+ }
154
+ }
155
+ &.warning {
156
+ background-color: var(--color-sentiment-warning-secondary);
157
+ color: var(--color-sentiment-warning-content);
158
+ a {
159
+ color: var(--color-sentiment-warning-content);
160
+ &:hover {
161
+ color: var(--color-sentiment-warning-content-hover);
162
+ }
163
+ &:active {
164
+ color: var(--color-sentiment-warning-content-active);
165
+ }
166
+ }
167
+ .np-prompt-interactive& {
168
+ &:hover {
169
+ background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 90%, var(--color-sentiment-warning-primary));
170
+ }
171
+ &:active {
172
+ background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 80%, var(--color-sentiment-warning-primary));
173
+ }
174
+ }
175
+ }
176
+ }
177
+ }
@@ -0,0 +1,188 @@
1
+ import Item, { Props as ItemProps } from './Item';
2
+ import { Meta, StoryObj } from '@storybook/react';
3
+ import React, { useState } from 'react';
4
+ import { Plus } from '@transferwise/icons';
5
+
6
+ import { lorem10, lorem20, lorem40, lorem5 } from '../test-utils';
7
+ import { Flag } from '@wise/art';
8
+
9
+ export default {
10
+ component: Item,
11
+ title: 'Content/Item',
12
+ } satisfies Meta<ItemProps>;
13
+
14
+ type Story = StoryObj<ItemProps>;
15
+
16
+ // TODO: delete this story later when we have more peace of the List Item puzzle
17
+ export const TempPlayground: Story = {
18
+ render: () => {
19
+ const [checked, setChecked] = useState(false);
20
+
21
+ return (
22
+ <div>
23
+ <Item
24
+ media={
25
+ <Item.AvatarView badge={{ type: 'action' }}>
26
+ <Flag code="BBD" />
27
+ </Item.AvatarView>
28
+ }
29
+ title="Test title"
30
+ subtitle="Test subtitle"
31
+ additionalInfo={<Item.AdditionalInfo>{lorem10}</Item.AdditionalInfo>}
32
+ />
33
+ <Item
34
+ media={
35
+ <Item.AvatarLayout
36
+ avatars={[{ asset: <Flag code="BBD" /> }, { asset: <Flag code="MXN" /> }]}
37
+ />
38
+ }
39
+ title="Test title"
40
+ subtitle={lorem10}
41
+ additionalInfo={<Item.AdditionalInfo>{lorem20}</Item.AdditionalInfo>}
42
+ />
43
+ <Item
44
+ media={
45
+ <Item.AvatarLayout
46
+ size={72}
47
+ orientation="diagonal"
48
+ avatars={[{ asset: <Flag code="BBD" /> }, { asset: <Flag code="MXN" /> }]}
49
+ />
50
+ }
51
+ title="Test title"
52
+ subtitle={lorem10}
53
+ valueTitle="100 GBP"
54
+ valueSubtitle="100 USD"
55
+ additionalInfo={<Item.AdditionalInfo>{lorem20}</Item.AdditionalInfo>}
56
+ />
57
+ <Item
58
+ media={<Item.AvatarView profileType="BUSINESS" notification />}
59
+ title="Test title"
60
+ subtitle="Test subtitle"
61
+ additionalInfo={
62
+ <Item.AdditionalInfo
63
+ action={{ label: 'Learn more', href: 'https://wise.com', target: '_blank' }}
64
+ >
65
+ {lorem10}
66
+ </Item.AdditionalInfo>
67
+ }
68
+ prompt={<Item.Prompt type="negative">You have done something wrong</Item.Prompt>}
69
+ />
70
+ <Item
71
+ media={<Item.AvatarView imgSrc="../avatar-square-dude.webp" selected />}
72
+ title="Test title"
73
+ additionalInfo={<Item.AdditionalInfo>{lorem10}</Item.AdditionalInfo>}
74
+ prompt={
75
+ <Item.Prompt
76
+ type="discount"
77
+ action={{
78
+ href: 'https://wise.com',
79
+ target: '_blank',
80
+ 'aria-label': 'clickable prompt',
81
+ }}
82
+ >
83
+ The whole prompt is secretly clickable
84
+ </Item.Prompt>
85
+ }
86
+ />
87
+
88
+ <Item
89
+ media={<Item.Image src="../apple-pay-logo.svg" />}
90
+ title="Accepting Apple Pay"
91
+ subtitle={lorem10}
92
+ />
93
+
94
+ <Item
95
+ media={<Item.Image src="../wise-card.svg" />}
96
+ title="Wise Business Card"
97
+ subtitle={lorem5}
98
+ />
99
+
100
+ <Item
101
+ title="Test title"
102
+ disabled
103
+ subtitle={lorem10}
104
+ additionalInfo={<Item.AdditionalInfo>{lorem20}</Item.AdditionalInfo>}
105
+ control={<Item.Button priority="secondary-neutral">as Button</Item.Button>}
106
+ />
107
+ <Item
108
+ title="Test title"
109
+ disabled
110
+ subtitle={lorem10}
111
+ additionalInfo={<Item.AdditionalInfo>{lorem20}</Item.AdditionalInfo>}
112
+ control={
113
+ <Item.IconButton>
114
+ <Plus />
115
+ </Item.IconButton>
116
+ }
117
+ />
118
+
119
+ <Item
120
+ title="Test title"
121
+ subtitle={lorem10}
122
+ additionalInfo={<Item.AdditionalInfo>{lorem20}</Item.AdditionalInfo>}
123
+ control={
124
+ <Item.Button
125
+ priority="secondary-neutral"
126
+ as="a"
127
+ target="dfdf"
128
+ aria-label="adsfasfd"
129
+ href="wise.com"
130
+ >
131
+ as Link
132
+ </Item.Button>
133
+ }
134
+ />
135
+
136
+ <Item
137
+ title="Test title"
138
+ subtitle={lorem10}
139
+ additionalInfo={<Item.AdditionalInfo>{lorem20}</Item.AdditionalInfo>}
140
+ control={<Item.Checkbox indeterminate />}
141
+ />
142
+
143
+ <Item
144
+ title="Test title"
145
+ subtitle={lorem10}
146
+ additionalInfo={<Item.AdditionalInfo>{lorem20}</Item.AdditionalInfo>}
147
+ control={
148
+ <Item.Switch
149
+ checked={checked}
150
+ onClick={() => {
151
+ setChecked(!checked);
152
+ }}
153
+ />
154
+ }
155
+ />
156
+ </div>
157
+ );
158
+ },
159
+ };
160
+
161
+ export const ItemRadio: Story = {
162
+ render: () => (
163
+ <div>
164
+ {/* Basic */}
165
+ {/* with additional info */}
166
+ {/* with prompt */}
167
+ {/* Disabled */}
168
+ {/* Spotlight */}
169
+ {/* Active */}
170
+ </div>
171
+ ),
172
+ };
173
+
174
+ export const ItemButton: Story = {
175
+ render: () => (
176
+ <div>
177
+ {/* Basic */}
178
+ {/* with additional info */}
179
+ {/* with prompt */}
180
+ {/* partially interactive */}
181
+ {/* Disabled */}
182
+ {/* Spotlight */}
183
+ {/* Active */}
184
+ </div>
185
+ ),
186
+ };
187
+
188
+ // add intaces with dark mode