@transferwise/components 0.0.0-experimental-e3978a5 → 0.0.0-experimental-e46526a

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,4 +1,5 @@
1
1
  @import "./ListItem.grid.less";
2
+ @import "./Prompt/ListItemPrompt.less";
2
3
  @import (reference) "../../node_modules/@transferwise/neptune-css/src/less/ring.less";
3
4
 
4
5
  .wds-list-item {
@@ -283,139 +284,4 @@
283
284
  var(--wds-list-item-spotlight-strokeDashSize);
284
285
  }
285
286
  }
286
-
287
- &-prompt {
288
- grid-area: prompt;
289
-
290
- display: inline-flex;
291
- justify-self: start;
292
- text-align: left;
293
- padding-top: calc(var(--padding-x-small) / 2);
294
- padding-bottom: calc(var(--padding-x-small) / 2);
295
- padding-left: calc(var(--padding-x-small) - 1px);
296
- padding-right: var(--padding-x-small);
297
- border-radius: var(--radius-small);
298
- word-break: break-word;
299
- overflow-wrap: break-word;
300
-
301
- &:has(a),
302
- &:has(button) {
303
- position: relative;
304
- z-index: 1;
305
- }
306
-
307
- a, button {
308
- text-underline-offset: calc(var(--size-4) / 2);
309
- &:first-of-type {
310
- &:before {
311
- content: '';
312
- position: absolute;
313
- inset: 0;
314
- }
315
- }
316
- }
317
-
318
- &.np-prompt-icon {
319
- padding-left: calc(var(--padding-x-small) - 1px);
320
- padding-right: var(--padding-x-small);
321
- display: inline-flex;
322
- align-items: center;
323
- gap: var(--size-4);
324
- }
325
-
326
- .np-prompt-icon {
327
- padding-right: calc(var(--size-12) / 2);
328
- padding-top: calc(var(--size-4) - 1px);
329
- padding-bottom: calc(var(--size-4) - 1px);
330
-
331
- .tw-icon-tags,
332
- .tw-icon-confetti {
333
- color: var(--color-sentiment-positive-primary);
334
- }
335
- }
336
-
337
- &.negative {
338
- background-color: var(--color-sentiment-negative-secondary);
339
- color: var(--color-sentiment-negative-primary);
340
- a, button {
341
- color: var(--color-sentiment-negative-primary);
342
- &:hover {
343
- color: var(--color-sentiment-negative-primary-hover);
344
- }
345
- &:active {
346
- color: var(--color-sentiment-negative-primary-active);
347
- }
348
- }
349
- .wds-list-item-prompt&:has(a, button) {
350
- &:hover {
351
- background-color: var(--color-sentiment-negative-secondary-hover);
352
- }
353
- &:active {
354
- background-color: var(--color-sentiment-negative-secondary-active);
355
- }
356
- }
357
- }
358
- &.positive,
359
- &.discount,
360
- &.savings {
361
- background-color: var(--color-sentiment-positive-secondary);
362
- color: var(--color-sentiment-positive-primary);
363
- a, button {
364
- color: var(--color-sentiment-positive-primary);
365
- &:hover {
366
- color: var(--color-sentiment-positive-primary-hover);
367
- }
368
- &:active {
369
- color: var(--color-sentiment-positive-primary-active);
370
- }
371
- }
372
- .wds-list-item-prompt&:has(a, button) {
373
- &:hover {
374
- background-color: var(--color-sentiment-positive-secondary-hover);
375
- }
376
- &:active {
377
- background-color: var(--color-sentiment-positive-secondary-active);
378
- }
379
- }
380
- }
381
- &.neutral {
382
- background-color: var(--color-background-neutral);
383
- color: var(--color-content-primary);
384
- a, button {
385
- color: var(--color-content-primary);
386
- }
387
- .wds-list-item-prompt&:has(a, button) {
388
- &:hover {
389
- background-color: var(--color-background-neutral-hover);
390
- }
391
- &:active {
392
- background-color: var(--color-background-neutral-active);
393
- }
394
- }
395
- }
396
- &.warning {
397
- background-color: var(--color-sentiment-warning-secondary);
398
- color: var(--color-sentiment-warning-content);
399
- a, button {
400
- color: var(--color-sentiment-warning-content);
401
- &:hover {
402
- color: var(--color-sentiment-warning-content-hover);
403
- }
404
- &:active {
405
- color: var(--color-sentiment-warning-content-active);
406
- }
407
- }
408
- .wds-list-item-prompt&:has(a, button) {
409
- &:hover {
410
- // someday we'll have hover and active states for warning
411
- // background-color: var(--color-sentiment-warning-secondary-hover);
412
- background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 92%, var(--color-sentiment-warning-primary));
413
- }
414
- &:active {
415
- // background-color: var(--color-sentiment-warning-secondary-active);
416
- background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 84%, var(--color-sentiment-warning-primary));
417
- }
418
- }
419
- }
420
- }
421
287
  }
