@transferwise/components 46.87.1 → 46.88.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/avatarLayout/AvatarLayout.js +9 -2
- package/build/avatarLayout/AvatarLayout.js.map +1 -1
- package/build/avatarLayout/AvatarLayout.mjs +9 -2
- package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
- package/build/button/Button.js +92 -79
- package/build/button/Button.js.map +1 -1
- package/build/button/Button.mjs +93 -80
- package/build/button/Button.mjs.map +1 -1
- package/build/button/Button.resolver.js +74 -0
- package/build/button/Button.resolver.js.map +1 -0
- package/build/button/Button.resolver.mjs +72 -0
- package/build/button/Button.resolver.mjs.map +1 -0
- package/build/button/LegacyButton.js +114 -0
- package/build/button/LegacyButton.js.map +1 -0
- package/build/button/LegacyButton.mjs +112 -0
- package/build/button/LegacyButton.mjs.map +1 -0
- package/build/circularButton/CircularButton.js.map +1 -1
- package/build/circularButton/CircularButton.mjs.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.js +2 -2
- package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
- package/build/header/Header.js +2 -2
- package/build/header/Header.js.map +1 -1
- package/build/header/Header.mjs +1 -1
- package/build/i18n/ja.json +1 -0
- package/build/i18n/ja.json.js +1 -0
- package/build/i18n/ja.json.js.map +1 -1
- package/build/i18n/ja.json.mjs +1 -0
- package/build/i18n/ja.json.mjs.map +1 -1
- package/build/i18n/pt.json +1 -0
- package/build/i18n/pt.json.js +1 -0
- package/build/i18n/pt.json.js.map +1 -1
- package/build/i18n/pt.json.mjs +1 -0
- package/build/i18n/pt.json.mjs.map +1 -1
- package/build/i18n/ru.json +1 -0
- package/build/i18n/ru.json.js +1 -0
- package/build/i18n/ru.json.js.map +1 -1
- package/build/i18n/ru.json.mjs +1 -0
- package/build/i18n/ru.json.mjs.map +1 -1
- package/build/i18n/zh-HK.json +1 -0
- package/build/i18n/zh-HK.json.js +1 -0
- package/build/i18n/zh-HK.json.js.map +1 -1
- package/build/i18n/zh-HK.json.mjs +1 -0
- package/build/i18n/zh-HK.json.mjs.map +1 -1
- package/build/index.js +2 -2
- package/build/index.mjs +1 -1
- package/build/link/Link.js +8 -3
- package/build/link/Link.js.map +1 -1
- package/build/link/Link.mjs +8 -3
- package/build/link/Link.mjs.map +1 -1
- package/build/main.css +247 -0
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +2 -4
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +2 -4
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +3 -5
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +3 -5
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
- package/build/select/Select.js +2 -2
- package/build/select/Select.js.map +1 -1
- package/build/select/Select.mjs +1 -1
- package/build/styles/avatarLayout/AvatarLayout.css +11 -0
- package/build/styles/button/Button.css +228 -15
- package/build/styles/button/Button.vars.css +46 -0
- package/build/styles/button/LegacyButton.css +23 -0
- package/build/styles/main.css +247 -0
- package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
- package/build/types/button/Button.d.ts +2 -23
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/button/Button.resolver.d.ts +35 -0
- package/build/types/button/Button.resolver.d.ts.map +1 -0
- package/build/types/button/Button.types.d.ts +70 -0
- package/build/types/button/Button.types.d.ts.map +1 -0
- package/build/types/button/LegacyButton.d.ts +44 -0
- package/build/types/button/LegacyButton.d.ts.map +1 -0
- package/build/types/button/index.d.ts +2 -2
- package/build/types/button/index.d.ts.map +1 -1
- package/build/types/circularButton/CircularButton.d.ts.map +1 -1
- package/build/types/link/Link.d.ts +2 -2
- package/build/types/link/Link.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +6 -2
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
- package/build/types/test-utils/story-config.d.ts +1 -1
- package/build/types/test-utils/story-config.d.ts.map +1 -1
- package/build/upload/steps/completeStep/completeStep.js +2 -2
- package/build/upload/steps/completeStep/completeStep.js.map +1 -1
- package/build/upload/steps/completeStep/completeStep.mjs +1 -1
- package/build/upload/steps/processingStep/processingStep.js +2 -2
- package/build/upload/steps/processingStep/processingStep.js.map +1 -1
- package/build/upload/steps/processingStep/processingStep.mjs +1 -1
- package/build/uploadInput/UploadInput.js +3 -3
- package/build/uploadInput/UploadInput.js.map +1 -1
- package/build/uploadInput/UploadInput.mjs +1 -1
- package/package.json +2 -2
- package/src/alert/Alert.tests.story.tsx +1 -1
- package/src/avatar/Avatar.story.tsx +1 -1
- package/src/avatarLayout/AvatarLayout.css +11 -0
- package/src/avatarLayout/AvatarLayout.less +18 -1
- package/src/avatarLayout/AvatarLayout.tsx +10 -2
- package/src/avatarWrapper/AvatarWrapper.story.tsx +1 -1
- package/src/badge/Badge.story.tsx +1 -1
- package/src/button/Button.accessibility.docs.mdx +103 -0
- package/src/button/Button.css +228 -15
- package/src/button/Button.less +242 -14
- package/src/button/Button.resolver.tsx +73 -0
- package/src/button/Button.spec.tsx +329 -213
- package/src/button/Button.story.tsx +782 -134
- package/src/button/Button.tests.story.tsx +27 -0
- package/src/button/Button.tsx +103 -132
- package/src/button/Button.types.ts +92 -0
- package/src/button/Button.vars.css +46 -0
- package/src/button/Button.vars.less +59 -0
- package/src/button/LegacyButton.css +23 -0
- package/src/button/LegacyButton.less +24 -0
- package/src/button/LegacyButton.spec.tsx +147 -0
- package/src/button/LegacyButton.story.tsx +228 -0
- package/src/button/LegacyButton.tsx +177 -0
- package/src/button/index.ts +2 -3
- package/src/card/Card.story.tsx +6 -1
- package/src/circularButton/CircularButton.tsx +1 -0
- package/src/field/Field.story.tsx +1 -1
- package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -2
- package/src/i18n/ja.json +1 -0
- package/src/i18n/pt.json +1 -0
- package/src/i18n/ru.json +1 -0
- package/src/i18n/zh-HK.json +1 -0
- package/src/inputs/SelectInput.story.tsx +1 -1
- package/src/label/Label.story.tsx +1 -1
- package/src/link/Link.tsx +15 -6
- package/src/main.css +247 -0
- package/src/main.less +1 -0
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +2 -8
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +7 -2
- package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +1 -3
- package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +4 -12
- package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +16 -13
- package/src/select/Select.story.tsx +4 -1
- package/src/test-utils/Parameters.d.ts +9 -1
- package/src/test-utils/story-config.ts +10 -1
- package/src/button/__snapshots__/Button.spec.tsx.snap +0 -309
|
@@ -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
|
-
{
|
|
51
|
-
|
|
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
|
|
@@ -10,7 +10,7 @@ import AvatarWrapper from './AvatarWrapper';
|
|
|
10
10
|
export default {
|
|
11
11
|
tags: ['autodocs'],
|
|
12
12
|
component: AvatarWrapper,
|
|
13
|
-
title: 'Content/AvatarWrapper',
|
|
13
|
+
title: 'Content/AvatarWrapper (Deprecated)',
|
|
14
14
|
} satisfies Meta<typeof AvatarWrapper>;
|
|
15
15
|
|
|
16
16
|
type Story = StoryObj<typeof AvatarWrapper>;
|
|
@@ -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} />
|
package/src/button/Button.css
CHANGED
|
@@ -1,23 +1,236 @@
|
|
|
1
|
-
.
|
|
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-secondary-neutral-background: var(--color-background-neutral);
|
|
19
|
+
--Button-secondary-neutral-background-hover: var(--color-background-neutral-hover);
|
|
20
|
+
--Button-secondary-neutral-background-active: var(--color-background-neutral-active);
|
|
21
|
+
--Button-secondary-neutral-color: var(--color-content-primary);
|
|
22
|
+
--Button-tertiary-background: transparent;
|
|
23
|
+
--Button-tertiary-background-hover: var(--color-background-screen-hover);
|
|
24
|
+
--Button-tertiary-background-active: var(--color-background-screen-active);
|
|
25
|
+
--Button-tertiary-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
|
+
color: var(--Button-color);
|
|
75
|
+
}
|
|
76
|
+
.wds-Button:hover {
|
|
77
|
+
background-color: var(--Button-background-hover);
|
|
78
|
+
}
|
|
79
|
+
.wds-Button:active {
|
|
80
|
+
background-color: var(--Button-background-active);
|
|
81
|
+
}
|
|
82
|
+
.wds-Button.wds-Button--disabled,
|
|
83
|
+
.wds-Button:disabled {
|
|
84
|
+
filter: none;
|
|
85
|
+
mix-blend-mode: luminosity;
|
|
86
|
+
opacity: 0.45;
|
|
87
|
+
cursor: not-allowed;
|
|
88
|
+
}
|
|
89
|
+
.wds-Button.wds-Button--disabled,
|
|
90
|
+
.wds-Button:disabled,
|
|
91
|
+
.wds-Button.wds-Button--disabled:hover,
|
|
92
|
+
.wds-Button:disabled:hover,
|
|
93
|
+
.wds-Button.wds-Button--disabled:active,
|
|
94
|
+
.wds-Button:disabled:active {
|
|
95
|
+
background-color: var(--Button-background);
|
|
96
|
+
}
|
|
97
|
+
.wds-Button--secondary {
|
|
98
|
+
--Button-background: var(--Button-secondary-background);
|
|
99
|
+
--Button-background-hover: var(--Button-secondary-background-hover);
|
|
100
|
+
--Button-background-active: var(--Button-secondary-background-active);
|
|
101
|
+
--Button-color: var(--Button-secondary-color);
|
|
102
|
+
}
|
|
103
|
+
.wds-Button--secondary-neutral {
|
|
104
|
+
--Button-background: var(--Button-secondary-neutral-background);
|
|
105
|
+
--Button-background-hover: var(--Button-secondary-neutral-background-hover);
|
|
106
|
+
--Button-background-active: var(--Button-secondary-neutral-background-active);
|
|
107
|
+
--Button-color: var(--Button-secondary-neutral-color);
|
|
108
|
+
}
|
|
109
|
+
.wds-Button--secondary-neutral .wds-Button-icon--end {
|
|
110
|
+
color: var(--color-interactive-primary);
|
|
111
|
+
}
|
|
112
|
+
.wds-Button--tertiary {
|
|
113
|
+
--Button-background: var(--Button-tertiary-background);
|
|
114
|
+
--Button-background-hover: var(--Button-tertiary-background-hover);
|
|
115
|
+
--Button-background-active: var(--Button-tertiary-background-active);
|
|
116
|
+
--Button-color: var(--Button-tertiary-color);
|
|
117
|
+
}
|
|
118
|
+
.wds-Button--tertiary .wds-Button-labelText,
|
|
119
|
+
.wds-Button--tertiary:hover .wds-Button-labelText,
|
|
120
|
+
.wds-Button--tertiary:active .wds-Button-labelText,
|
|
121
|
+
.wds-Button--tertiary:focus .wds-Button-labelText {
|
|
122
|
+
-webkit-text-decoration: underline;
|
|
123
|
+
text-decoration: underline;
|
|
124
|
+
text-underline-offset: 3px;
|
|
125
|
+
text-decoration-thickness: 1px;
|
|
126
|
+
}
|
|
127
|
+
.wds-Button--negative.wds-Button--primary {
|
|
128
|
+
--Button-background: var(--Button-primary-negative-background);
|
|
129
|
+
--Button-background-hover: var(--Button-primary-negative-background-hover);
|
|
130
|
+
--Button-background-active: var(--Button-primary-negative-background-active);
|
|
131
|
+
--Button-color: var(--Button-primary-negative-color);
|
|
132
|
+
}
|
|
133
|
+
.wds-Button--negative.wds-Button--secondary {
|
|
134
|
+
--Button-background: var(--Button-secondary-negative-background);
|
|
135
|
+
--Button-background-hover: var(--Button-secondary-negative-background-hover);
|
|
136
|
+
--Button-background-active: var(--Button-secondary-negative-background-active);
|
|
137
|
+
--Button-color: var(--Button-secondary-negative-color);
|
|
138
|
+
}
|
|
139
|
+
.wds-Button--large {
|
|
140
|
+
padding: var(--Button-large-padding);
|
|
141
|
+
}
|
|
142
|
+
.wds-Button--medium {
|
|
143
|
+
padding: var(--Button-medium-padding);
|
|
144
|
+
}
|
|
145
|
+
.wds-Button--medium:has(.wds-Button-avatars) {
|
|
146
|
+
padding-inline-start: 8px;
|
|
147
|
+
padding-inline-start: var(--size-8);
|
|
148
|
+
}
|
|
149
|
+
.wds-Button--medium:has(.wds-Button-icon--end) {
|
|
150
|
+
padding-inline-end: 8px;
|
|
151
|
+
padding-inline-end: var(--size-8);
|
|
152
|
+
}
|
|
153
|
+
.wds-Button--medium .wds-Button-icon--start {
|
|
154
|
+
margin-inline-end: var(--Button-label-gap);
|
|
155
|
+
}
|
|
156
|
+
.wds-Button--small {
|
|
157
|
+
padding: var(--Button-small-padding);
|
|
158
|
+
}
|
|
159
|
+
.wds-Button--small:has(.wds-Button-icon--start) {
|
|
160
|
+
padding-inline-start: 8px;
|
|
161
|
+
padding-inline-start: var(--size-8);
|
|
162
|
+
}
|
|
163
|
+
.wds-Button--small:has(.wds-Button-icon--end) {
|
|
164
|
+
padding-inline-end: 8px;
|
|
165
|
+
padding-inline-end: var(--size-8);
|
|
166
|
+
}
|
|
167
|
+
.wds-Button--block {
|
|
168
|
+
width: 100%;
|
|
169
|
+
}
|
|
170
|
+
.wds-Button-avatars {
|
|
171
|
+
display: inline-flex;
|
|
172
|
+
}
|
|
173
|
+
.wds-Button-avatars .np-avatar-view .np-avatar-view-content {
|
|
174
|
+
color: var(--Button-color);
|
|
175
|
+
}
|
|
176
|
+
.wds-Button-icon {
|
|
177
|
+
display: inline-block;
|
|
178
|
+
}
|
|
179
|
+
.wds-Button-icon--md {
|
|
180
|
+
--Button-iconSize: calc(var(--size-10) + var(--size-8));
|
|
181
|
+
}
|
|
182
|
+
.wds-Button-icon--sm {
|
|
183
|
+
--Button-iconSize: var(--size-16);
|
|
184
|
+
}
|
|
185
|
+
.wds-Button-icon svg {
|
|
186
|
+
width: var(--Button-iconSize);
|
|
187
|
+
height: var(--Button-iconSize);
|
|
188
|
+
}
|
|
189
|
+
.wds-Button-content {
|
|
2
190
|
position: relative;
|
|
3
191
|
}
|
|
4
|
-
.
|
|
192
|
+
.wds-Button-content--loading .wds-Button-label,
|
|
193
|
+
.wds-Button-content--loading .wds-Button-media,
|
|
194
|
+
.wds-Button-content--loading .wds-Button-icon {
|
|
195
|
+
visibility: hidden;
|
|
196
|
+
opacity: 0;
|
|
197
|
+
}
|
|
198
|
+
.wds-Button-label {
|
|
199
|
+
display: flex;
|
|
200
|
+
justify-content: center;
|
|
201
|
+
align-items: center;
|
|
202
|
+
gap: var(--Button-label-gap);
|
|
203
|
+
position: relative;
|
|
204
|
+
}
|
|
205
|
+
.wds-Button-loader {
|
|
5
206
|
position: absolute;
|
|
6
|
-
|
|
7
|
-
|
|
207
|
+
width: 100%;
|
|
208
|
+
height: 100%;
|
|
209
|
+
}
|
|
210
|
+
.wds-Button-loader .process-circle {
|
|
211
|
+
stroke: var(--Button-color);
|
|
212
|
+
}
|
|
213
|
+
/* Avatar border transparency */
|
|
214
|
+
/* dark buttons get 20% transparency, light buttons get 12% */
|
|
215
|
+
.wds-Button-avatars .np-circle {
|
|
216
|
+
--circle-border-color: color-mix(in srgb, var(--Button-color) 20%, transparent);
|
|
8
217
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
218
|
+
.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,
|
|
219
|
+
.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,
|
|
220
|
+
.np-theme-personal:not(.np-theme-personal--dark):not(.np-theme-personal--forest-green):not(.np-theme-personal--bright-green) .wds-Button--secondary-neutral .wds-Button-avatars .np-circle,
|
|
221
|
+
.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 {
|
|
222
|
+
--circle-border-color: color-mix(in srgb, var(--Button-color) 12%, transparent);
|
|
14
223
|
}
|
|
15
|
-
.np-
|
|
16
|
-
|
|
224
|
+
.np-theme-personal--dark .wds-Button--primary .wds-Button-avatars .np-circle,
|
|
225
|
+
.np-theme-personal--dark .wds-Button--primary.wds-Button--negative .wds-Button-avatars .np-circle,
|
|
226
|
+
.np-theme-personal--forest-green .wds-Button--primary .wds-Button-avatars .np-circle,
|
|
227
|
+
.np-theme-personal--forest-green .wds-Button--primary.wds-Button--negative .wds-Button-avatars .np-circle {
|
|
228
|
+
--circle-border-color: color-mix(in srgb, var(--Button-color) 12%, transparent);
|
|
17
229
|
}
|
|
18
|
-
.np-
|
|
19
|
-
|
|
230
|
+
.np-theme-personal--bright-green .wds-Button--tertiary .wds-Button-avatars .np-circle,
|
|
231
|
+
.np-theme-personal--bright-green .wds-Button--secondary-neutral .wds-Button-avatars .np-circle {
|
|
232
|
+
--circle-border-color: color-mix(in srgb, var(--Button-color) 12%, transparent);
|
|
20
233
|
}
|
|
21
|
-
.
|
|
22
|
-
|
|
234
|
+
[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 {
|
|
235
|
+
scale: -1 1;
|
|
23
236
|
}
|
package/src/button/Button.less
CHANGED
|
@@ -1,24 +1,252 @@
|
|
|
1
|
-
@import
|
|
1
|
+
@import './Button.vars.less';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
22
|
+
&,
|
|
23
|
+
&:hover,
|
|
24
|
+
&:active,
|
|
25
|
+
&:focus {
|
|
26
|
+
text-decoration: none;
|
|
27
|
+
color: var(--Button-color);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&:hover {
|
|
31
|
+
background-color: var(--Button-background-hover);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&:active {
|
|
35
|
+
background-color: var(--Button-background-active);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&.wds-Button--disabled,
|
|
39
|
+
&:disabled {
|
|
40
|
+
// The declarations below are necessary as design specs for
|
|
41
|
+
// the button's disabled state have changed. This is to be
|
|
42
|
+
// further investigated at a later stage.
|
|
43
|
+
// @see https://transferwise.atlassian.net/browse/DS-7386
|
|
44
|
+
filter: none;
|
|
45
|
+
mix-blend-mode: luminosity;
|
|
46
|
+
opacity: 0.45;
|
|
47
|
+
cursor: not-allowed;
|
|
48
|
+
|
|
49
|
+
&,
|
|
50
|
+
&:hover,
|
|
51
|
+
&:active {
|
|
52
|
+
background-color: var(--Button-background);
|
|
53
|
+
}
|
|
9
54
|
}
|
|
10
55
|
|
|
11
|
-
|
|
12
|
-
|
|
56
|
+
// Priority modifiers
|
|
57
|
+
&--secondary {
|
|
58
|
+
--Button-background: var(--Button-secondary-background);
|
|
59
|
+
--Button-background-hover: var(--Button-secondary-background-hover);
|
|
60
|
+
--Button-background-active: var(--Button-secondary-background-active);
|
|
61
|
+
--Button-color: var(--Button-secondary-color);
|
|
13
62
|
}
|
|
14
63
|
|
|
15
|
-
|
|
16
|
-
|
|
64
|
+
&--secondary-neutral {
|
|
65
|
+
--Button-background: var(--Button-secondary-neutral-background);
|
|
66
|
+
--Button-background-hover: var(--Button-secondary-neutral-background-hover);
|
|
67
|
+
--Button-background-active: var(--Button-secondary-neutral-background-active);
|
|
68
|
+
--Button-color: var(--Button-secondary-neutral-color);
|
|
69
|
+
|
|
70
|
+
.wds-Button-icon--end {
|
|
71
|
+
color: var(--color-interactive-primary);
|
|
72
|
+
}
|
|
17
73
|
}
|
|
18
74
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
75
|
+
&--tertiary {
|
|
76
|
+
--Button-background: var(--Button-tertiary-background);
|
|
77
|
+
--Button-background-hover: var(--Button-tertiary-background-hover);
|
|
78
|
+
--Button-background-active: var(--Button-tertiary-background-active);
|
|
79
|
+
--Button-color: var(--Button-tertiary-color);
|
|
80
|
+
|
|
81
|
+
&,
|
|
82
|
+
&:hover,
|
|
83
|
+
&:active,
|
|
84
|
+
&:focus {
|
|
85
|
+
.wds-Button-labelText{
|
|
86
|
+
text-decoration: underline;
|
|
87
|
+
text-underline-offset: 3px;
|
|
88
|
+
text-decoration-thickness: 1px;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Negative styles
|
|
94
|
+
&--negative {
|
|
95
|
+
&.wds-Button--primary {
|
|
96
|
+
--Button-background: var(--Button-primary-negative-background);
|
|
97
|
+
--Button-background-hover: var(--Button-primary-negative-background-hover);
|
|
98
|
+
--Button-background-active: var(--Button-primary-negative-background-active);
|
|
99
|
+
--Button-color: var(--Button-primary-negative-color);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
&.wds-Button--secondary {
|
|
103
|
+
--Button-background: var(--Button-secondary-negative-background);
|
|
104
|
+
--Button-background-hover: var(--Button-secondary-negative-background-hover);
|
|
105
|
+
--Button-background-active: var(--Button-secondary-negative-background-active);
|
|
106
|
+
--Button-color: var(--Button-secondary-negative-color);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Size modifiers
|
|
111
|
+
&--large {
|
|
112
|
+
padding: var(--Button-large-padding);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&--medium {
|
|
116
|
+
padding: var(--Button-medium-padding);
|
|
117
|
+
|
|
118
|
+
&:has(.wds-Button-avatars){
|
|
119
|
+
padding-inline-start: var(--size-8);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&:has(.wds-Button-icon--end){
|
|
123
|
+
padding-inline-end: var(--size-8);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.wds-Button-icon--start{
|
|
127
|
+
margin-inline-end: var(--Button-label-gap);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
&--small {
|
|
132
|
+
padding: var(--Button-small-padding);
|
|
133
|
+
|
|
134
|
+
&:has(.wds-Button-icon--start){
|
|
135
|
+
padding-inline-start: var(--size-8);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
&:has(.wds-Button-icon--end){
|
|
139
|
+
padding-inline-end: var(--size-8);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
// Width modifiers
|
|
146
|
+
&--block {
|
|
147
|
+
width: 100%;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
&-avatars {
|
|
151
|
+
display: inline-flex;
|
|
152
|
+
|
|
153
|
+
.np-avatar-view .np-avatar-view-content {
|
|
154
|
+
color: var(--Button-color);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Icon styles
|
|
159
|
+
&-icon {
|
|
160
|
+
display: inline-block;
|
|
161
|
+
|
|
162
|
+
&--md{
|
|
163
|
+
--Button-iconSize: calc(var(--size-10) + var(--size-8));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
&--sm{
|
|
167
|
+
--Button-iconSize: var(--size-16);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
svg {
|
|
171
|
+
width: var(--Button-iconSize);
|
|
172
|
+
height: var(--Button-iconSize);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
&-content {
|
|
177
|
+
position: relative;
|
|
178
|
+
|
|
179
|
+
&--loading {
|
|
180
|
+
.wds-Button-label,
|
|
181
|
+
.wds-Button-media,
|
|
182
|
+
.wds-Button-icon {
|
|
183
|
+
visibility: hidden;
|
|
184
|
+
opacity: 0;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
&-label {
|
|
190
|
+
display: flex;
|
|
191
|
+
justify-content: center;
|
|
192
|
+
align-items: center;
|
|
193
|
+
gap: var(--Button-label-gap);
|
|
194
|
+
position: relative;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
&-loader {
|
|
198
|
+
position: absolute;
|
|
199
|
+
width: 100%;
|
|
200
|
+
height: 100%;
|
|
201
|
+
|
|
202
|
+
.process-circle {
|
|
203
|
+
stroke: var(--Button-color);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/* Avatar border transparency */
|
|
209
|
+
/* dark buttons get 20% transparency, light buttons get 12% */
|
|
210
|
+
.wds-Button-avatars {
|
|
211
|
+
.np-circle {
|
|
212
|
+
--circle-border-color: color-mix(in srgb, var(--Button-color) 20%, transparent);
|
|
213
|
+
|
|
214
|
+
.wds-Button--secondary.wds-Button--negative &,
|
|
215
|
+
.wds-Button--secondary &,
|
|
216
|
+
.wds-Button--secondary-neutral &,
|
|
217
|
+
.wds-Button--tertiary & {
|
|
218
|
+
.np-theme-personal:not(.np-theme-personal--dark, .np-theme-personal--forest-green, .np-theme-personal--bright-green) & {
|
|
219
|
+
--circle-border-color: color-mix(in srgb, var(--Button-color) 12%, transparent);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
.wds-Button--primary &,
|
|
223
|
+
.wds-Button--primary.wds-Button--negative & {
|
|
224
|
+
.np-theme-personal--dark &,
|
|
225
|
+
.np-theme-personal--forest-green & {
|
|
226
|
+
--circle-border-color: color-mix(in srgb, var(--Button-color) 12%, transparent);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
.wds-Button--tertiary &,
|
|
230
|
+
.wds-Button--secondary-neutral & {
|
|
231
|
+
.np-theme-personal--bright-green & {
|
|
232
|
+
--circle-border-color: color-mix(in srgb, var(--Button-color) 12%, transparent);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
:dir(rtl) {
|
|
240
|
+
.wds-Button {
|
|
241
|
+
.tw-icon-chevron-right,
|
|
242
|
+
.tw-icon-arrow-right,
|
|
243
|
+
.tw-icon-chevron-left,
|
|
244
|
+
.tw-icon-arrow-left,
|
|
245
|
+
.tw-icon-arrow-diagonal-down,
|
|
246
|
+
.tw-icon-arrow-diagonal-up,
|
|
247
|
+
.tw-icon-list,
|
|
248
|
+
.tw-icon-activity {
|
|
249
|
+
scale: -1 1;
|
|
250
|
+
}
|
|
23
251
|
}
|
|
24
252
|
}
|