@transferwise/components 0.0.0-experimental-6528439 → 0.0.0-experimental-1ffdc56

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 (189) hide show
  1. package/build/alert/Alert.js +33 -17
  2. package/build/alert/Alert.js.map +1 -1
  3. package/build/alert/Alert.mjs +30 -14
  4. package/build/alert/Alert.mjs.map +1 -1
  5. package/build/avatarLayout/AvatarLayout.js +9 -2
  6. package/build/avatarLayout/AvatarLayout.js.map +1 -1
  7. package/build/avatarLayout/AvatarLayout.mjs +9 -2
  8. package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
  9. package/build/button/Button.js +86 -79
  10. package/build/button/Button.js.map +1 -1
  11. package/build/button/Button.mjs +87 -80
  12. package/build/button/Button.mjs.map +1 -1
  13. package/build/button/Button.resolver.js +74 -0
  14. package/build/button/Button.resolver.js.map +1 -0
  15. package/build/button/Button.resolver.mjs +72 -0
  16. package/build/button/Button.resolver.mjs.map +1 -0
  17. package/build/button/LegacyButton.js +114 -0
  18. package/build/button/LegacyButton.js.map +1 -0
  19. package/build/button/LegacyButton.mjs +112 -0
  20. package/build/button/LegacyButton.mjs.map +1 -0
  21. package/build/common/action/Action.js +26 -15
  22. package/build/common/action/Action.js.map +1 -1
  23. package/build/common/action/Action.mjs +26 -15
  24. package/build/common/action/Action.mjs.map +1 -1
  25. package/build/common/propsValues/sentiment.js +1 -0
  26. package/build/common/propsValues/sentiment.js.map +1 -1
  27. package/build/common/propsValues/sentiment.mjs +1 -0
  28. package/build/common/propsValues/sentiment.mjs.map +1 -1
  29. package/build/criticalBanner/CriticalCommsBanner.js +10 -73
  30. package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
  31. package/build/criticalBanner/CriticalCommsBanner.mjs +11 -74
  32. package/build/criticalBanner/CriticalCommsBanner.mjs.map +1 -1
  33. package/build/dimmer/Dimmer.js +67 -41
  34. package/build/dimmer/Dimmer.js.map +1 -1
  35. package/build/dimmer/Dimmer.mjs +69 -43
  36. package/build/dimmer/Dimmer.mjs.map +1 -1
  37. package/build/header/Header.js +2 -2
  38. package/build/header/Header.js.map +1 -1
  39. package/build/header/Header.mjs +1 -1
  40. package/build/i18n/en.json +1 -0
  41. package/build/i18n/en.json.js +1 -0
  42. package/build/i18n/en.json.js.map +1 -1
  43. package/build/i18n/en.json.mjs +1 -0
  44. package/build/i18n/en.json.mjs.map +1 -1
  45. package/build/index.js +2 -2
  46. package/build/index.mjs +1 -1
  47. package/build/inputs/_BottomSheet.js +8 -1
  48. package/build/inputs/_BottomSheet.js.map +1 -1
  49. package/build/inputs/_BottomSheet.mjs +9 -2
  50. package/build/inputs/_BottomSheet.mjs.map +1 -1
  51. package/build/inputs/_Popover.js +8 -1
  52. package/build/inputs/_Popover.js.map +1 -1
  53. package/build/inputs/_Popover.mjs +9 -2
  54. package/build/inputs/_Popover.mjs.map +1 -1
  55. package/build/link/Link.js +8 -3
  56. package/build/link/Link.js.map +1 -1
  57. package/build/link/Link.mjs +8 -3
  58. package/build/link/Link.mjs.map +1 -1
  59. package/build/main.css +250 -72
  60. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +2 -4
  61. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
  62. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +2 -4
  63. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
  64. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +3 -5
  65. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
  66. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +3 -5
  67. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
  68. package/build/select/Select.js +2 -2
  69. package/build/select/Select.js.map +1 -1
  70. package/build/select/Select.mjs +1 -1
  71. package/build/statusIcon/StatusIcon.js +5 -1
  72. package/build/statusIcon/StatusIcon.js.map +1 -1
  73. package/build/statusIcon/StatusIcon.messages.js +3 -0
  74. package/build/statusIcon/StatusIcon.messages.js.map +1 -1
  75. package/build/statusIcon/StatusIcon.messages.mjs +3 -0
  76. package/build/statusIcon/StatusIcon.messages.mjs.map +1 -1
  77. package/build/statusIcon/StatusIcon.mjs +5 -1
  78. package/build/statusIcon/StatusIcon.mjs.map +1 -1
  79. package/build/styles/avatarLayout/AvatarLayout.css +11 -0
  80. package/build/styles/button/Button.css +220 -15
  81. package/build/styles/button/Button.vars.css +46 -0
  82. package/build/styles/button/LegacyButton.css +23 -0
  83. package/build/styles/criticalBanner/CriticalCommsBanner.css +7 -72
  84. package/build/styles/main.css +250 -72
  85. package/build/styles/statusIcon/StatusIcon.css +4 -0
  86. package/build/types/alert/Alert.d.ts +2 -1
  87. package/build/types/alert/Alert.d.ts.map +1 -1
  88. package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
  89. package/build/types/button/Button.d.ts +2 -23
  90. package/build/types/button/Button.d.ts.map +1 -1
  91. package/build/types/button/Button.resolver.d.ts +35 -0
  92. package/build/types/button/Button.resolver.d.ts.map +1 -0
  93. package/build/types/button/Button.types.d.ts +70 -0
  94. package/build/types/button/Button.types.d.ts.map +1 -0
  95. package/build/types/button/LegacyButton.d.ts +44 -0
  96. package/build/types/button/LegacyButton.d.ts.map +1 -0
  97. package/build/types/button/index.d.ts +2 -2
  98. package/build/types/button/index.d.ts.map +1 -1
  99. package/build/types/common/action/Action.d.ts +4 -1
  100. package/build/types/common/action/Action.d.ts.map +1 -1
  101. package/build/types/common/propsValues/sentiment.d.ts +1 -0
  102. package/build/types/common/propsValues/sentiment.d.ts.map +1 -1
  103. package/build/types/criticalBanner/CriticalCommsBanner.d.ts.map +1 -1
  104. package/build/types/dimmer/Dimmer.d.ts.map +1 -1
  105. package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
  106. package/build/types/inputs/_Popover.d.ts.map +1 -1
  107. package/build/types/link/Link.d.ts +2 -2
  108. package/build/types/link/Link.d.ts.map +1 -1
  109. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
  110. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +6 -2
  111. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
  112. package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
  113. package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
  114. package/build/types/statusIcon/StatusIcon.messages.d.ts +5 -0
  115. package/build/types/statusIcon/StatusIcon.messages.d.ts.map +1 -1
  116. package/build/types/test-utils/index.d.ts +2 -0
  117. package/build/types/test-utils/index.d.ts.map +1 -1
  118. package/build/types/test-utils/story-config.d.ts +1 -1
  119. package/build/types/test-utils/story-config.d.ts.map +1 -1
  120. package/build/types/withNextPortal/withNextPortal.d.ts.map +1 -1
  121. package/build/upload/steps/completeStep/completeStep.js +2 -2
  122. package/build/upload/steps/completeStep/completeStep.js.map +1 -1
  123. package/build/upload/steps/completeStep/completeStep.mjs +1 -1
  124. package/build/upload/steps/processingStep/processingStep.js +2 -2
  125. package/build/upload/steps/processingStep/processingStep.js.map +1 -1
  126. package/build/upload/steps/processingStep/processingStep.mjs +1 -1
  127. package/build/uploadInput/UploadInput.js +3 -3
  128. package/build/uploadInput/UploadInput.js.map +1 -1
  129. package/build/uploadInput/UploadInput.mjs +1 -1
  130. package/build/withNextPortal/withNextPortal.js +2 -5
  131. package/build/withNextPortal/withNextPortal.js.map +1 -1
  132. package/build/withNextPortal/withNextPortal.mjs +2 -5
  133. package/build/withNextPortal/withNextPortal.mjs.map +1 -1
  134. package/package.json +5 -5
  135. package/src/alert/Alert.story.tsx +36 -0
  136. package/src/alert/Alert.tests.story.tsx +1 -1
  137. package/src/alert/Alert.tsx +37 -8
  138. package/src/avatarLayout/AvatarLayout.css +11 -0
  139. package/src/avatarLayout/AvatarLayout.less +18 -1
  140. package/src/avatarLayout/AvatarLayout.tsx +10 -2
  141. package/src/button/Button.accessibility.docs.mdx +103 -0
  142. package/src/button/Button.css +220 -15
  143. package/src/button/Button.less +228 -13
  144. package/src/button/Button.resolver.tsx +73 -0
  145. package/src/button/Button.spec.tsx +215 -226
  146. package/src/button/Button.story.tsx +761 -134
  147. package/src/button/Button.tests.story.tsx +27 -0
  148. package/src/button/Button.tsx +99 -132
  149. package/src/button/Button.types.ts +92 -0
  150. package/src/button/Button.vars.css +46 -0
  151. package/src/button/Button.vars.less +57 -0
  152. package/src/button/LegacyButton.css +23 -0
  153. package/src/button/LegacyButton.less +24 -0
  154. package/src/button/LegacyButton.spec.tsx +147 -0
  155. package/src/button/LegacyButton.story.tsx +228 -0
  156. package/src/button/LegacyButton.tsx +177 -0
  157. package/src/button/index.ts +2 -3
  158. package/src/common/action/Action.tsx +39 -21
  159. package/src/common/bottomSheet/BottomSheet.spec.tsx +3 -6
  160. package/src/common/bottomSheet/__snapshots__/BottomSheet.spec.tsx.snap +1 -5
  161. package/src/common/propsValues/sentiment.ts +1 -0
  162. package/src/criticalBanner/CriticalCommsBanner.css +7 -72
  163. package/src/criticalBanner/CriticalCommsBanner.less +12 -73
  164. package/src/criticalBanner/CriticalCommsBanner.story.tsx +13 -9
  165. package/src/criticalBanner/CriticalCommsBanner.tsx +8 -50
  166. package/src/dimmer/Dimmer.tsx +72 -44
  167. package/src/field/Field.story.tsx +1 -1
  168. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -2
  169. package/src/i18n/en.json +1 -0
  170. package/src/inputs/SelectInput.story.tsx +1 -1
  171. package/src/inputs/_BottomSheet.tsx +9 -3
  172. package/src/inputs/_Popover.tsx +10 -4
  173. package/src/label/Label.story.tsx +1 -1
  174. package/src/link/Link.tsx +15 -6
  175. package/src/main.css +250 -72
  176. package/src/main.less +1 -0
  177. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +2 -8
  178. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +7 -2
  179. package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +1 -3
  180. package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +4 -12
  181. package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +16 -13
  182. package/src/statusIcon/StatusIcon.css +4 -0
  183. package/src/statusIcon/StatusIcon.less +4 -0
  184. package/src/statusIcon/StatusIcon.messages.ts +6 -0
  185. package/src/statusIcon/StatusIcon.tsx +8 -1
  186. package/src/test-utils/Parameters.d.ts +9 -1
  187. package/src/test-utils/story-config.ts +10 -1
  188. package/src/withNextPortal/withNextPortal.tsx +1 -10
  189. package/src/button/__snapshots__/Button.spec.tsx.snap +0 -309