@@ -37,16 +37,6 @@ describe('ListItem', () => {
37
37
  expect(screen.getByRole('listitem')).toHaveAttribute('id', 'custom-id');
38
38
  });
39
39
 
40
- it('sets custom role on the container', () => {
41
- render(<ListItem title={title} role="button" />);
42
- expect(screen.getByRole('button')).toBeInTheDocument();
43
- });
44
-
45
- it('sets aria-labelledby when provided', () => {
46
- render(<ListItem title={title} aria-labelledby="Accessible label" />);
47
- expect(screen.getByRole('listitem')).toHaveAttribute('aria-labelledby', 'Accessible label');
48
- });
49
-
50
40
  it('sets aria-describedby with correct IDs for fully interactive list item with prompt and additionalInfo', () => {
51
41
  render(
52
42
  <ListItem
@@ -92,8 +92,6 @@ export type ListItemProps = {
92
92
  */
93
93
  valueColumnWidth?: number;
94
94
  id?: string;
95
- role?: string;
96
- 'aria-labelledby'?: string;
97
95
  };
98
96
 
99
97
  /**
@@ -115,9 +113,7 @@ export const ListItem = ({
115
113
  disabled,
116
114
  className,
117
115
  valueColumnWidth,
118
- role,
119
116
  id,
120
- 'aria-labelledby': ariaLabelledby,
121
117
  }: ListItemProps) => {
122
118
  const idPrefix = useId();
123
119
  const [controlProps, setControlProps] = useState<ListItemControlProps>({});
@@ -232,9 +228,7 @@ export const ListItem = ({
232
228
  className,
233
229
  )}
234
230
  id={id}
235
- role={role}
236
231
  aria-disabled={disabled}
237
- aria-labelledby={ariaLabelledby}
238
232
  >
239
233
  {spotlight === 'inactive' && (
240
234
  <svg aria-hidden="true" className="wds-list-item-spotlight__border">
@@ -0,0 +1,157 @@
1
+ .wds-list-item-prompt {
2
+ grid-area: prompt;
3
+ display: inline-flex;
4
+ justify-self: start;
5
+ text-align: left;
6
+ padding-top: calc(8px / 2);
7
+ padding-top: calc(var(--padding-x-small) / 2);
8
+ padding-bottom: calc(8px / 2);
9
+ padding-bottom: calc(var(--padding-x-small) / 2);
10
+ padding-left: calc(8px - 1px);
11
+ padding-left: calc(var(--padding-x-small) - 1px);
12
+ padding-right: 8px;
13
+ padding-right: var(--padding-x-small);
14
+ border-radius: 10px;
15
+ border-radius: var(--radius-small);
16
+ word-break: break-word;
17
+ word-wrap: break-word;
18
+ }
19
+ .wds-list-item-prompt:has(a),
20
+ .wds-list-item-prompt:has(button) {
21
+ position: relative;
22
+ z-index: 1;
23
+ }
24
+ .wds-list-item-prompt a,
25
+ .wds-list-item-prompt button {
26
+ text-underline-offset: calc(4px / 2);
27
+ text-underline-offset: calc(var(--size-4) / 2);
28
+ }
29
+ .wds-list-item-prompt a:first-of-type:before,
30
+ .wds-list-item-prompt button:first-of-type:before {
31
+ content: '';
32
+ position: absolute;
33
+ inset: 0;
34
+ }
35
+ .wds-list-item-prompt.np-prompt-icon {
36
+ padding-left: calc(8px - 1px);
37
+ padding-left: calc(var(--padding-x-small) - 1px);
38
+ padding-right: 8px;
39
+ padding-right: var(--padding-x-small);
40
+ display: inline-flex;
41
+ align-items: center;
42
+ gap: 4px;
43
+ gap: var(--size-4);
44
+ }
45
+ .wds-list-item-prompt .np-prompt-icon {
46
+ padding-right: calc(12px / 2);
47
+ padding-right: calc(var(--size-12) / 2);
48
+ padding-top: calc(4px - 1px);
49
+ padding-top: calc(var(--size-4) - 1px);
50
+ padding-bottom: calc(4px - 1px);
51
+ padding-bottom: calc(var(--size-4) - 1px);
52
+ }
53
+ .wds-list-item-prompt .np-prompt-icon .tw-icon-tags,
54
+ .wds-list-item-prompt .np-prompt-icon .tw-icon-confetti {
55
+ color: var(--color-sentiment-positive-primary);
56
+ }
57
+ .wds-list-item-prompt.negative {
58
+ background-color: var(--color-sentiment-negative-secondary);
59
+ color: var(--color-sentiment-negative-primary);
60
+ }
61
+ .wds-list-item-prompt.negative a,
62
+ .wds-list-item-prompt.negative button {
63
+ color: var(--color-sentiment-negative-primary);
64
+ }
65
+ .wds-list-item-prompt.negative a:hover,
66
+ .wds-list-item-prompt.negative button:hover {
67
+ color: var(--color-sentiment-negative-primary-hover);
68
+ }
69
+ .wds-list-item-prompt.negative a:active,
70
+ .wds-list-item-prompt.negative button:active {
71
+ color: var(--color-sentiment-negative-primary-active);
72
+ }
73
+ .wds-list-item-prompt.wds-list-item-prompt.negative:has(a, button):hover {
74
+ background-color: var(--color-sentiment-negative-secondary-hover);
75
+ }
76
+ .wds-list-item-prompt.wds-list-item-prompt.negative:has(a, button):active {
77
+ background-color: var(--color-sentiment-negative-secondary-active);
78
+ }
79
+ .wds-list-item-prompt.positive,
80
+ .wds-list-item-prompt.discount,
81
+ .wds-list-item-prompt.savings {
82
+ background-color: var(--color-sentiment-positive-secondary);
83
+ color: var(--color-sentiment-positive-primary);
84
+ }
85
+ .wds-list-item-prompt.positive a,
86
+ .wds-list-item-prompt.discount a,
87
+ .wds-list-item-prompt.savings a,
88
+ .wds-list-item-prompt.positive button,
89
+ .wds-list-item-prompt.discount button,
90
+ .wds-list-item-prompt.savings button {
91
+ color: var(--color-sentiment-positive-primary);
92
+ }
93
+ .wds-list-item-prompt.positive a:hover,
94
+ .wds-list-item-prompt.discount a:hover,
95
+ .wds-list-item-prompt.savings a:hover,
96
+ .wds-list-item-prompt.positive button:hover,
97
+ .wds-list-item-prompt.discount button:hover,
98
+ .wds-list-item-prompt.savings button:hover {
99
+ color: var(--color-sentiment-positive-primary-hover);
100
+ }
101
+ .wds-list-item-prompt.positive a:active,
102
+ .wds-list-item-prompt.discount a:active,
103
+ .wds-list-item-prompt.savings a:active,
104
+ .wds-list-item-prompt.positive button:active,
105
+ .wds-list-item-prompt.discount button:active,
106
+ .wds-list-item-prompt.savings button:active {
107
+ color: var(--color-sentiment-positive-primary-active);
108
+ }
109
+ .wds-list-item-prompt.wds-list-item-prompt.positive:has(a, button):hover,
110
+ .wds-list-item-prompt.wds-list-item-prompt.discount:has(a, button):hover,
111
+ .wds-list-item-prompt.wds-list-item-prompt.savings:has(a, button):hover {
112
+ background-color: var(--color-sentiment-positive-secondary-hover);
113
+ }
114
+ .wds-list-item-prompt.wds-list-item-prompt.positive:has(a, button):active,
115
+ .wds-list-item-prompt.wds-list-item-prompt.discount:has(a, button):active,
116
+ .wds-list-item-prompt.wds-list-item-prompt.savings:has(a, button):active {
117
+ background-color: var(--color-sentiment-positive-secondary-active);
118
+ }
119
+ .wds-list-item-prompt.neutral {
120
+ background-color: rgba(134,167,189,0.10196);
121
+ background-color: var(--color-background-neutral);
122
+ color: #37517e;
123
+ color: var(--color-content-primary);
124
+ }
125
+ .wds-list-item-prompt.neutral a,
126
+ .wds-list-item-prompt.neutral button {
127
+ color: #37517e;
128
+ color: var(--color-content-primary);
129
+ }
130
+ .wds-list-item-prompt.wds-list-item-prompt.neutral:has(a, button):hover {
131
+ background-color: var(--color-background-neutral-hover);
132
+ }
133
+ .wds-list-item-prompt.wds-list-item-prompt.neutral:has(a, button):active {
134
+ background-color: var(--color-background-neutral-active);
135
+ }
136
+ .wds-list-item-prompt.warning {
137
+ background-color: var(--color-sentiment-warning-secondary);
138
+ color: var(--color-sentiment-warning-content);
139
+ }
140
+ .wds-list-item-prompt.warning a,
141
+ .wds-list-item-prompt.warning button {
142
+ color: var(--color-sentiment-warning-content);
143
+ }
144
+ .wds-list-item-prompt.warning a:hover,
145
+ .wds-list-item-prompt.warning button:hover {
146
+ color: var(--color-sentiment-warning-content-hover);
147
+ }
148
+ .wds-list-item-prompt.warning a:active,
149
+ .wds-list-item-prompt.warning button:active {
150
+ color: var(--color-sentiment-warning-content-active);
151
+ }
152
+ .wds-list-item-prompt.wds-list-item-prompt.warning:has(a, button):hover {
153
+ background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 92%, var(--color-sentiment-warning-primary));
154
+ }
155
+ .wds-list-item-prompt.wds-list-item-prompt.warning:has(a, button):active {
156
+ background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 84%, var(--color-sentiment-warning-primary));
157
+ }
@@ -0,0 +1,134 @@
1
+ .wds-list-item-prompt {
2
+ grid-area: prompt;
3
+
4
+ display: inline-flex;
5
+ justify-self: start;
6
+ text-align: left;
7
+ padding-top: calc(var(--padding-x-small) / 2);
8
+ padding-bottom: calc(var(--padding-x-small) / 2);
9
+ padding-left: calc(var(--padding-x-small) - 1px);
10
+ padding-right: var(--padding-x-small);
11
+ border-radius: var(--radius-small);
12
+ word-break: break-word;
13
+ overflow-wrap: break-word;
14
+
15
+ &:has(a),
16
+ &:has(button) {
17
+ position: relative;
18
+ z-index: 1;
19
+ }
20
+
21
+ a, button {
22
+ text-underline-offset: calc(var(--size-4) / 2);
23
+ &:first-of-type {
24
+ &:before {
25
+ content: '';
26
+ position: absolute;
27
+ inset: 0;
28
+ }
29
+ }
30
+ }
31
+
32
+ &.np-prompt-icon {
33
+ padding-left: calc(var(--padding-x-small) - 1px);
34
+ padding-right: var(--padding-x-small);
35
+ display: inline-flex;
36
+ align-items: center;
37
+ gap: var(--size-4);
38
+ }
39
+
40
+ .np-prompt-icon {
41
+ padding-right: calc(var(--size-12) / 2);
42
+ padding-top: calc(var(--size-4) - 1px);
43
+ padding-bottom: calc(var(--size-4) - 1px);
44
+
45
+ .tw-icon-tags,
46
+ .tw-icon-confetti {
47
+ color: var(--color-sentiment-positive-primary);
48
+ }
49
+ }
50
+
51
+ &.negative {
52
+ background-color: var(--color-sentiment-negative-secondary);
53
+ color: var(--color-sentiment-negative-primary);
54
+ a, button {
55
+ color: var(--color-sentiment-negative-primary);
56
+ &:hover {
57
+ color: var(--color-sentiment-negative-primary-hover);
58
+ }
59
+ &:active {
60
+ color: var(--color-sentiment-negative-primary-active);
61
+ }
62
+ }
63
+ .wds-list-item-prompt&:has(a, button) {
64
+ &:hover {
65
+ background-color: var(--color-sentiment-negative-secondary-hover);
66
+ }
67
+ &:active {
68
+ background-color: var(--color-sentiment-negative-secondary-active);
69
+ }
70
+ }
71
+ }
72
+ &.positive,
73
+ &.discount,
74
+ &.savings {
75
+ background-color: var(--color-sentiment-positive-secondary);
76
+ color: var(--color-sentiment-positive-primary);
77
+ a, button {
78
+ color: var(--color-sentiment-positive-primary);
79
+ &:hover {
80
+ color: var(--color-sentiment-positive-primary-hover);
81
+ }
82
+ &:active {
83
+ color: var(--color-sentiment-positive-primary-active);
84
+ }
85
+ }
86
+ .wds-list-item-prompt&:has(a, button) {
87
+ &:hover {
88
+ background-color: var(--color-sentiment-positive-secondary-hover);
89
+ }
90
+ &:active {
91
+ background-color: var(--color-sentiment-positive-secondary-active);
92
+ }
93
+ }
94
+ }
95
+ &.neutral {
96
+ background-color: var(--color-background-neutral);
97
+ color: var(--color-content-primary);
98
+ a, button {
99
+ color: var(--color-content-primary);
100
+ }
101
+ .wds-list-item-prompt&:has(a, button) {
102
+ &:hover {
103
+ background-color: var(--color-background-neutral-hover);
104
+ }
105
+ &:active {
106
+ background-color: var(--color-background-neutral-active);
107
+ }
108
+ }
109
+ }
110
+ &.warning {
111
+ background-color: var(--color-sentiment-warning-secondary);
112
+ color: var(--color-sentiment-warning-content);
113
+ a, button {
114
+ color: var(--color-sentiment-warning-content);
115
+ &:hover {
116
+ color: var(--color-sentiment-warning-content-hover);
117
+ }
118
+ &:active {
119
+ color: var(--color-sentiment-warning-content-active);
120
+ }
121
+ }
122
+ .wds-list-item-prompt&:has(a, button) {
123
+ &:hover {
124
+ // someday we'll have hover and active states for warning
125
+ // background-color: var(--color-sentiment-warning-secondary-hover);
126
+ background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 92%, var(--color-sentiment-warning-primary));
127
+ }
128
+ &:active {
129
+ // background-color: var(--color-sentiment-warning-secondary-active);
130
+ background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 84%, var(--color-sentiment-warning-primary));
131
+ }
132
+ }
133
+ }
134
+ }
@@ -21,8 +21,6 @@ const hideControls = disableControls([
21
21
  'media',
22
22
  'className',
23
23
  'id',
24
- 'role',
25
- 'aria-labelledby',
26
24
  'as',
27
25
  ]);
28
26