@transferwise/components 46.107.0 → 46.108.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/build/header/Header.js +1 -0
- package/build/header/Header.js.map +1 -1
- package/build/header/Header.mjs +1 -0
- package/build/header/Header.mjs.map +1 -1
- package/build/link/Link.js +6 -2
- package/build/link/Link.js.map +1 -1
- package/build/link/Link.mjs +6 -2
- package/build/link/Link.mjs.map +1 -1
- package/build/listItem/ListItem.js +20 -8
- package/build/listItem/ListItem.js.map +1 -1
- package/build/listItem/ListItem.mjs +20 -8
- package/build/listItem/ListItem.mjs.map +1 -1
- package/build/listItem/ListItemContext.js.map +1 -1
- package/build/listItem/ListItemContext.mjs.map +1 -1
- package/build/listItem/Navigation/ListItemNavigation.js +1 -3
- package/build/listItem/Navigation/ListItemNavigation.js.map +1 -1
- package/build/listItem/Navigation/ListItemNavigation.mjs +2 -4
- package/build/listItem/Navigation/ListItemNavigation.mjs.map +1 -1
- package/build/listItem/Prompt/InlinePrompt/InlinePrompt.js +74 -0
- package/build/listItem/Prompt/InlinePrompt/InlinePrompt.js.map +1 -0
- package/build/listItem/Prompt/InlinePrompt/InlinePrompt.mjs +72 -0
- package/build/listItem/Prompt/InlinePrompt/InlinePrompt.mjs.map +1 -0
- package/build/listItem/Prompt/ListItemPrompt.js +10 -15
- package/build/listItem/Prompt/ListItemPrompt.js.map +1 -1
- package/build/listItem/Prompt/ListItemPrompt.mjs +11 -16
- package/build/listItem/Prompt/ListItemPrompt.mjs.map +1 -1
- package/build/main.css +94 -74
- package/build/styles/link/Link.css +7 -0
- package/build/styles/listItem/ListItem.css +87 -74
- package/build/styles/listItem/Prompt/InlinePrompt/InlinePrompt.css +153 -0
- package/build/styles/listItem/Prompt/ListItemPrompt.css +72 -72
- package/build/styles/main.css +94 -74
- package/build/types/header/Header.d.ts +1 -0
- package/build/types/header/Header.d.ts.map +1 -1
- package/build/types/link/Link.d.ts +1 -1
- package/build/types/link/Link.d.ts.map +1 -1
- package/build/types/listItem/ListItem.d.ts +10 -1
- package/build/types/listItem/ListItem.d.ts.map +1 -1
- package/build/types/listItem/ListItemContext.d.ts +2 -1
- package/build/types/listItem/ListItemContext.d.ts.map +1 -1
- package/build/types/listItem/Navigation/ListItemNavigation.d.ts.map +1 -1
- package/build/types/listItem/Prompt/InlinePrompt/InlinePrompt.d.ts +15 -0
- package/build/types/listItem/Prompt/InlinePrompt/InlinePrompt.d.ts.map +1 -0
- package/build/types/listItem/Prompt/InlinePrompt/index.d.ts +3 -0
- package/build/types/listItem/Prompt/InlinePrompt/index.d.ts.map +1 -0
- package/build/types/listItem/Prompt/ListItemPrompt.d.ts +4 -6
- package/build/types/listItem/Prompt/ListItemPrompt.d.ts.map +1 -1
- package/build/types/listItem/_stories/helpers.d.ts.map +1 -1
- package/build/types/listItem/_stories/subcomponents.d.ts +1 -0
- package/build/types/listItem/_stories/subcomponents.d.ts.map +1 -1
- package/build/types/listItem/useListItemControl.d.ts +1 -1
- package/package.json +3 -3
- package/src/header/Header.story.tsx +14 -0
- package/src/header/Header.tsx +2 -0
- package/src/link/Link.css +7 -0
- package/src/link/Link.less +8 -0
- package/src/link/Link.spec.tsx +28 -0
- package/src/link/Link.story.tsx +72 -16
- package/src/link/Link.tsx +5 -1
- package/src/listItem/ListItem.css +87 -74
- package/src/listItem/ListItem.less +19 -4
- package/src/listItem/ListItem.spec.tsx +33 -0
- package/src/listItem/ListItem.tsx +38 -12
- package/src/listItem/ListItemContext.tsx +2 -1
- package/src/listItem/Navigation/ListItemNavigation.spec.tsx +1 -10
- package/src/listItem/Navigation/ListItemNavigation.story.tsx +0 -22
- package/src/listItem/Navigation/ListItemNavigation.tsx +2 -3
- package/src/listItem/Prompt/InlinePrompt/InlinePrompt.css +153 -0
- package/src/listItem/Prompt/InlinePrompt/InlinePrompt.less +162 -0
- package/src/listItem/Prompt/InlinePrompt/InlinePrompt.spec.tsx +66 -0
- package/src/listItem/Prompt/InlinePrompt/InlinePrompt.tsx +56 -0
- package/src/listItem/Prompt/InlinePrompt/index.ts +2 -0
- package/src/listItem/Prompt/ListItemPrompt.css +72 -72
- package/src/listItem/Prompt/ListItemPrompt.less +2 -130
- package/src/listItem/Prompt/ListItemPrompt.spec.tsx +36 -0
- package/src/listItem/Prompt/ListItemPrompt.story.tsx +4 -2
- package/src/listItem/Prompt/ListItemPrompt.tsx +14 -14
- package/src/listItem/_stories/ListItem.disabled.story.tsx +433 -0
- package/src/listItem/_stories/ListItem.story.tsx +1 -177
- package/src/listItem/_stories/helpers.tsx +1 -0
- package/src/listItem/_stories/subcomponents.tsx +5 -0
- package/src/main.css +94 -74
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
.wds-inline-prompt {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
text-align: left;
|
|
4
|
+
padding-top: calc(8px / 2);
|
|
5
|
+
padding-top: calc(var(--padding-x-small) / 2);
|
|
6
|
+
padding-bottom: calc(8px / 2);
|
|
7
|
+
padding-bottom: calc(var(--padding-x-small) / 2);
|
|
8
|
+
padding-left: calc(8px - 1px);
|
|
9
|
+
padding-left: calc(var(--padding-x-small) - 1px);
|
|
10
|
+
padding-right: 8px;
|
|
11
|
+
padding-right: var(--padding-x-small);
|
|
12
|
+
border-radius: 10px;
|
|
13
|
+
border-radius: var(--radius-small);
|
|
14
|
+
word-break: break-word;
|
|
15
|
+
word-wrap: break-word;
|
|
16
|
+
}
|
|
17
|
+
.wds-inline-prompt:has(a),
|
|
18
|
+
.wds-inline-prompt:has(button) {
|
|
19
|
+
position: relative;
|
|
20
|
+
z-index: 1;
|
|
21
|
+
}
|
|
22
|
+
.wds-inline-prompt--muted {
|
|
23
|
+
opacity: 0.93;
|
|
24
|
+
filter: grayscale(1);
|
|
25
|
+
}
|
|
26
|
+
.wds-inline-prompt a,
|
|
27
|
+
.wds-inline-prompt button {
|
|
28
|
+
text-underline-offset: calc(4px / 2);
|
|
29
|
+
text-underline-offset: calc(var(--size-4) / 2);
|
|
30
|
+
}
|
|
31
|
+
.wds-inline-prompt a:first-of-type:before,
|
|
32
|
+
.wds-inline-prompt button:first-of-type:before {
|
|
33
|
+
content: '';
|
|
34
|
+
position: absolute;
|
|
35
|
+
inset: 0;
|
|
36
|
+
}
|
|
37
|
+
.wds-inline-prompt__media-wrapper {
|
|
38
|
+
padding-right: calc(12px / 2);
|
|
39
|
+
padding-right: calc(var(--size-12) / 2);
|
|
40
|
+
padding-top: calc(4px - 1px);
|
|
41
|
+
padding-top: calc(var(--size-4) - 1px);
|
|
42
|
+
padding-bottom: calc(4px - 1px);
|
|
43
|
+
padding-bottom: calc(var(--size-4) - 1px);
|
|
44
|
+
}
|
|
45
|
+
.wds-inline-prompt__media-wrapper .tw-icon-tags,
|
|
46
|
+
.wds-inline-prompt__media-wrapper .tw-icon-confetti {
|
|
47
|
+
color: var(--color-sentiment-positive-primary);
|
|
48
|
+
}
|
|
49
|
+
.wds-inline-prompt--negative {
|
|
50
|
+
background-color: var(--color-sentiment-negative-secondary);
|
|
51
|
+
color: var(--color-sentiment-negative-primary);
|
|
52
|
+
}
|
|
53
|
+
.wds-inline-prompt--negative a,
|
|
54
|
+
.wds-inline-prompt--negative button {
|
|
55
|
+
color: var(--color-sentiment-negative-primary);
|
|
56
|
+
}
|
|
57
|
+
.wds-inline-prompt--negative a:hover,
|
|
58
|
+
.wds-inline-prompt--negative button:hover {
|
|
59
|
+
color: var(--color-sentiment-negative-primary-hover);
|
|
60
|
+
}
|
|
61
|
+
.wds-inline-prompt--negative a:active,
|
|
62
|
+
.wds-inline-prompt--negative button:active {
|
|
63
|
+
color: var(--color-sentiment-negative-primary-active);
|
|
64
|
+
}
|
|
65
|
+
.wds-inline-prompt.wds-inline-prompt--negative:has(a, button):hover {
|
|
66
|
+
background-color: var(--color-sentiment-negative-secondary-hover);
|
|
67
|
+
}
|
|
68
|
+
.wds-inline-prompt.wds-inline-prompt--negative:has(a, button):active {
|
|
69
|
+
background-color: var(--color-sentiment-negative-secondary-active);
|
|
70
|
+
}
|
|
71
|
+
.wds-inline-prompt--positive {
|
|
72
|
+
background-color: var(--color-sentiment-positive-secondary);
|
|
73
|
+
color: var(--color-sentiment-positive-primary);
|
|
74
|
+
}
|
|
75
|
+
.wds-inline-prompt--positive a,
|
|
76
|
+
.wds-inline-prompt--positive button {
|
|
77
|
+
color: var(--color-sentiment-positive-primary);
|
|
78
|
+
}
|
|
79
|
+
.wds-inline-prompt--positive a:hover,
|
|
80
|
+
.wds-inline-prompt--positive button:hover {
|
|
81
|
+
color: var(--color-sentiment-positive-primary-hover);
|
|
82
|
+
}
|
|
83
|
+
.wds-inline-prompt--positive a:active,
|
|
84
|
+
.wds-inline-prompt--positive button:active {
|
|
85
|
+
color: var(--color-sentiment-positive-primary-active);
|
|
86
|
+
}
|
|
87
|
+
.wds-inline-prompt.wds-inline-prompt--positive:has(a, button):hover {
|
|
88
|
+
background-color: var(--color-sentiment-positive-secondary-hover);
|
|
89
|
+
}
|
|
90
|
+
.wds-inline-prompt.wds-inline-prompt--positive:has(a, button):active {
|
|
91
|
+
background-color: var(--color-sentiment-positive-secondary-active);
|
|
92
|
+
}
|
|
93
|
+
.wds-inline-prompt--proposition {
|
|
94
|
+
background-color: var(--color-sentiment-positive-secondary);
|
|
95
|
+
color: var(--color-sentiment-positive-primary);
|
|
96
|
+
}
|
|
97
|
+
.wds-inline-prompt--proposition a,
|
|
98
|
+
.wds-inline-prompt--proposition button {
|
|
99
|
+
color: var(--color-sentiment-positive-primary);
|
|
100
|
+
}
|
|
101
|
+
.wds-inline-prompt--proposition a:hover,
|
|
102
|
+
.wds-inline-prompt--proposition button:hover {
|
|
103
|
+
color: var(--color-sentiment-positive-primary-hover);
|
|
104
|
+
}
|
|
105
|
+
.wds-inline-prompt--proposition a:active,
|
|
106
|
+
.wds-inline-prompt--proposition button:active {
|
|
107
|
+
color: var(--color-sentiment-positive-primary-active);
|
|
108
|
+
}
|
|
109
|
+
.wds-inline-prompt.wds-inline-prompt--proposition:has(a, button):hover {
|
|
110
|
+
background-color: var(--color-sentiment-positive-secondary-hover);
|
|
111
|
+
}
|
|
112
|
+
.wds-inline-prompt.wds-inline-prompt--proposition:has(a, button):active {
|
|
113
|
+
background-color: var(--color-sentiment-positive-secondary-active);
|
|
114
|
+
}
|
|
115
|
+
.wds-inline-prompt--neutral {
|
|
116
|
+
background-color: rgba(134,167,189,0.10196);
|
|
117
|
+
background-color: var(--color-background-neutral);
|
|
118
|
+
color: #37517e;
|
|
119
|
+
color: var(--color-content-primary);
|
|
120
|
+
}
|
|
121
|
+
.wds-inline-prompt--neutral a,
|
|
122
|
+
.wds-inline-prompt--neutral button {
|
|
123
|
+
color: #37517e;
|
|
124
|
+
color: var(--color-content-primary);
|
|
125
|
+
}
|
|
126
|
+
.wds-inline-prompt.wds-inline-prompt--neutral:has(a, button):hover {
|
|
127
|
+
background-color: var(--color-background-neutral-hover);
|
|
128
|
+
}
|
|
129
|
+
.wds-inline-prompt.wds-inline-prompt--neutral:has(a, button):active {
|
|
130
|
+
background-color: var(--color-background-neutral-active);
|
|
131
|
+
}
|
|
132
|
+
.wds-inline-prompt--warning {
|
|
133
|
+
background-color: var(--color-sentiment-warning-secondary);
|
|
134
|
+
color: var(--color-sentiment-warning-content);
|
|
135
|
+
}
|
|
136
|
+
.wds-inline-prompt--warning a,
|
|
137
|
+
.wds-inline-prompt--warning button {
|
|
138
|
+
color: var(--color-sentiment-warning-content);
|
|
139
|
+
}
|
|
140
|
+
.wds-inline-prompt--warning a:hover,
|
|
141
|
+
.wds-inline-prompt--warning button:hover {
|
|
142
|
+
color: var(--color-sentiment-warning-content-hover);
|
|
143
|
+
}
|
|
144
|
+
.wds-inline-prompt--warning a:active,
|
|
145
|
+
.wds-inline-prompt--warning button:active {
|
|
146
|
+
color: var(--color-sentiment-warning-content-active);
|
|
147
|
+
}
|
|
148
|
+
.wds-inline-prompt.wds-inline-prompt--warning:has(a, button):hover {
|
|
149
|
+
background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 92%, var(--color-sentiment-warning-primary));
|
|
150
|
+
}
|
|
151
|
+
.wds-inline-prompt.wds-inline-prompt--warning:has(a, button):active {
|
|
152
|
+
background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 84%, var(--color-sentiment-warning-primary));
|
|
153
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/// @FIXME all tokens here need to be adjusted after
|
|
2
|
+
/// the new sentiment tokens land
|
|
3
|
+
|
|
4
|
+
.wds-inline-prompt {
|
|
5
|
+
display: inline-flex;
|
|
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
|
+
&--muted {
|
|
22
|
+
opacity: .93;
|
|
23
|
+
filter: grayscale(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
a, button {
|
|
27
|
+
text-underline-offset: calc(var(--size-4) / 2);
|
|
28
|
+
&:first-of-type {
|
|
29
|
+
&:before {
|
|
30
|
+
content: '';
|
|
31
|
+
position: absolute;
|
|
32
|
+
inset: 0;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&__media-wrapper {
|
|
38
|
+
padding-right: calc(var(--size-12) / 2);
|
|
39
|
+
padding-top: calc(var(--size-4) - 1px);
|
|
40
|
+
padding-bottom: calc(var(--size-4) - 1px);
|
|
41
|
+
|
|
42
|
+
.tw-icon-tags,
|
|
43
|
+
.tw-icon-confetti {
|
|
44
|
+
color: var(--color-sentiment-positive-primary);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&--negative {
|
|
49
|
+
background-color: var(--color-sentiment-negative-secondary);
|
|
50
|
+
color: var(--color-sentiment-negative-primary);
|
|
51
|
+
|
|
52
|
+
a, button {
|
|
53
|
+
color: var(--color-sentiment-negative-primary);
|
|
54
|
+
|
|
55
|
+
&:hover {
|
|
56
|
+
color: var(--color-sentiment-negative-primary-hover);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&:active {
|
|
60
|
+
color: var(--color-sentiment-negative-primary-active);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.wds-inline-prompt&:has(a, button) {
|
|
65
|
+
&:hover {
|
|
66
|
+
background-color: var(--color-sentiment-negative-secondary-hover);
|
|
67
|
+
}
|
|
68
|
+
&:active {
|
|
69
|
+
background-color: var(--color-sentiment-negative-secondary-active);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&--positive {
|
|
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-inline-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
|
+
|
|
96
|
+
&--proposition {
|
|
97
|
+
background-color: var(--color-sentiment-positive-secondary);
|
|
98
|
+
|
|
99
|
+
color: var(--color-sentiment-positive-primary);
|
|
100
|
+
|
|
101
|
+
a, button {
|
|
102
|
+
color: var(--color-sentiment-positive-primary);
|
|
103
|
+
&:hover {
|
|
104
|
+
color: var(--color-sentiment-positive-primary-hover);
|
|
105
|
+
}
|
|
106
|
+
&:active {
|
|
107
|
+
color: var(--color-sentiment-positive-primary-active);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.wds-inline-prompt&:has(a, button) {
|
|
112
|
+
&:hover {
|
|
113
|
+
background-color: var(--color-sentiment-positive-secondary-hover);
|
|
114
|
+
}
|
|
115
|
+
&:active {
|
|
116
|
+
background-color: var(--color-sentiment-positive-secondary-active);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
&--neutral {
|
|
122
|
+
background-color: var(--color-background-neutral);
|
|
123
|
+
color: var(--color-content-primary);
|
|
124
|
+
|
|
125
|
+
a, button {
|
|
126
|
+
color: var(--color-content-primary);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.wds-inline-prompt&:has(a, button) {
|
|
130
|
+
&:hover {
|
|
131
|
+
background-color: var(--color-background-neutral-hover);
|
|
132
|
+
}
|
|
133
|
+
&:active {
|
|
134
|
+
background-color: var(--color-background-neutral-active);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
&--warning {
|
|
140
|
+
background-color: var(--color-sentiment-warning-secondary);
|
|
141
|
+
color: var(--color-sentiment-warning-content);
|
|
142
|
+
|
|
143
|
+
a, button {
|
|
144
|
+
color: var(--color-sentiment-warning-content);
|
|
145
|
+
&:hover {
|
|
146
|
+
color: var(--color-sentiment-warning-content-hover);
|
|
147
|
+
}
|
|
148
|
+
&:active {
|
|
149
|
+
color: var(--color-sentiment-warning-content-active);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.wds-inline-prompt&:has(a, button) {
|
|
154
|
+
&:hover {
|
|
155
|
+
background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 92%, var(--color-sentiment-warning-primary));
|
|
156
|
+
}
|
|
157
|
+
&:active {
|
|
158
|
+
background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 84%, var(--color-sentiment-warning-primary));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mockMatchMedia, render, screen } from '../../../test-utils';
|
|
3
|
+
import { InlinePrompt, InlinePromptProps } from './InlinePrompt';
|
|
4
|
+
import { Sentiment } from '../../../common';
|
|
5
|
+
|
|
6
|
+
mockMatchMedia();
|
|
7
|
+
|
|
8
|
+
describe('InlinePrompt', () => {
|
|
9
|
+
const defaultProps: InlinePromptProps = {
|
|
10
|
+
children: 'Prompt message',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
it('renders children', () => {
|
|
14
|
+
render(<InlinePrompt {...defaultProps}>Hello world</InlinePrompt>);
|
|
15
|
+
expect(screen.getByText('Hello world')).toBeInTheDocument();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('renders with each sentiment', () => {
|
|
19
|
+
it.each([Sentiment.POSITIVE, Sentiment.NEUTRAL, Sentiment.NEGATIVE, Sentiment.WARNING])(
|
|
20
|
+
'renders with sentiment %s',
|
|
21
|
+
(sentiment) => {
|
|
22
|
+
render(
|
|
23
|
+
<InlinePrompt
|
|
24
|
+
{...defaultProps}
|
|
25
|
+
sentiment={sentiment as InlinePromptProps['sentiment']}
|
|
26
|
+
/>,
|
|
27
|
+
);
|
|
28
|
+
expect(screen.getByText('Prompt message').parentElement).toHaveClass(
|
|
29
|
+
`wds-inline-prompt--${sentiment}`,
|
|
30
|
+
);
|
|
31
|
+
},
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('renders muted state', () => {
|
|
36
|
+
render(<InlinePrompt {...defaultProps} muted />);
|
|
37
|
+
screen.debug(undefined, 99999999);
|
|
38
|
+
expect(screen.getByText('Prompt message').parentElement).toHaveClass(
|
|
39
|
+
'wds-inline-prompt--muted',
|
|
40
|
+
);
|
|
41
|
+
expect(screen.getByTestId('InlinePrompt_Muted')).toBeInTheDocument();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('renders loading state', () => {
|
|
45
|
+
render(<InlinePrompt {...defaultProps} loading />);
|
|
46
|
+
screen.debug(undefined, 99999999);
|
|
47
|
+
expect(screen.getByText('Prompt message').parentElement).toHaveClass(
|
|
48
|
+
'wds-inline-prompt--loading',
|
|
49
|
+
);
|
|
50
|
+
expect(screen.getByTestId('InlinePrompt_ProcessIndicator')).toBeInTheDocument();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('applies custom className, id, and data-testid', () => {
|
|
54
|
+
render(
|
|
55
|
+
<InlinePrompt
|
|
56
|
+
{...defaultProps}
|
|
57
|
+
className="custom-class"
|
|
58
|
+
id="custom-id"
|
|
59
|
+
data-testid="custom-test"
|
|
60
|
+
/>,
|
|
61
|
+
);
|
|
62
|
+
const el = screen.getByTestId('custom-test');
|
|
63
|
+
expect(el).toHaveClass('custom-class');
|
|
64
|
+
expect(el).toHaveAttribute('id', 'custom-id');
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Sentiment } from '../../../common';
|
|
2
|
+
import { BackslashCircle } from '@transferwise/icons';
|
|
3
|
+
import ProcessIndicator from '../../../processIndicator';
|
|
4
|
+
import StatusIcon from '../../../statusIcon';
|
|
5
|
+
import { clsx } from 'clsx';
|
|
6
|
+
import Body from '../../../body';
|
|
7
|
+
|
|
8
|
+
export type InlinePromptProps = {
|
|
9
|
+
sentiment?: `${Sentiment.POSITIVE | Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.WARNING}`;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Use for short-lived inline prompts to avoid swap of the icon (which is bad UX for short-lived prompts, e.g. when submit form)
|
|
13
|
+
*/
|
|
14
|
+
muted?: boolean;
|
|
15
|
+
id?: string;
|
|
16
|
+
className?: string;
|
|
17
|
+
'data-testid'?: string;
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const InlinePrompt = ({
|
|
22
|
+
sentiment = Sentiment.POSITIVE,
|
|
23
|
+
muted = false,
|
|
24
|
+
loading = false,
|
|
25
|
+
className,
|
|
26
|
+
children,
|
|
27
|
+
...rest
|
|
28
|
+
}: InlinePromptProps) => {
|
|
29
|
+
const renderMedia = () => {
|
|
30
|
+
if (muted) {
|
|
31
|
+
return <BackslashCircle size={16} data-testid="InlinePrompt_Muted" />;
|
|
32
|
+
}
|
|
33
|
+
if (loading) {
|
|
34
|
+
return <ProcessIndicator data-testid="InlinePrompt_ProcessIndicator" size="xxs" />;
|
|
35
|
+
}
|
|
36
|
+
return <StatusIcon size={16} sentiment={sentiment} />;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div
|
|
41
|
+
className={clsx(
|
|
42
|
+
'wds-inline-prompt',
|
|
43
|
+
`wds-inline-prompt--${sentiment}`,
|
|
44
|
+
{
|
|
45
|
+
'wds-inline-prompt--muted': muted,
|
|
46
|
+
'wds-inline-prompt--loading': loading,
|
|
47
|
+
},
|
|
48
|
+
className,
|
|
49
|
+
)}
|
|
50
|
+
{...rest}
|
|
51
|
+
>
|
|
52
|
+
<div className="wds-inline-prompt__media-wrapper">{renderMedia()}</div>
|
|
53
|
+
<Body>{children}</Body>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
.wds-
|
|
2
|
-
grid-area: prompt;
|
|
1
|
+
.wds-inline-prompt {
|
|
3
2
|
display: inline-flex;
|
|
4
|
-
justify-self: start;
|
|
5
3
|
text-align: left;
|
|
6
4
|
padding-top: calc(8px / 2);
|
|
7
5
|
padding-top: calc(var(--padding-x-small) / 2);
|
|
@@ -16,33 +14,27 @@
|
|
|
16
14
|
word-break: break-word;
|
|
17
15
|
word-wrap: break-word;
|
|
18
16
|
}
|
|
19
|
-
.wds-
|
|
20
|
-
.wds-
|
|
17
|
+
.wds-inline-prompt:has(a),
|
|
18
|
+
.wds-inline-prompt:has(button) {
|
|
21
19
|
position: relative;
|
|
22
20
|
z-index: 1;
|
|
23
21
|
}
|
|
24
|
-
.wds-
|
|
25
|
-
.
|
|
22
|
+
.wds-inline-prompt--muted {
|
|
23
|
+
opacity: 0.93;
|
|
24
|
+
filter: grayscale(1);
|
|
25
|
+
}
|
|
26
|
+
.wds-inline-prompt a,
|
|
27
|
+
.wds-inline-prompt button {
|
|
26
28
|
text-underline-offset: calc(4px / 2);
|
|
27
29
|
text-underline-offset: calc(var(--size-4) / 2);
|
|
28
30
|
}
|
|
29
|
-
.wds-
|
|
30
|
-
.wds-
|
|
31
|
+
.wds-inline-prompt a:first-of-type:before,
|
|
32
|
+
.wds-inline-prompt button:first-of-type:before {
|
|
31
33
|
content: '';
|
|
32
34
|
position: absolute;
|
|
33
35
|
inset: 0;
|
|
34
36
|
}
|
|
35
|
-
.wds-
|
|
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 {
|
|
37
|
+
.wds-inline-prompt__media-wrapper {
|
|
46
38
|
padding-right: calc(12px / 2);
|
|
47
39
|
padding-right: calc(var(--size-12) / 2);
|
|
48
40
|
padding-top: calc(4px - 1px);
|
|
@@ -50,108 +42,116 @@
|
|
|
50
42
|
padding-bottom: calc(4px - 1px);
|
|
51
43
|
padding-bottom: calc(var(--size-4) - 1px);
|
|
52
44
|
}
|
|
53
|
-
.wds-
|
|
54
|
-
.wds-
|
|
45
|
+
.wds-inline-prompt__media-wrapper .tw-icon-tags,
|
|
46
|
+
.wds-inline-prompt__media-wrapper .tw-icon-confetti {
|
|
55
47
|
color: var(--color-sentiment-positive-primary);
|
|
56
48
|
}
|
|
57
|
-
.wds-
|
|
49
|
+
.wds-inline-prompt--negative {
|
|
58
50
|
background-color: var(--color-sentiment-negative-secondary);
|
|
59
51
|
color: var(--color-sentiment-negative-primary);
|
|
60
52
|
}
|
|
61
|
-
.wds-
|
|
62
|
-
.wds-
|
|
53
|
+
.wds-inline-prompt--negative a,
|
|
54
|
+
.wds-inline-prompt--negative button {
|
|
63
55
|
color: var(--color-sentiment-negative-primary);
|
|
64
56
|
}
|
|
65
|
-
.wds-
|
|
66
|
-
.wds-
|
|
57
|
+
.wds-inline-prompt--negative a:hover,
|
|
58
|
+
.wds-inline-prompt--negative button:hover {
|
|
67
59
|
color: var(--color-sentiment-negative-primary-hover);
|
|
68
60
|
}
|
|
69
|
-
.wds-
|
|
70
|
-
.wds-
|
|
61
|
+
.wds-inline-prompt--negative a:active,
|
|
62
|
+
.wds-inline-prompt--negative button:active {
|
|
71
63
|
color: var(--color-sentiment-negative-primary-active);
|
|
72
64
|
}
|
|
73
|
-
.wds-
|
|
65
|
+
.wds-inline-prompt.wds-inline-prompt--negative:has(a, button):hover {
|
|
74
66
|
background-color: var(--color-sentiment-negative-secondary-hover);
|
|
75
67
|
}
|
|
76
|
-
.wds-
|
|
68
|
+
.wds-inline-prompt.wds-inline-prompt--negative:has(a, button):active {
|
|
77
69
|
background-color: var(--color-sentiment-negative-secondary-active);
|
|
78
70
|
}
|
|
79
|
-
.wds-
|
|
80
|
-
.wds-list-item-prompt.discount,
|
|
81
|
-
.wds-list-item-prompt.savings {
|
|
71
|
+
.wds-inline-prompt--positive {
|
|
82
72
|
background-color: var(--color-sentiment-positive-secondary);
|
|
83
73
|
color: var(--color-sentiment-positive-primary);
|
|
84
74
|
}
|
|
85
|
-
.wds-
|
|
86
|
-
.wds-
|
|
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 {
|
|
75
|
+
.wds-inline-prompt--positive a,
|
|
76
|
+
.wds-inline-prompt--positive button {
|
|
91
77
|
color: var(--color-sentiment-positive-primary);
|
|
92
78
|
}
|
|
93
|
-
.wds-
|
|
94
|
-
.wds-
|
|
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 {
|
|
79
|
+
.wds-inline-prompt--positive a:hover,
|
|
80
|
+
.wds-inline-prompt--positive button:hover {
|
|
99
81
|
color: var(--color-sentiment-positive-primary-hover);
|
|
100
82
|
}
|
|
101
|
-
.wds-
|
|
102
|
-
.wds-
|
|
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 {
|
|
83
|
+
.wds-inline-prompt--positive a:active,
|
|
84
|
+
.wds-inline-prompt--positive button:active {
|
|
107
85
|
color: var(--color-sentiment-positive-primary-active);
|
|
108
86
|
}
|
|
109
|
-
.wds-
|
|
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 {
|
|
87
|
+
.wds-inline-prompt.wds-inline-prompt--positive:has(a, button):hover {
|
|
112
88
|
background-color: var(--color-sentiment-positive-secondary-hover);
|
|
113
89
|
}
|
|
114
|
-
.wds-
|
|
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 {
|
|
90
|
+
.wds-inline-prompt.wds-inline-prompt--positive:has(a, button):active {
|
|
117
91
|
background-color: var(--color-sentiment-positive-secondary-active);
|
|
118
92
|
}
|
|
119
|
-
.wds-
|
|
93
|
+
.wds-inline-prompt--proposition {
|
|
94
|
+
background-color: var(--color-sentiment-positive-secondary);
|
|
95
|
+
color: var(--color-sentiment-positive-primary);
|
|
96
|
+
}
|
|
97
|
+
.wds-inline-prompt--proposition a,
|
|
98
|
+
.wds-inline-prompt--proposition button {
|
|
99
|
+
color: var(--color-sentiment-positive-primary);
|
|
100
|
+
}
|
|
101
|
+
.wds-inline-prompt--proposition a:hover,
|
|
102
|
+
.wds-inline-prompt--proposition button:hover {
|
|
103
|
+
color: var(--color-sentiment-positive-primary-hover);
|
|
104
|
+
}
|
|
105
|
+
.wds-inline-prompt--proposition a:active,
|
|
106
|
+
.wds-inline-prompt--proposition button:active {
|
|
107
|
+
color: var(--color-sentiment-positive-primary-active);
|
|
108
|
+
}
|
|
109
|
+
.wds-inline-prompt.wds-inline-prompt--proposition:has(a, button):hover {
|
|
110
|
+
background-color: var(--color-sentiment-positive-secondary-hover);
|
|
111
|
+
}
|
|
112
|
+
.wds-inline-prompt.wds-inline-prompt--proposition:has(a, button):active {
|
|
113
|
+
background-color: var(--color-sentiment-positive-secondary-active);
|
|
114
|
+
}
|
|
115
|
+
.wds-inline-prompt--neutral {
|
|
120
116
|
background-color: rgba(134,167,189,0.10196);
|
|
121
117
|
background-color: var(--color-background-neutral);
|
|
122
118
|
color: #37517e;
|
|
123
119
|
color: var(--color-content-primary);
|
|
124
120
|
}
|
|
125
|
-
.wds-
|
|
126
|
-
.wds-
|
|
121
|
+
.wds-inline-prompt--neutral a,
|
|
122
|
+
.wds-inline-prompt--neutral button {
|
|
127
123
|
color: #37517e;
|
|
128
124
|
color: var(--color-content-primary);
|
|
129
125
|
}
|
|
130
|
-
.wds-
|
|
126
|
+
.wds-inline-prompt.wds-inline-prompt--neutral:has(a, button):hover {
|
|
131
127
|
background-color: var(--color-background-neutral-hover);
|
|
132
128
|
}
|
|
133
|
-
.wds-
|
|
129
|
+
.wds-inline-prompt.wds-inline-prompt--neutral:has(a, button):active {
|
|
134
130
|
background-color: var(--color-background-neutral-active);
|
|
135
131
|
}
|
|
136
|
-
.wds-
|
|
132
|
+
.wds-inline-prompt--warning {
|
|
137
133
|
background-color: var(--color-sentiment-warning-secondary);
|
|
138
134
|
color: var(--color-sentiment-warning-content);
|
|
139
135
|
}
|
|
140
|
-
.wds-
|
|
141
|
-
.wds-
|
|
136
|
+
.wds-inline-prompt--warning a,
|
|
137
|
+
.wds-inline-prompt--warning button {
|
|
142
138
|
color: var(--color-sentiment-warning-content);
|
|
143
139
|
}
|
|
144
|
-
.wds-
|
|
145
|
-
.wds-
|
|
140
|
+
.wds-inline-prompt--warning a:hover,
|
|
141
|
+
.wds-inline-prompt--warning button:hover {
|
|
146
142
|
color: var(--color-sentiment-warning-content-hover);
|
|
147
143
|
}
|
|
148
|
-
.wds-
|
|
149
|
-
.wds-
|
|
144
|
+
.wds-inline-prompt--warning a:active,
|
|
145
|
+
.wds-inline-prompt--warning button:active {
|
|
150
146
|
color: var(--color-sentiment-warning-content-active);
|
|
151
147
|
}
|
|
152
|
-
.wds-
|
|
148
|
+
.wds-inline-prompt.wds-inline-prompt--warning:has(a, button):hover {
|
|
153
149
|
background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 92%, var(--color-sentiment-warning-primary));
|
|
154
150
|
}
|
|
155
|
-
.wds-
|
|
151
|
+
.wds-inline-prompt.wds-inline-prompt--warning:has(a, button):active {
|
|
156
152
|
background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 84%, var(--color-sentiment-warning-primary));
|
|
157
153
|
}
|
|
154
|
+
.wds-list-item-prompt {
|
|
155
|
+
grid-area: prompt;
|
|
156
|
+
justify-self: start;
|
|
157
|
+
}
|