@@ -1,24 +1,239 @@
1
- @import (reference) "../../node_modules/@transferwise/neptune-css/src/less/mixins/_logical-properties.less";
1
+ @import './Button.vars.less';
2
2
 
3
- .np-btn {
4
- position: relative;
3
+ /* Button Styles */
4
+ .wds-Button {
5
+ display: inline-flex;
6
+ flex: none;
7
+ width: auto;
8
+ align-items: center;
9
+ justify-content: center;
10
+ vertical-align: middle;
11
+ text-align: center;
12
+ white-space: nowrap;
13
+ word-wrap: break-word;
14
+ appearance: none;
15
+ background-color: var(--Button-background);
16
+ border: none;
17
+ border-radius: var(--Button-border-radius);
18
+ color: var(--Button-color);
19
+ cursor: pointer;
20
+ transition: color, background-color var(--Button-transition-duration) var(--Button-transition-easing);
5
21
 
6
- &.np-btn-block > span.btn-loader {
22
+ &,
23
+ &:hover,
24
+ &:active,
25
+ &:focus {
26
+ text-decoration: none;
27
+ }
28
+
29
+ &:hover {
30
+ background-color: var(--Button-background-hover);
31
+ }
32
+
33
+ &:active {
34
+ background-color: var(--Button-background-active);
35
+ }
36
+
37
+ &.wds-Button--disabled,
38
+ &:disabled {
39
+ // The declarations below are necessary as design specs for
40
+ // the button's disabled state have changed. This is to be
41
+ // further investigated at a later stage.
42
+ // @see https://transferwise.atlassian.net/browse/DS-7386
43
+ filter: none;
44
+ mix-blend-mode: luminosity;
45
+ opacity: 0.45;
46
+ cursor: not-allowed;
47
+
48
+ &,
49
+ &:hover,
50
+ &:active {
51
+ background-color: var(--Button-background);
52
+ }
53
+ }
54
+
55
+ // Priority modifiers
56
+ &--secondary {
57
+ --Button-background: var(--Button-secondary-background);
58
+ --Button-background-hover: var(--Button-secondary-background-hover);
59
+ --Button-background-active: var(--Button-secondary-background-active);
60
+ --Button-color: var(--Button-secondary-color);
61
+ }
62
+
63
+ &--tertiary {
64
+ --Button-background: var(--Button-tertiary-background);
65
+ --Button-background-hover: var(--Button-tertiary-background-hover);
66
+ --Button-background-active: var(--Button-tertiary-background-active);
67
+ --Button-color: var(--Button-tertiary-color);
68
+
69
+ .wds-Button-icon--end {
70
+ color: var(--color-interactive-primary);
71
+ }
72
+ }
73
+
74
+ &--minimal {
75
+ --Button-background: var(--Button-minimal-background);
76
+ --Button-background-hover: var(--Button-minimal-background-hover);
77
+ --Button-background-active: var(--Button-minimal-background-active);
78
+ --Button-color: var(--Button-minimal-color);
79
+
80
+ &,
81
+ &:hover,
82
+ &:active,
83
+ &:focus {
84
+ text-decoration: underline;
85
+ text-underline-offset: 3px;
86
+ text-decoration-thickness: 1px;
87
+ }
88
+ }
89
+
90
+ // Negative styles
91
+ &--negative {
92
+ &.wds-Button--primary {
93
+ --Button-background: var(--Button-primary-negative-background);
94
+ --Button-background-hover: var(--Button-primary-negative-background-hover);
95
+ --Button-background-active: var(--Button-primary-negative-background-active);
96
+ --Button-color: var(--Button-primary-negative-color);
97
+ }
98
+
99
+ &.wds-Button--secondary {
100
+ --Button-background: var(--Button-secondary-negative-background);
101
+ --Button-background-hover: var(--Button-secondary-negative-background-hover);
102
+ --Button-background-active: var(--Button-secondary-negative-background-active);
103
+ --Button-color: var(--Button-secondary-negative-color);
104
+ }
105
+ }
106
+
107
+ // Size modifiers
108
+ &--large {
109
+ padding: var(--Button-large-padding);
110
+ }
111
+
112
+ &--medium {
113
+ padding: var(--Button-medium-padding);
114
+
115
+ &:has(.wds-Button-avatars){
116
+ padding-inline-start: var(--size-8);
117
+ }
118
+
119
+ &:has(.wds-Button-icon--end){
120
+ padding-inline-end: var(--size-8);
121
+ }
122
+
123
+ .wds-Button-icon--start{
124
+ margin-inline-end: var(--Button-label-gap);
125
+ }
126
+ }
127
+
128
+ &--small {
129
+ padding: var(--Button-small-padding);
130
+
131
+ &:has(.wds-Button-icon--start){
132
+ padding-inline-start: var(--size-8);
133
+ }
134
+
135
+ &:has(.wds-Button-icon--end){
136
+ padding-inline-end: var(--size-8);
137
+ }
138
+ }
139
+
140
+ // Width modifiers
141
+ &--block {
142
+ width: 100%;
143
+ }
144
+
145
+ &-avatars {
146
+ display: inline-flex;
147
+
148
+ .np-avatar-view .np-avatar-view-content {
149
+ color: var(--Button-color);
150
+ }
151
+ }
152
+
153
+ // Icon styles
154
+ &-icon {
155
+ display: inline-block;
156
+ }
157
+
158
+ &-content {
159
+ position: relative;
160
+
161
+ &--loading {
162
+ .wds-Button-label,
163
+ .wds-Button-media,
164
+ .wds-Button-icon {
165
+ visibility: hidden;
166
+ opacity: 0;
167
+ }
168
+ }
169
+ }
170
+
171
+ &-label {
172
+ display: flex;
173
+ justify-content: center;
174
+ align-items: center;
175
+ gap: var(--Button-label-gap);
176
+ position: relative;
177
+ }
178
+
179
+ &-loader {
7
180
  position: absolute;
8
- .left(var(--size-24));
181
+ width: 100%;
182
+ height: 100%;
183
+
184
+ .process-circle {
185
+ stroke: var(--Button-color);
186
+ }
9
187
  }
188
+ }
10
189
 
11
- &.np-btn-xs > span.btn-loader {
12
- background-size: 16px 16px;
190
+ /* Avatar border transparency */
191
+ /* dark buttons get 20% transparency, light buttons get 12% */
192
+ .wds-Button-avatars {
193
+ .np-circle {
194
+ --circle-border-color: color-mix(in srgb, var(--Button-color) 20%, transparent);
195
+
196
+ .wds-Button--secondary.wds-Button--negative &,
197
+ .wds-Button--secondary &,
198
+ .wds-Button--tertiary &,
199
+ .wds-Button--minimal & {
200
+ .np-theme-personal:not(.np-theme-personal--dark, .np-theme-personal--forest-green, .np-theme-personal--bright-green) & {
201
+ --circle-border-color: color-mix(in srgb, var(--Button-color) 12%, transparent);
202
+ }
203
+ }
204
+ .wds-Button--primary &,
205
+ .wds-Button--primary.wds-Button--negative & {
206
+ .np-theme-personal--dark &,
207
+ .np-theme-personal--forest-green & {
208
+ --circle-border-color: color-mix(in srgb, var(--Button-color) 12%, transparent);
209
+ }
210
+ }
211
+ .wds-Button--tertiary &,
212
+ .wds-Button--minimal & {
213
+ .np-theme-personal--bright-green & {
214
+ --circle-border-color: color-mix(in srgb, var(--Button-color) 12%, transparent);
215
+ }
216
+ }
13
217
  }
218
+ }
14
219
 
15
- &.np-btn-xs.btn-block > span.btn-loader {
16
- top: 0;
220
+ .critical-comms {
221
+ .wds-Button {
222
+ --Button-background: var(--color-contrast-overlay);
17
223
  }
224
+ }
18
225
 
19
- // we do not want pointer events disabled as that
20
- // prevents the custom cursor to be shown
21
- &.disabled[class] {
22
- pointer-events: auto;
226
+ :dir(rtl) {
227
+ .wds-Button {
228
+ .tw-icon-chevron-right,
229
+ .tw-icon-arrow-right,
230
+ .tw-icon-chevron-left,
231
+ .tw-icon-arrow-left,
232
+ .tw-icon-arrow-diagonal-down,
233
+ .tw-icon-arrow-diagonal-up,
234
+ .tw-icon-list,
235
+ .tw-icon-activity {
236
+ scale: -1 1;
237
+ }
23
238
  }
24
239
  }
@@ -0,0 +1,73 @@
1
+ import { forwardRef } from 'react';
2
+ import LegacyButton, { LegacyButtonProps } from './LegacyButton';
3
+ import { ButtonReferenceType, ButtonProps as NewButtonProps } from './Button.types';
4
+ import NewButton from './Button';
5
+
6
+ export type ButtonProps = LegacyButtonProps | NewButtonProps;
7
+
8
+ const mapProps = (props: LegacyButtonProps): NewButtonProps => {
9
+ const { priority, size, type, ...newProps } = props;
10
+
11
+ const priorityMapping: Record<string, Record<string, NewButtonProps['priority']>> = {
12
+ accent: {
13
+ primary: 'primary',
14
+ secondary: 'tertiary',
15
+ tertiary: 'minimal',
16
+ },
17
+ positive: {
18
+ primary: 'primary',
19
+ secondary: 'tertiary',
20
+ tertiary: 'tertiary',
21
+ },
22
+ negative: {
23
+ primary: 'primary',
24
+ secondary: 'secondary',
25
+ tertiary: 'secondary',
26
+ },
27
+ };
28
+
29
+ const mappedPriority =
30
+ type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;
31
+ const mappedSentiment = type === 'negative' ? 'negative' : undefined;
32
+
33
+ const legacyButtonTypes: LegacyButtonProps['type'][] = [
34
+ 'accent',
35
+ 'negative',
36
+ 'positive',
37
+ 'primary',
38
+ 'pay',
39
+ 'secondary',
40
+ 'danger',
41
+ 'link',
42
+ ];
43
+
44
+ const resolveSize = () => {
45
+ if (size) {
46
+ return { xs: 'sm', sm: 'sm', md: 'md', lg: 'lg' }[size] || size;
47
+ }
48
+
49
+ return size;
50
+ };
51
+
52
+ return {
53
+ ...newProps,
54
+ size: resolveSize(),
55
+ priority: mappedPriority,
56
+ sentiment: mappedSentiment || ('sentiment' in props ? props.sentiment : null),
57
+ type: type && !legacyButtonTypes.includes(type) ? type : props.htmlType || null,
58
+ v2: true,
59
+ } as NewButtonProps;
60
+ };
61
+
62
+ const Button = forwardRef<ButtonReferenceType, ButtonProps>(({ v2 = false, ...props }, ref) => {
63
+ if (v2) {
64
+ const mappedProps = mapProps(props as LegacyButtonProps);
65
+ return <NewButton {...mappedProps} ref={ref} />;
66
+ }
67
+
68
+ return <LegacyButton {...(props as LegacyButtonProps)} ref={ref} />;
69
+ });
70
+
71
+ Button.displayName = 'Button';
72
+
73
+ export default Button;