@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
@@ -32,7 +32,8 @@ type AlertTypeResolved = `${
32
32
  | Sentiment.POSITIVE
33
33
  | Sentiment.NEUTRAL
34
34
  | Sentiment.WARNING
35
- | Sentiment.NEGATIVE}`;
35
+ | Sentiment.NEGATIVE
36
+ | Sentiment.CRITICAL}`;
36
37
  export type AlertType = AlertTypeResolved | AlertTypeDeprecated;
37
38
 
38
39
  export enum AlertArrowPosition {
@@ -63,6 +64,7 @@ export interface AlertProps {
63
64
  onDismiss?: React.MouseEventHandler<HTMLButtonElement>;
64
65
  /** The type dictates which icon and colour will be used */
65
66
  type?: AlertType;
67
+ /** @deprecated They both look and behave the same. */
66
68
  variant?: `${Variant}`;
67
69
  /** @deprecated Use `InlineAlert` instead. */
68
70
  arrow?: `${AlertArrowPosition}`;
@@ -152,9 +154,20 @@ export default function Alert({
152
154
 
153
155
  const closeButtonReference = useRef<HTMLButtonElement>(null);
154
156
 
157
+ const showButtonBelow = () => {
158
+ if (variant === 'desktop' && resolvedType === 'critical') {
159
+ return false;
160
+ }
161
+ return true;
162
+ };
163
+
155
164
  return (
156
165
  <div
157
- role={resolvedType === Sentiment.NEGATIVE ? 'alert' : 'status'}
166
+ role={
167
+ resolvedType === Sentiment.NEGATIVE || resolvedType === Sentiment.CRITICAL
168
+ ? 'alert'
169
+ : 'status'
170
+ }
158
171
  className="wds-alert__liveRegion"
159
172
  >
160
173
  <div
@@ -186,15 +199,13 @@ export default function Alert({
186
199
  }}
187
200
  onTouchMove={() => setShouldFire(false)}
188
201
  >
202
+ <div className="alert__icon">
203
+ {icon || <StatusIcon size={48} sentiment={resolvedType} iconLabel={statusIconLabel} />}
204
+ </div>
189
205
  <div
190
206
  className={clsx('alert__content', 'd-flex', 'flex-grow-1', variant)}
191
207
  data-testid={variant}
192
208
  >
193
- {icon ? (
194
- <div className="alert__icon">{icon}</div>
195
- ) : (
196
- <StatusIcon size={Size.LARGE} sentiment={resolvedType} iconLabel={statusIconLabel} />
197
- )}
198
209
  <div className="alert__message">
199
210
  <div>
200
211
  {title && (
@@ -206,9 +217,27 @@ export default function Alert({
206
217
  {children || <InlineMarkdown>{message}</InlineMarkdown>}
207
218
  </Body>
208
219
  </div>
209
- {action && <Action action={action} variant="action-button" className="m-t-1" />}
220
+ {action && showButtonBelow() && (
221
+ <Action
222
+ action={action}
223
+ variant="action-button"
224
+ className="m-t-2"
225
+ sentiment={type === 'critical' ? 'negative' : 'default'}
226
+ priority={type === 'critical' ? 'secondary' : 'tertiary'}
227
+ />
228
+ )}
210
229
  </div>
211
230
  </div>
231
+ {action && !showButtonBelow() && (
232
+ <div className="action__desktop">
233
+ <Action
234
+ action={action}
235
+ variant="action-button"
236
+ sentiment={type === 'critical' ? 'negative' : 'default'}
237
+ priority={type === 'critical' ? 'secondary' : 'tertiary'}
238
+ />
239
+ </div>
240
+ )}
212
241
  {onDismiss && (
213
242
  <CloseButton ref={closeButtonReference} className="m-l-2" onClick={onDismiss} />
214
243
  )}
@@ -11,10 +11,18 @@
11
11
  -webkit-mask-image: radial-gradient(circle at bottom calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)) right calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)), transparent 0, transparent calc(var(--np-avatar-size) / 2 + 2px), black 0);
12
12
  mask-image: radial-gradient(circle at bottom calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)) right calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)), transparent 0, transparent calc(var(--np-avatar-size) / 2 + 2px), black 0);
13
13
  }
14
+ [dir="rtl"] .np-avatar-layout-diagonal-mask {
15
+ -webkit-mask-image: radial-gradient(circle at bottom calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)) left calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)), transparent 0, transparent calc(var(--np-avatar-size) / 2 + 2px), black 0);
16
+ mask-image: radial-gradient(circle at bottom calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)) left calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)), transparent 0, transparent calc(var(--np-avatar-size) / 2 + 2px), black 0);
17
+ }
14
18
  .np-avatar-layout-diagonal-child {
15
19
  margin-left: calc(var(--np-avatar-layout-size) - var(--np-avatar-size) * 2);
16
20
  margin-top: calc(var(--np-avatar-layout-size) - var(--np-avatar-size));
17
21
  }
22
+ [dir="rtl"] .np-avatar-layout-diagonal-child {
23
+ margin-left: 0;
24
+ margin-right: calc(var(--np-avatar-layout-size) - var(--np-avatar-size) * 2);
25
+ }
18
26
  .np-avatar-layout-horizontal {
19
27
  width: calc(var(--np-avatar-size) * var(--np-avatar-avatars-count) - (var(--np-avatar-offset) * (var(--np-avatar-avatars-count) - 1)));
20
28
  width: calc(var(--np-avatar-size) * var(--np-avatar-avatars-count) - calc(var(--np-avatar-offset) * calc(var(--np-avatar-avatars-count) - 1)));
@@ -29,3 +37,6 @@
29
37
  .np-avatar-layout-horizontal-child {
30
38
  margin-left: calc(var(--np-avatar-offset) * -1);
31
39
  }
40
+ [dir="rtl"] .np-avatar-layout-horizontal-child {
41
+ margin-right: calc(var(--np-avatar-offset) * -1);
42
+ }
@@ -13,11 +13,24 @@
13
13
  transparent 0,
14
14
  transparent calc(var(--np-avatar-size) / 2 + 2px),
15
15
  black 0);
16
+
17
+ :dir(rtl) & {
18
+ mask-image:
19
+ radial-gradient(circle at bottom calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)) left calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)),
20
+ transparent 0,
21
+ transparent calc(var(--np-avatar-size) / 2 + 2px),
22
+ black 0);
23
+ }
16
24
  }
17
25
 
18
26
  &-child {
19
27
  margin-left: calc(var(--np-avatar-layout-size) - var(--np-avatar-size) * 2);
20
28
  margin-top: calc(var(--np-avatar-layout-size) - var(--np-avatar-size));
29
+
30
+ :dir(rtl) & {
31
+ margin-left: 0;
32
+ margin-right: calc(var(--np-avatar-layout-size) - var(--np-avatar-size) * 2);
33
+ }
21
34
  }
22
35
  }
23
36
 
@@ -34,6 +47,10 @@
34
47
 
35
48
  &-child {
36
49
  margin-left: calc(var(--np-avatar-offset) * -1);
50
+
51
+ :dir(rtl) & {
52
+ margin-right: calc(var(--np-avatar-offset) * -1);
53
+ }
37
54
  }
38
55
  }
39
- }
56
+ }
@@ -1,5 +1,6 @@
1
1
  import { clsx } from 'clsx';
2
2
  import AvatarView, { AvatarViewProps } from '../avatarView';
3
+ import { useDirection } from '../common/hooks';
3
4
 
4
5
  type SingleAvatarType = { asset?: AvatarViewProps['children'] } & Omit<
5
6
  AvatarViewProps,
@@ -24,6 +25,7 @@ export default function AvatarLayout({
24
25
  }: Props) {
25
26
  const orientation =
26
27
  size === 16 && orientationProp === 'diagonal' ? 'horizontal' : orientationProp;
28
+ const { isRTL } = useDirection();
27
29
  const isDiagonal = orientation === 'diagonal';
28
30
  const avatarSize = isDiagonal ? DIAGONAL_LAYOUT_STYLE_CONFIG[size]?.avatarSize : size;
29
31
  return avatars.length < 1 ? null : avatars.length === 1 ? (
@@ -47,8 +49,14 @@ export default function AvatarLayout({
47
49
  // eslint-disable-next-line react/no-array-index-key
48
50
  key={index}
49
51
  className={clsx(
50
- { [`np-avatar-layout-${orientation}-child`]: index !== 0 },
51
- { [`np-avatar-layout-${orientation}-mask`]: index !== avatars.length - 1 },
52
+ {
53
+ [`np-avatar-layout-${orientation}-child`]:
54
+ !isDiagonal && isRTL ? index !== avatars.length - 1 : index !== 0,
55
+ },
56
+ {
57
+ [`np-avatar-layout-${orientation}-mask`]:
58
+ !isDiagonal && isRTL ? index !== 0 : index !== avatars.length - 1,
59
+ },
52
60
  )}
53
61
  >
54
62
  <AvatarView
@@ -0,0 +1,103 @@
1
+ import { Meta, Canvas, Source } from '@storybook/blocks';
2
+ import { NavigationOption } from '..';
3
+ import { Bulb } from '@transferwise/icons';
4
+ import * as stories from './Button.story';
5
+
6
+ <Meta title="Actions/Button/Accessibility" />
7
+
8
+ # Accessibility
9
+
10
+ Given the `Button` is a widely used and highly sensitive component, there are some instances where care is required to ensure inclusive and accessible experience.
11
+
12
+ <NavigationOption
13
+ media={<Bulb size={24} />}
14
+ title="Design guidance"
15
+ content="Before you start, familiarise yourself with the dedicated accessibility documentation."
16
+ href="https://wise.design/components/button#accessibility"
17
+ />
18
+
19
+ <br />
20
+ <br />
21
+
22
+ ## Anchors
23
+
24
+ While it's technically possible to make the `Button` component render as a link by using `as="a"` on its own, and there are use cases for it, this will not result in a semantic HTML anchor. For that to happen, you should set `href` instead – it will automatically render the component as a semantic anchor.
25
+
26
+ <Source dark code={`
27
+ // ⚠️ use with care
28
+ <Button v2 as="a">Inaccessible anchor</Button>
29
+
30
+ // ✅ semantic link
31
+
32
+ <Button v2 href="https://wise.com">
33
+ Accessible anchor
34
+ </Button>
35
+ <Button v2 href="https://wise.com" as="a">
36
+ Accessible anchor
37
+ </Button>
38
+ `}/>
39
+
40
+ It's also worth noting that HTML links without a valid `href` are not recognised by RTL via `getByRole('link')`.
41
+
42
+ **Additional resources:**
43
+
44
+ 1. [Deque: Anchors must only be used as links with valid URLs or URL fragments](https://dequeuniversity.com/rules/axe-devtools/4.2/href-no-hash)
45
+ 2. [whatwg HTML standard: 4.6.2 Links created by a and area elements](https://html.spec.whatwg.org/multipage/links.html#links-created-by-a-and-area-elements)
46
+
47
+ <br />
48
+
49
+ ## Disabled anchors
50
+
51
+ Technically, there's no such thing as disabled HTML anchor and the `disabled` attribute is not recognised on the `<a />`. While the code shown below works in all major screen readers, should be overall considered a last resort and design teams should be encouraged to use it sporadically and consider alternative flows instead.
52
+
53
+ <Source
54
+ dark
55
+ code={`
56
+ // ⚠️ use with care
57
+ <Button v2 href="https://wise.com" disabled>Emulated disabled anchor</Button>
58
+ `}
59
+ />
60
+
61
+ We're emulating this behaviour by applying a combination of the following:
62
+
63
+ 1. removing `href` attribute to strip out the link's semantics.
64
+ 2. adding `role="link"` to make it recognisable and discoverable by the assistive tech.
65
+ 3. setting `aria-disabled="true"` to inform assistive tech of the component state.
66
+
67
+ **Additional resources:**
68
+
69
+ 1. [Scott O'Hara: Disabling a link](https://www.scottohara.me/blog/2021/05/28/disabled-links.html)
70
+ 2. [CSS-Tricks: How to Disable Links](https://css-tricks.com/how-to-disable-links/)
71
+
72
+ <br />
73
+
74
+ ## Loading state
75
+
76
+ While it might be tempting to use the native, HTML `disabled` attribute for the `loading` state, it would result in a component that is completely invisible to the assistive tech – not focusable and not parsable – entirely inaccessible experience for users relying on such tools.
77
+
78
+ Instead, we're relying on ARIA attributes and roles to ensure the `Button` is focusable, correctly announced as "busy" and offering visual cue different to the disabled state.
79
+
80
+ <Source dark code={`
81
+ // ❌ do not use
82
+ <Button v2 loading disabled>Invisible</Button>
83
+
84
+ // ✅ semantic loading button
85
+
86
+ <Button v2 loading>
87
+ Proper loading state
88
+ </Button>
89
+ `}/>
90
+
91
+ `Button` instances rendered as HTML anchors, follow the strategy described in the [Disabled anchors](#disabled-anchors) section above.
92
+
93
+ <br />
94
+
95
+ ## Working with addons (accessories)
96
+
97
+ One of the core requirements of accessible experience is that all users have equal access to the same content, no matter how they interact with our products.
98
+
99
+ This becomes troublesome for more complex instances of the `Button` such as those with contentful icons or avatars, e.g. those referring to particular currencies, people or action types.
100
+
101
+ Exposing separate ARIA labels for such addons would likely become problematic due to syntactic differences between different languages and so instead we recommend using simple `aria-label` attribute to describe given components complete content. Please note, that screen readers will use that text over the visible label
102
+
103
+ <Canvas of={stories.AccessibilityAddons} />
@@ -1,23 +1,228 @@
1
- .np-btn {
1
+ .wds-Button {
2
+ --Button-background: var(--color-interactive-accent);
3
+ --Button-background-hover: var(--color-interactive-accent-hover);
4
+ --Button-background-active: var(--color-interactive-accent-active);
5
+ --Button-color: var(--color-interactive-control);
6
+ --Button-border-radius: var(--radius-full);
7
+ --Button-label-gap: var(--size-4);
8
+ --Button-large-padding: var(--size-12) var(--size-16);
9
+ --Button-medium-padding: var(--size-8) var(--size-12);
10
+ --Button-small-padding: var(--size-5) var(--size-12);
11
+ --Button-avatar-border-color: var(--color-border-neutral);
12
+ --Button-transition-duration: 150ms;
13
+ --Button-transition-easing: ease-in-out;
14
+ --Button-secondary-background: var(--color-interactive-neutral);
15
+ --Button-secondary-background-hover: var(--color-interactive-neutral-hover);
16
+ --Button-secondary-background-active: var(--color-interactive-neutral-active);
17
+ --Button-secondary-color: var(--color-interactive-primary);
18
+ --Button-tertiary-background: var(--color-background-neutral);
19
+ --Button-tertiary-background-hover: var(--color-background-neutral-hover);
20
+ --Button-tertiary-background-active: var(--color-background-neutral-active);
21
+ --Button-tertiary-color: var(--color-content-primary);
22
+ --Button-minimal-background: transparent;
23
+ --Button-minimal-background-hover: var(--color-background-screen-hover);
24
+ --Button-minimal-background-active: var(--color-background-screen-active);
25
+ --Button-minimal-color: var(--color-interactive-primary);
26
+ --Button-primary-negative-background: var(--color-sentiment-negative-primary);
27
+ --Button-primary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
28
+ --Button-primary-negative-background-active: var(--color-sentiment-negative-primary-active);
29
+ --Button-primary-negative-color: var(--color-contrast-overlay);
30
+ --Button-secondary-negative-background: var(--color-sentiment-negative-secondary);
31
+ --Button-secondary-negative-background-hover: var(--color-sentiment-negative-secondary-hover);
32
+ --Button-secondary-negative-background-active: var(--color-sentiment-negative-secondary-active);
33
+ --Button-secondary-negative-color: var(--color-sentiment-negative-primary);
34
+ }
35
+ .np-theme-personal--bright-green .wds-Button {
36
+ --Button-primary-negative-color: var(--color-white);
37
+ --Button-secondary-color: var(--color-interactive-control);
38
+ --Button-secondary-negative-color: var(--color-white);
39
+ }
40
+ .np-theme-personal--forest-green .wds-Button {
41
+ --Button-secondary-background: var(--color-interactive-neutral);
42
+ --Button-secondary-negative-background: var(--color-sentiment-negative-primary);
43
+ --Button-secondary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
44
+ --Button-secondary-negative-background-active: var(--color-sentiment-negative-primary-active);
45
+ --Button-secondary-negative-color: var(--color-contrast-overlay);
46
+ }
47
+ /* Button Styles */
48
+ .wds-Button {
49
+ display: inline-flex;
50
+ flex: none;
51
+ width: auto;
52
+ align-items: center;
53
+ justify-content: center;
54
+ vertical-align: middle;
55
+ text-align: center;
56
+ white-space: nowrap;
57
+ word-wrap: break-word;
58
+ -webkit-appearance: none;
59
+ -moz-appearance: none;
60
+ appearance: none;
61
+ background-color: var(--Button-background);
62
+ border: none;
63
+ border-radius: var(--Button-border-radius);
64
+ color: var(--Button-color);
65
+ cursor: pointer;
66
+ transition: color, background-color var(--Button-transition-duration) var(--Button-transition-easing);
67
+ }
68
+ .wds-Button,
69
+ .wds-Button:hover,
70
+ .wds-Button:active,
71
+ .wds-Button:focus {
72
+ -webkit-text-decoration: none;
73
+ text-decoration: none;
74
+ }
75
+ .wds-Button:hover {
76
+ background-color: var(--Button-background-hover);
77
+ }
78
+ .wds-Button:active {
79
+ background-color: var(--Button-background-active);
80
+ }
81
+ .wds-Button.wds-Button--disabled,
82
+ .wds-Button:disabled {
83
+ filter: none;
84
+ mix-blend-mode: luminosity;
85
+ opacity: 0.45;
86
+ cursor: not-allowed;
87
+ }
88
+ .wds-Button.wds-Button--disabled,
89
+ .wds-Button:disabled,
90
+ .wds-Button.wds-Button--disabled:hover,
91
+ .wds-Button:disabled:hover,
92
+ .wds-Button.wds-Button--disabled:active,
93
+ .wds-Button:disabled:active {
94
+ background-color: var(--Button-background);
95
+ }
96
+ .wds-Button--secondary {
97
+ --Button-background: var(--Button-secondary-background);
98
+ --Button-background-hover: var(--Button-secondary-background-hover);
99
+ --Button-background-active: var(--Button-secondary-background-active);
100
+ --Button-color: var(--Button-secondary-color);
101
+ }
102
+ .wds-Button--tertiary {
103
+ --Button-background: var(--Button-tertiary-background);
104
+ --Button-background-hover: var(--Button-tertiary-background-hover);
105
+ --Button-background-active: var(--Button-tertiary-background-active);
106
+ --Button-color: var(--Button-tertiary-color);
107
+ }
108
+ .wds-Button--tertiary .wds-Button-icon--end {
109
+ color: var(--color-interactive-primary);
110
+ }
111
+ .wds-Button--minimal {
112
+ --Button-background: var(--Button-minimal-background);
113
+ --Button-background-hover: var(--Button-minimal-background-hover);
114
+ --Button-background-active: var(--Button-minimal-background-active);
115
+ --Button-color: var(--Button-minimal-color);
116
+ }
117
+ .wds-Button--minimal,
118
+ .wds-Button--minimal:hover,
119
+ .wds-Button--minimal:active,
120
+ .wds-Button--minimal:focus {
121
+ -webkit-text-decoration: underline;
122
+ text-decoration: underline;
123
+ text-underline-offset: 3px;
124
+ text-decoration-thickness: 1px;
125
+ }
126
+ .wds-Button--negative.wds-Button--primary {
127
+ --Button-background: var(--Button-primary-negative-background);
128
+ --Button-background-hover: var(--Button-primary-negative-background-hover);
129
+ --Button-background-active: var(--Button-primary-negative-background-active);
130
+ --Button-color: var(--Button-primary-negative-color);
131
+ }
132
+ .wds-Button--negative.wds-Button--secondary {
133
+ --Button-background: var(--Button-secondary-negative-background);
134
+ --Button-background-hover: var(--Button-secondary-negative-background-hover);
135
+ --Button-background-active: var(--Button-secondary-negative-background-active);
136
+ --Button-color: var(--Button-secondary-negative-color);
137
+ }
138
+ .wds-Button--large {
139
+ padding: var(--Button-large-padding);
140
+ }
141
+ .wds-Button--medium {
142
+ padding: var(--Button-medium-padding);
143
+ }
144
+ .wds-Button--medium:has(.wds-Button-avatars) {
145
+ padding-inline-start: 8px;
146
+ padding-inline-start: var(--size-8);
147
+ }
148
+ .wds-Button--medium:has(.wds-Button-icon--end) {
149
+ padding-inline-end: 8px;
150
+ padding-inline-end: var(--size-8);
151
+ }
152
+ .wds-Button--medium .wds-Button-icon--start {
153
+ margin-inline-end: var(--Button-label-gap);
154
+ }
155
+ .wds-Button--small {
156
+ padding: var(--Button-small-padding);
157
+ }
158
+ .wds-Button--small:has(.wds-Button-icon--start) {
159
+ padding-inline-start: 8px;
160
+ padding-inline-start: var(--size-8);
161
+ }
162
+ .wds-Button--small:has(.wds-Button-icon--end) {
163
+ padding-inline-end: 8px;
164
+ padding-inline-end: var(--size-8);
165
+ }
166
+ .wds-Button--block {
167
+ width: 100%;
168
+ }
169
+ .wds-Button-avatars {
170
+ display: inline-flex;
171
+ }
172
+ .wds-Button-avatars .np-avatar-view .np-avatar-view-content {
173
+ color: var(--Button-color);
174
+ }
175
+ .wds-Button-icon {
176
+ display: inline-block;
177
+ }
178
+ .wds-Button-content {
179
+ position: relative;
180
+ }
181
+ .wds-Button-content--loading .wds-Button-label,
182
+ .wds-Button-content--loading .wds-Button-media,
183
+ .wds-Button-content--loading .wds-Button-icon {
184
+ visibility: hidden;
185
+ opacity: 0;
186
+ }
187
+ .wds-Button-label {
188
+ display: flex;
189
+ justify-content: center;
190
+ align-items: center;
191
+ gap: var(--Button-label-gap);
2
192
  position: relative;
3
193
  }
4
- .np-btn.np-btn-block > span.btn-loader {
194
+ .wds-Button-loader {
5
195
  position: absolute;
6
- left: 24px;
7
- left: var(--size-24);
196
+ width: 100%;
197
+ height: 100%;
198
+ }
199
+ .wds-Button-loader .process-circle {
200
+ stroke: var(--Button-color);
201
+ }
202
+ /* Avatar border transparency */
203
+ /* dark buttons get 20% transparency, light buttons get 12% */
204
+ .wds-Button-avatars .np-circle {
205
+ --circle-border-color: color-mix(in srgb, var(--Button-color) 20%, transparent);
206
+ }
207
+ .np-theme-personal:not(.np-theme-personal--dark):not(.np-theme-personal--forest-green):not(.np-theme-personal--bright-green) .wds-Button--secondary.wds-Button--negative .wds-Button-avatars .np-circle,
208
+ .np-theme-personal:not(.np-theme-personal--dark):not(.np-theme-personal--forest-green):not(.np-theme-personal--bright-green) .wds-Button--secondary .wds-Button-avatars .np-circle,
209
+ .np-theme-personal:not(.np-theme-personal--dark):not(.np-theme-personal--forest-green):not(.np-theme-personal--bright-green) .wds-Button--tertiary .wds-Button-avatars .np-circle,
210
+ .np-theme-personal:not(.np-theme-personal--dark):not(.np-theme-personal--forest-green):not(.np-theme-personal--bright-green) .wds-Button--minimal .wds-Button-avatars .np-circle {
211
+ --circle-border-color: color-mix(in srgb, var(--Button-color) 12%, transparent);
8
212
  }
9
- [dir="rtl"] .np-btn.np-btn-block > span.btn-loader {
10
- right: 24px;
11
- right: var(--size-24);
12
- left: auto;
13
- left: initial;
213
+ .np-theme-personal--dark .wds-Button--primary .wds-Button-avatars .np-circle,
214
+ .np-theme-personal--dark .wds-Button--primary.wds-Button--negative .wds-Button-avatars .np-circle,
215
+ .np-theme-personal--forest-green .wds-Button--primary .wds-Button-avatars .np-circle,
216
+ .np-theme-personal--forest-green .wds-Button--primary.wds-Button--negative .wds-Button-avatars .np-circle {
217
+ --circle-border-color: color-mix(in srgb, var(--Button-color) 12%, transparent);
14
218
  }
15
- .np-btn.np-btn-xs > span.btn-loader {
16
- background-size: 16px 16px;
219
+ .np-theme-personal--bright-green .wds-Button--tertiary .wds-Button-avatars .np-circle,
220
+ .np-theme-personal--bright-green .wds-Button--minimal .wds-Button-avatars .np-circle {
221
+ --circle-border-color: color-mix(in srgb, var(--Button-color) 12%, transparent);
17
222
  }
18
- .np-btn.np-btn-xs.btn-block > span.btn-loader {
19
- top: 0;
223
+ .critical-comms .wds-Button {
224
+ --Button-background: var(--color-contrast-overlay);
20
225
  }
21
- .np-btn.disabled[class] {
22
- pointer-events: auto;
226
+ [dir="rtl"] .wds-Button .tw-icon-chevron-right,[dir="rtl"] .wds-Button .tw-icon-arrow-right,[dir="rtl"] .wds-Button .tw-icon-chevron-left,[dir="rtl"] .wds-Button .tw-icon-arrow-left,[dir="rtl"] .wds-Button .tw-icon-arrow-diagonal-down,[dir="rtl"] .wds-Button .tw-icon-arrow-diagonal-up,[dir="rtl"] .wds-Button .tw-icon-list,[dir="rtl"] .wds-Button .tw-icon-activity {
227
+ scale: -1 1;
23
228
  }