@transferwise/components 0.0.0-experimental-2524bc4 → 0.0.0-experimental-0ee6ecc
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/src/Button.js +93 -0
- package/build/button/Button/src/Button.js.map +1 -0
- package/build/button/Button/src/Button.mjs +91 -0
- package/build/button/Button/src/Button.mjs.map +1 -0
- package/build/button/{Button.js → LegacyButton/Button.js} +25 -24
- package/build/button/LegacyButton/Button.js.map +1 -0
- package/build/button/{Button.mjs → LegacyButton/Button.mjs} +25 -24
- package/build/button/LegacyButton/Button.mjs.map +1 -0
- package/build/button/LegacyButton/classMap.js +42 -0
- package/build/button/LegacyButton/classMap.js.map +1 -0
- package/build/button/LegacyButton/classMap.mjs +39 -0
- package/build/button/LegacyButton/classMap.mjs.map +1 -0
- package/build/button/{legacyUtils → LegacyButton/legacyUtils}/legacyUtils.js +21 -21
- package/build/button/LegacyButton/legacyUtils/legacyUtils.js.map +1 -0
- package/build/button/{legacyUtils → LegacyButton/legacyUtils}/legacyUtils.mjs +21 -21
- package/build/button/LegacyButton/legacyUtils/legacyUtils.mjs.map +1 -0
- package/build/button/src/Button.js +64 -0
- package/build/button/src/Button.js.map +1 -0
- package/build/button/src/Button.mjs +62 -0
- package/build/button/src/Button.mjs.map +1 -0
- package/build/circularButton/CircularButton.js +1 -1
- package/build/circularButton/CircularButton.js.map +1 -1
- package/build/circularButton/CircularButton.mjs +1 -1
- package/build/circularButton/CircularButton.mjs.map +1 -1
- package/build/common/action/Action.js +1 -1
- package/build/common/action/Action.js.map +1 -1
- package/build/common/action/Action.mjs +1 -1
- package/build/common/action/Action.mjs.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.js +1 -1
- package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
- package/build/header/Header.js +1 -1
- package/build/header/Header.mjs +1 -1
- package/build/i18n/es.json +0 -1
- package/build/i18n/es.json.js +0 -1
- package/build/i18n/es.json.js.map +1 -1
- package/build/i18n/es.json.mjs +0 -1
- package/build/i18n/es.json.mjs.map +1 -1
- package/build/i18n/fr.json +5 -6
- package/build/i18n/fr.json.js +5 -6
- package/build/i18n/fr.json.js.map +1 -1
- package/build/i18n/fr.json.mjs +5 -6
- package/build/i18n/fr.json.mjs.map +1 -1
- package/build/i18n/hu.json +0 -1
- package/build/i18n/hu.json.js +0 -1
- package/build/i18n/hu.json.js.map +1 -1
- package/build/i18n/hu.json.mjs +0 -1
- package/build/i18n/hu.json.mjs.map +1 -1
- package/build/i18n/id.json +0 -1
- package/build/i18n/id.json.js +0 -1
- package/build/i18n/id.json.js.map +1 -1
- package/build/i18n/id.json.mjs +0 -1
- package/build/i18n/id.json.mjs.map +1 -1
- package/build/i18n/ro.json +0 -1
- package/build/i18n/ro.json.js +0 -1
- package/build/i18n/ro.json.js.map +1 -1
- package/build/i18n/ro.json.mjs +0 -1
- package/build/i18n/ro.json.mjs.map +1 -1
- package/build/index.js +1 -1
- 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 +288 -29
- package/build/nudge/Nudge.js +1 -1
- package/build/nudge/Nudge.js.map +1 -1
- package/build/nudge/Nudge.mjs +1 -1
- package/build/nudge/Nudge.mjs.map +1 -1
- package/build/select/Select.js +1 -1
- package/build/select/Select.mjs +1 -1
- package/build/styles/avatarLayout/AvatarLayout.css +11 -0
- package/build/styles/button/Button/less/Button.css +253 -0
- package/build/styles/button/Button/less/Button.vars.css +57 -0
- package/build/styles/iconButton/IconButton.css +24 -29
- package/build/styles/main.css +288 -29
- package/build/types/avatarLayout/AvatarLayout.d.ts +1 -2
- package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
- package/build/types/avatarLayout/index.d.ts +1 -0
- package/build/types/avatarLayout/index.d.ts.map +1 -1
- package/build/types/button/Button/index.d.ts +3 -0
- package/build/types/button/Button/index.d.ts.map +1 -0
- package/build/types/button/Button/src/Button.d.ts +4 -0
- package/build/types/button/Button/src/Button.d.ts.map +1 -0
- package/build/types/button/Button/src/Button.types.d.ts +50 -0
- package/build/types/button/Button/src/Button.types.d.ts.map +1 -0
- package/build/types/button/Button/src/index.d.ts +2 -0
- package/build/types/button/Button/src/index.d.ts.map +1 -0
- package/build/types/button/{Button.d.ts → LegacyButton/Button.d.ts} +6 -5
- package/build/types/button/LegacyButton/Button.d.ts.map +1 -0
- package/build/types/button/LegacyButton/classMap.d.ts.map +1 -0
- package/build/types/button/LegacyButton/index.d.ts +3 -0
- package/build/types/button/LegacyButton/index.d.ts.map +1 -0
- package/build/types/button/LegacyButton/legacyUtils/index.d.ts.map +1 -0
- package/build/types/button/{legacyUtils → LegacyButton/legacyUtils}/legacyUtils.d.ts +1 -1
- package/build/types/button/LegacyButton/legacyUtils/legacyUtils.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/button/src/Button.d.ts +40 -0
- package/build/types/button/src/Button.d.ts.map +1 -0
- package/build/types/button/src/index.d.ts +3 -0
- package/build/types/button/src/index.d.ts.map +1 -0
- package/build/types/link/Link.d.ts +2 -2
- package/build/types/link/Link.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/build/upload/steps/completeStep/completeStep.js +1 -1
- package/build/upload/steps/completeStep/completeStep.mjs +1 -1
- package/build/upload/steps/processingStep/processingStep.js +1 -1
- package/build/upload/steps/processingStep/processingStep.mjs +1 -1
- package/build/uploadInput/UploadInput.js +1 -1
- package/build/uploadInput/UploadInput.mjs +1 -1
- package/package.json +3 -3
- package/src/avatarLayout/AvatarLayout.css +11 -0
- package/src/avatarLayout/AvatarLayout.less +18 -1
- package/src/avatarLayout/AvatarLayout.tsx +11 -3
- package/src/avatarLayout/index.ts +1 -0
- package/src/avatarWrapper/AvatarWrapper.story.tsx +2 -0
- package/src/button/Button/index.ts +2 -0
- package/src/button/Button/less/Button.css +253 -0
- package/src/button/Button/less/Button.less +221 -0
- package/src/button/Button/less/Button.vars.css +57 -0
- package/src/button/Button/less/Button.vars.less +65 -0
- package/src/button/Button/src/Button.tsx +116 -0
- package/src/button/Button/src/Button.types.ts +70 -0
- package/src/button/Button/src/index.ts +1 -0
- package/src/button/Button/stories/Button.story.tsx +314 -0
- package/src/button/Button/stories/Button.tests.story.tsx +288 -0
- package/src/button/Button/test/Button.spec.tsx +328 -0
- package/src/button/{Button.less → LegacyButton/Button.less} +1 -1
- package/src/button/{Button.spec.tsx → LegacyButton/Button.spec.tsx} +3 -3
- package/src/button/LegacyButton/Button.story.tsx +224 -0
- package/src/button/{Button.tsx → LegacyButton/Button.tsx} +12 -9
- package/src/button/{classMap.ts → LegacyButton/classMap.ts} +1 -1
- package/src/button/LegacyButton/index.ts +3 -0
- package/src/button/{legacyUtils → LegacyButton/legacyUtils}/legacyUtils.spec.tsx +2 -2
- package/src/button/{legacyUtils → LegacyButton/legacyUtils}/legacyUtils.ts +2 -2
- package/src/button/index.ts +2 -3
- package/src/button/src/Button.tsx +60 -0
- package/src/button/src/index.ts +2 -0
- package/src/button/test/Button.spec.tsx +32 -0
- package/src/circularButton/CircularButton.tsx +1 -1
- package/src/common/action/Action.tsx +1 -1
- package/src/i18n/es.json +0 -1
- package/src/i18n/fr.json +5 -6
- package/src/i18n/hu.json +0 -1
- package/src/i18n/id.json +0 -1
- package/src/i18n/ro.json +0 -1
- package/src/iconButton/IconButton.css +24 -29
- package/src/iconButton/IconButton.less +4 -4
- package/src/link/Link.tsx +15 -6
- package/src/main.css +288 -29
- package/src/main.less +2 -1
- package/src/nudge/Nudge.tsx +1 -1
- package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.story.tsx +1 -1
- package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +1 -1
- package/src/primitives/PrimitiveButton/stories/PrimitiveButton.story.tsx +1 -1
- package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +2 -3
- package/src/test-utils/index.tsx +0 -1
- package/build/button/Button.js.map +0 -1
- package/build/button/Button.mjs.map +0 -1
- package/build/button/classMap.js +0 -42
- package/build/button/classMap.js.map +0 -1
- package/build/button/classMap.mjs +0 -39
- package/build/button/classMap.mjs.map +0 -1
- package/build/button/legacyUtils/legacyUtils.js.map +0 -1
- package/build/button/legacyUtils/legacyUtils.mjs.map +0 -1
- package/build/types/button/Button.d.ts.map +0 -1
- package/build/types/button/classMap.d.ts.map +0 -1
- package/build/types/button/legacyUtils/index.d.ts.map +0 -1
- package/build/types/button/legacyUtils/legacyUtils.d.ts.map +0 -1
- package/src/button/Button.story.tsx +0 -163
- /package/build/styles/button/{Button.css → LegacyButton/Button.css} +0 -0
- /package/build/types/button/{classMap.d.ts → LegacyButton/classMap.d.ts} +0 -0
- /package/build/types/button/{legacyUtils → LegacyButton/legacyUtils}/index.d.ts +0 -0
- /package/src/button/{Button.css → LegacyButton/Button.css} +0 -0
- /package/src/button/{__snapshots__ → LegacyButton/__snapshots__}/Button.spec.tsx.snap +0 -0
- /package/src/button/{legacyUtils → LegacyButton/legacyUtils}/index.ts +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
:root {
|
|
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-padding: var(--size-8) var(--size-12);
|
|
7
|
+
--Button-border-radius: var(--radius-full);
|
|
8
|
+
--Button-font-size: var(--font-size-16);
|
|
9
|
+
--Button-line-height: var(--size-24);
|
|
10
|
+
--Button-font-weight: var(--font-weight-semi-bold);
|
|
11
|
+
--Button-letter-spacing: -0.011em;
|
|
12
|
+
--Button-size-small-padding: 5px var(--size-12);
|
|
13
|
+
--Button-size-medium-padding: var(--size-8) var(--size-12);
|
|
14
|
+
--Button-size-large-padding: var(--size-12) var(--size-16);
|
|
15
|
+
--Button-avatar-border-color: var(--color-border-neutral);
|
|
16
|
+
--Button-secondary-background: var(--color-interactive-neutral);
|
|
17
|
+
--Button-secondary-background-hover: var(--color-interactive-neutral-hover);
|
|
18
|
+
--Button-secondary-background-active: var(--color-interactive-neutral-active);
|
|
19
|
+
--Button-secondary-color: var(--color-interactive-primary);
|
|
20
|
+
--Button-tertiary-background: var(--color-background-neutral);
|
|
21
|
+
--Button-tertiary-background-hover: var(--color-background-neutral-hover);
|
|
22
|
+
--Button-tertiary-background-active: var(--color-background-neutral-active);
|
|
23
|
+
--Button-tertiary-color: var(--color-content-primary);
|
|
24
|
+
--Button-minimal-background: transparent;
|
|
25
|
+
--Button-minimal-background-hover: var(--color-background-screen-hover);
|
|
26
|
+
--Button-minimal-background-active: var(--color-background-screen-active);
|
|
27
|
+
--Button-minimal-color: var(--color-interactive-primary);
|
|
28
|
+
--Button-primary-negative-background: var(--color-sentiment-negative-primary);
|
|
29
|
+
--Button-primary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
|
|
30
|
+
--Button-primary-negative-background-active: var(--color-sentiment-negative-primary-active);
|
|
31
|
+
--Button-primary-negative-color: var(--color-contrast);
|
|
32
|
+
--Button-primary-netative-avatar-border-color: rgba(255,255,255,0.2);
|
|
33
|
+
--Button-secondary-negative-background: var(--color-sentiment-negative-secondary);
|
|
34
|
+
--Button-secondary-negative-background-hover: var(--color-sentiment-negative-secondary-hover);
|
|
35
|
+
--Button-secondary-negative-background-active: var(--color-sentiment-negative-secondary-active);
|
|
36
|
+
--Button-secondary-negative-color: var(--color-sentiment-negative-primary);
|
|
37
|
+
--Button-secondary-netative-avatar-border-color: rgba(168,32,13,0.12157);
|
|
38
|
+
}
|
|
39
|
+
.np-theme-personal--dark {
|
|
40
|
+
--Button-primary-netative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
41
|
+
}
|
|
42
|
+
.np-theme-personal--forest-green {
|
|
43
|
+
--color-interactive-neutral: rgba(159,232,112,0.2);
|
|
44
|
+
--color-interactive-neutral-hover: rgba(205,255,173,0.2);
|
|
45
|
+
--color-interactive-neutral-active: rgba(236,255,224,0.2);
|
|
46
|
+
--color-sentiment-negative-secondary: rgba(255,196,194,0.2);
|
|
47
|
+
--color-sentiment-negative-secondary-hover: rgba(255,220,219,0.2);
|
|
48
|
+
--color-sentiment-negative-secondary-active: rgba(255,235,235,0.2);
|
|
49
|
+
--Button-primary-netative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
50
|
+
--Button-secondary-netative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
51
|
+
}
|
|
52
|
+
.np-theme-personal--bright-green {
|
|
53
|
+
--color-contrast: #FFFFFF;
|
|
54
|
+
--Button-secondary-color: var(--color-interactive-control);
|
|
55
|
+
--Button-secondary-negative-color: var(--color-contrast);
|
|
56
|
+
--Button-secondary-netative-avatar-border-color: var(--Button-primary-netative-avatar-border-color);
|
|
57
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
:root {
|
|
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-padding: var(--size-8) var(--size-12);
|
|
7
|
+
--Button-border-radius: var(--radius-full);
|
|
8
|
+
--Button-font-size: var(--font-size-16);
|
|
9
|
+
--Button-line-height: var(--size-24);
|
|
10
|
+
--Button-font-weight: var(--font-weight-semi-bold);
|
|
11
|
+
--Button-letter-spacing: -0.011em;
|
|
12
|
+
--Button-size-small-padding: 5px var(--size-12);
|
|
13
|
+
--Button-size-medium-padding: var(--size-8) var(--size-12);
|
|
14
|
+
--Button-size-large-padding: var(--size-12) var(--size-16);
|
|
15
|
+
--Button-avatar-border-color: var(--color-border-neutral);
|
|
16
|
+
|
|
17
|
+
--Button-secondary-background: var(--color-interactive-neutral);
|
|
18
|
+
--Button-secondary-background-hover: var(--color-interactive-neutral-hover);
|
|
19
|
+
--Button-secondary-background-active: var(--color-interactive-neutral-active);
|
|
20
|
+
--Button-secondary-color: var(--color-interactive-primary);
|
|
21
|
+
|
|
22
|
+
--Button-tertiary-background: var(--color-background-neutral);
|
|
23
|
+
--Button-tertiary-background-hover: var(--color-background-neutral-hover);
|
|
24
|
+
--Button-tertiary-background-active: var(--color-background-neutral-active);
|
|
25
|
+
--Button-tertiary-color: var(--color-content-primary);
|
|
26
|
+
|
|
27
|
+
--Button-minimal-background: transparent;
|
|
28
|
+
--Button-minimal-background-hover: var(--color-background-screen-hover);
|
|
29
|
+
--Button-minimal-background-active: var(--color-background-screen-active);
|
|
30
|
+
--Button-minimal-color: var(--color-interactive-primary);
|
|
31
|
+
|
|
32
|
+
--Button-primary-negative-background: var(--color-sentiment-negative-primary);
|
|
33
|
+
--Button-primary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
|
|
34
|
+
--Button-primary-negative-background-active: var(--color-sentiment-negative-primary-active);
|
|
35
|
+
--Button-primary-negative-color: var(--color-contrast);
|
|
36
|
+
--Button-primary-netative-avatar-border-color: #FFFFFF33;
|
|
37
|
+
|
|
38
|
+
--Button-secondary-negative-background: var(--color-sentiment-negative-secondary);
|
|
39
|
+
--Button-secondary-negative-background-hover: var(--color-sentiment-negative-secondary-hover);
|
|
40
|
+
--Button-secondary-negative-background-active: var(--color-sentiment-negative-secondary-active);
|
|
41
|
+
--Button-secondary-negative-color: var(--color-sentiment-negative-primary);
|
|
42
|
+
--Button-secondary-netative-avatar-border-color: #A8200D1F;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.np-theme-personal--dark {
|
|
46
|
+
--Button-primary-netative-avatar-border-color: #0E0F0C1F;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.np-theme-personal--forest-green {
|
|
50
|
+
--color-interactive-neutral: #9FE87033;
|
|
51
|
+
--color-interactive-neutral-hover: #CDFFAD33;
|
|
52
|
+
--color-interactive-neutral-active: #ECFFE033;
|
|
53
|
+
--color-sentiment-negative-secondary: #FFC4C233;
|
|
54
|
+
--color-sentiment-negative-secondary-hover: #FFDCDB33;
|
|
55
|
+
--color-sentiment-negative-secondary-active: #FFEBEB33;
|
|
56
|
+
--Button-primary-netative-avatar-border-color: #0E0F0C1F;
|
|
57
|
+
--Button-secondary-netative-avatar-border-color: #0E0F0C1F;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.np-theme-personal--bright-green {
|
|
61
|
+
--color-contrast: #FFFFFF;
|
|
62
|
+
--Button-secondary-color: var(--color-interactive-control);
|
|
63
|
+
--Button-secondary-negative-color: var(--color-contrast);
|
|
64
|
+
--Button-secondary-netative-avatar-border-color: var(--Button-primary-netative-avatar-border-color);
|
|
65
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import React, { forwardRef, useMemo } from 'react';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import type { ButtonProps } from './Button.types';
|
|
4
|
+
import PrimitiveButton from '../../../primitives/PrimitiveButton';
|
|
5
|
+
import PrimitiveAnchor from '../../../primitives/PrimitiveAnchor';
|
|
6
|
+
import ProcessIndicator from '../../../processIndicator/ProcessIndicator';
|
|
7
|
+
import AvatarView from '../../../avatarView/AvatarView';
|
|
8
|
+
import AvatarLayout from '../../../avatarLayout/AvatarLayout';
|
|
9
|
+
|
|
10
|
+
const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(
|
|
11
|
+
(
|
|
12
|
+
{
|
|
13
|
+
as = 'button',
|
|
14
|
+
children,
|
|
15
|
+
className,
|
|
16
|
+
size = 'md',
|
|
17
|
+
href,
|
|
18
|
+
priority = 'primary',
|
|
19
|
+
appearance = 'default',
|
|
20
|
+
iconLeft: LeftIcon,
|
|
21
|
+
iconRight: RightIcon,
|
|
22
|
+
avatars,
|
|
23
|
+
type = 'button',
|
|
24
|
+
loading = false,
|
|
25
|
+
block = false,
|
|
26
|
+
...props
|
|
27
|
+
},
|
|
28
|
+
ref,
|
|
29
|
+
) => {
|
|
30
|
+
const sizeClass = useMemo(() => {
|
|
31
|
+
return size === 'sm' ? 'small' : size === 'md' ? 'medium' : size === 'lg' ? 'large' : '';
|
|
32
|
+
}, [size]);
|
|
33
|
+
|
|
34
|
+
const classNames = clsx(
|
|
35
|
+
{
|
|
36
|
+
[`wds-Button`]: as === 'a',
|
|
37
|
+
[`wds-Button--block`]: block,
|
|
38
|
+
[`wds-Button--${sizeClass}`]: size,
|
|
39
|
+
[`wds-Button--${priority}`]: priority,
|
|
40
|
+
[`wds-Button--${appearance}`]: appearance,
|
|
41
|
+
},
|
|
42
|
+
className,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const contentClassNames = clsx('wds-Button-content', {
|
|
46
|
+
[`wds-Button-content--loading`]: loading,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const content = (
|
|
50
|
+
<span className={contentClassNames}>
|
|
51
|
+
{loading && (
|
|
52
|
+
<ProcessIndicator
|
|
53
|
+
size="xs"
|
|
54
|
+
className="wds-Button-loader"
|
|
55
|
+
data-testid="button-loader-indicator"
|
|
56
|
+
/>
|
|
57
|
+
)}
|
|
58
|
+
<span className="wds-Button-label" aria-hidden={loading}>
|
|
59
|
+
{size === 'lg' ? (
|
|
60
|
+
children
|
|
61
|
+
) : (
|
|
62
|
+
<>
|
|
63
|
+
{size === 'md' && avatars && (
|
|
64
|
+
<span className="wds-Button-avatars">
|
|
65
|
+
{avatars.length === 1 ? (
|
|
66
|
+
<AvatarView size={24} {...avatars[0]}>
|
|
67
|
+
{avatars[0]?.asset}
|
|
68
|
+
</AvatarView>
|
|
69
|
+
) : (
|
|
70
|
+
<AvatarLayout orientation="horizontal" avatars={avatars} size={24} />
|
|
71
|
+
)}
|
|
72
|
+
</span>
|
|
73
|
+
)}
|
|
74
|
+
{!avatars && LeftIcon && (
|
|
75
|
+
<LeftIcon className="wds-Button-icon wds-Button-icon--left" />
|
|
76
|
+
)}
|
|
77
|
+
{children}
|
|
78
|
+
{RightIcon && <RightIcon className="wds-Button-icon wds-Button-icon--right" />}
|
|
79
|
+
</>
|
|
80
|
+
)}
|
|
81
|
+
</span>
|
|
82
|
+
</span>
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
if (as === 'a') {
|
|
86
|
+
return (
|
|
87
|
+
<PrimitiveAnchor
|
|
88
|
+
ref={ref as React.Ref<HTMLAnchorElement>}
|
|
89
|
+
{...(props as any)}
|
|
90
|
+
href={href}
|
|
91
|
+
className={classNames}
|
|
92
|
+
disabled={props.disabled}
|
|
93
|
+
>
|
|
94
|
+
{content}
|
|
95
|
+
</PrimitiveAnchor>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<PrimitiveButton
|
|
101
|
+
ref={ref as React.Ref<HTMLButtonElement>}
|
|
102
|
+
{...(props as any)}
|
|
103
|
+
className={classNames}
|
|
104
|
+
disabled={props.disabled}
|
|
105
|
+
loading={loading}
|
|
106
|
+
type={type}
|
|
107
|
+
>
|
|
108
|
+
{content}
|
|
109
|
+
</PrimitiveButton>
|
|
110
|
+
);
|
|
111
|
+
},
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
Button.displayName = 'Button';
|
|
115
|
+
|
|
116
|
+
export default Button;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
PrimitiveButtonProps,
|
|
4
|
+
PrimitiveAnchorProps,
|
|
5
|
+
PrimitiveButtonElementRef,
|
|
6
|
+
PrimitiveAnchorElementRef,
|
|
7
|
+
} from '../../../primitives';
|
|
8
|
+
import type { SingleAvatarType } from '../../../avatarLayout';
|
|
9
|
+
|
|
10
|
+
export type ButtonApperance = 'default' | 'negative';
|
|
11
|
+
export type ButtonPriority = 'primary' | 'secondary' | 'tertiary' | 'minimal';
|
|
12
|
+
export type ButtonType = 'button' | 'submit' | 'reset' | undefined;
|
|
13
|
+
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
14
|
+
export type ButtonRefType = PrimitiveButtonElementRef | PrimitiveAnchorElementRef;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Common properties for the Button component.
|
|
18
|
+
*/
|
|
19
|
+
export interface CommonButtonProps {
|
|
20
|
+
/** The HTML element to render */
|
|
21
|
+
as?: 'button' | 'a' | undefined;
|
|
22
|
+
|
|
23
|
+
/** Additional class name(s) to apply to the button */
|
|
24
|
+
className?: string;
|
|
25
|
+
|
|
26
|
+
/** Content to be displayed inside the button */
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
|
|
29
|
+
/** Whether the button is disabled */
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
|
|
32
|
+
href?: string;
|
|
33
|
+
|
|
34
|
+
/** Whether the button is in a loading state */
|
|
35
|
+
loading?: boolean;
|
|
36
|
+
|
|
37
|
+
/** Whether the button should take up the full width of its container */
|
|
38
|
+
block?: boolean;
|
|
39
|
+
|
|
40
|
+
/** Size of the button */
|
|
41
|
+
size?: ButtonSize;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Priority of the button
|
|
45
|
+
* @default 'primary'
|
|
46
|
+
*/
|
|
47
|
+
priority?: ButtonPriority;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Appearance of the button
|
|
51
|
+
* @default 'default'
|
|
52
|
+
*/
|
|
53
|
+
appearance?: ButtonApperance;
|
|
54
|
+
|
|
55
|
+
/** Icon to be displayed on the left side of the button */
|
|
56
|
+
iconLeft?: React.ElementType;
|
|
57
|
+
|
|
58
|
+
/** Icon to be displayed on the right side of the button */
|
|
59
|
+
iconRight?: React.ElementType;
|
|
60
|
+
|
|
61
|
+
/** Media to be displayed on the left side of the button */
|
|
62
|
+
avatars?: SingleAvatarType[];
|
|
63
|
+
|
|
64
|
+
/** Optional property to provide component Ref */
|
|
65
|
+
ref?: ButtonRefType;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type ButtonElementProps = PrimitiveButtonProps & CommonButtonProps;
|
|
69
|
+
export type AnchorElementProps = PrimitiveAnchorProps & CommonButtonProps;
|
|
70
|
+
export type ButtonProps = ButtonElementProps | AnchorElementProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Button';
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { fn } from '@storybook/test';
|
|
3
|
+
import Button from '../../src';
|
|
4
|
+
import { Freeze, ArrowRight } from '@transferwise/icons';
|
|
5
|
+
|
|
6
|
+
const withContainer = (Story: any) => (
|
|
7
|
+
<div style={{ display: 'flex', flexDirection: 'initial', justifyContent: 'center' }}>
|
|
8
|
+
<Story />
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const meta: Meta<typeof Button> = {
|
|
13
|
+
component: Button,
|
|
14
|
+
title: 'Actions/Button',
|
|
15
|
+
argTypes: {
|
|
16
|
+
as: {
|
|
17
|
+
type: {
|
|
18
|
+
name: 'enum',
|
|
19
|
+
value: ['button', 'a'],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
size: {
|
|
23
|
+
type: {
|
|
24
|
+
name: 'enum',
|
|
25
|
+
value: ['sm', 'md', 'lg'],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
href: {
|
|
29
|
+
type: {
|
|
30
|
+
name: 'string',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
priority: {
|
|
34
|
+
type: {
|
|
35
|
+
name: 'enum',
|
|
36
|
+
value: ['primary', 'secondary', 'tertiary', 'minimal'],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
appearance: {
|
|
40
|
+
type: {
|
|
41
|
+
name: 'enum',
|
|
42
|
+
value: ['default', 'negative'],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
iconLeft: {
|
|
46
|
+
control: 'object',
|
|
47
|
+
},
|
|
48
|
+
iconRight: {
|
|
49
|
+
control: 'object',
|
|
50
|
+
},
|
|
51
|
+
avatars: {
|
|
52
|
+
control: 'object',
|
|
53
|
+
},
|
|
54
|
+
htmlType: {
|
|
55
|
+
table: {
|
|
56
|
+
disable: true,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
'data-testid': {
|
|
60
|
+
table: {
|
|
61
|
+
disable: true,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
args: {
|
|
66
|
+
children: 'Button text',
|
|
67
|
+
as: 'button',
|
|
68
|
+
href: undefined,
|
|
69
|
+
disabled: false,
|
|
70
|
+
loading: false,
|
|
71
|
+
size: 'md',
|
|
72
|
+
iconLeft: undefined,
|
|
73
|
+
iconRight: undefined,
|
|
74
|
+
priority: 'primary',
|
|
75
|
+
appearance: 'default',
|
|
76
|
+
avatars: undefined,
|
|
77
|
+
useNewButton: true,
|
|
78
|
+
onClick: fn(),
|
|
79
|
+
onBlur: fn(),
|
|
80
|
+
onFocus: fn(),
|
|
81
|
+
onKeyDown: fn(),
|
|
82
|
+
onMouseEnter: fn(),
|
|
83
|
+
onMouseLeave: fn(),
|
|
84
|
+
},
|
|
85
|
+
tags: ['autodocs'],
|
|
86
|
+
decorators: [withContainer],
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default meta;
|
|
90
|
+
|
|
91
|
+
type Story = StoryObj<typeof Button>;
|
|
92
|
+
|
|
93
|
+
export const Basic: Story = {
|
|
94
|
+
parameters: {
|
|
95
|
+
docs: {
|
|
96
|
+
description: {
|
|
97
|
+
story: 'A basic example of the Button component.',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const Secondary: Story = {
|
|
104
|
+
args: {
|
|
105
|
+
priority: 'secondary',
|
|
106
|
+
},
|
|
107
|
+
parameters: {
|
|
108
|
+
docs: {
|
|
109
|
+
description: {
|
|
110
|
+
story: 'A Button with secondary priority.',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const Tertiary: Story = {
|
|
117
|
+
args: {
|
|
118
|
+
priority: 'tertiary',
|
|
119
|
+
},
|
|
120
|
+
parameters: {
|
|
121
|
+
docs: {
|
|
122
|
+
description: {
|
|
123
|
+
story: 'A Button with tertiary priority.',
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export const Minimal: Story = {
|
|
130
|
+
args: {
|
|
131
|
+
priority: 'minimal',
|
|
132
|
+
},
|
|
133
|
+
parameters: {
|
|
134
|
+
docs: {
|
|
135
|
+
description: {
|
|
136
|
+
story: 'A Button with minimal priority.',
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const Negative: Story = {
|
|
143
|
+
args: {
|
|
144
|
+
appearance: 'negative',
|
|
145
|
+
},
|
|
146
|
+
parameters: {
|
|
147
|
+
docs: {
|
|
148
|
+
description: {
|
|
149
|
+
story: 'A Button with negative appearance.',
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export const NegativeSecondary: Story = {
|
|
156
|
+
args: {
|
|
157
|
+
appearance: 'negative',
|
|
158
|
+
priority: 'secondary',
|
|
159
|
+
},
|
|
160
|
+
parameters: {
|
|
161
|
+
docs: {
|
|
162
|
+
description: {
|
|
163
|
+
story: 'A Button with negative appearance and secondary priority.',
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export const AsAnchor: Story = {
|
|
170
|
+
args: {
|
|
171
|
+
as: 'a',
|
|
172
|
+
href: 'https://wise.com',
|
|
173
|
+
},
|
|
174
|
+
parameters: {
|
|
175
|
+
docs: {
|
|
176
|
+
description: {
|
|
177
|
+
story: 'A Button rendered as an anchor element.',
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const Disabled: Story = {
|
|
184
|
+
args: {
|
|
185
|
+
disabled: true,
|
|
186
|
+
},
|
|
187
|
+
parameters: {
|
|
188
|
+
docs: {
|
|
189
|
+
description: {
|
|
190
|
+
story: 'A disabled Button.',
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export const Loading: Story = {
|
|
197
|
+
args: {
|
|
198
|
+
loading: true,
|
|
199
|
+
},
|
|
200
|
+
parameters: {
|
|
201
|
+
docs: {
|
|
202
|
+
description: {
|
|
203
|
+
story: 'A Button in a loading state.',
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export const SizeSmall: Story = {
|
|
210
|
+
args: {
|
|
211
|
+
size: 'sm',
|
|
212
|
+
},
|
|
213
|
+
parameters: {
|
|
214
|
+
docs: {
|
|
215
|
+
description: {
|
|
216
|
+
story: 'A small Button.',
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export const SizeLarge: Story = {
|
|
223
|
+
args: {
|
|
224
|
+
size: 'lg',
|
|
225
|
+
},
|
|
226
|
+
parameters: {
|
|
227
|
+
docs: {
|
|
228
|
+
description: {
|
|
229
|
+
story: 'A large Button.',
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
export const DisplayBlock: Story = {
|
|
236
|
+
args: {
|
|
237
|
+
block: true,
|
|
238
|
+
},
|
|
239
|
+
parameters: {
|
|
240
|
+
docs: {
|
|
241
|
+
description: {
|
|
242
|
+
story: 'A Button that takes up the full width of its container.',
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export const WithIcon: Story = {
|
|
249
|
+
args: {
|
|
250
|
+
iconRight: ArrowRight,
|
|
251
|
+
},
|
|
252
|
+
parameters: {
|
|
253
|
+
docs: {
|
|
254
|
+
description: {
|
|
255
|
+
story:
|
|
256
|
+
'A Button with an icon on the right. Can also use `iconLeft` to place the icon on the left or have both at the same time.',
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
export const WithAvatars: Story = {
|
|
263
|
+
args: {
|
|
264
|
+
avatars: [{ asset: <Freeze /> }, { asset: <Freeze /> }],
|
|
265
|
+
},
|
|
266
|
+
parameters: {
|
|
267
|
+
docs: {
|
|
268
|
+
description: {
|
|
269
|
+
story:
|
|
270
|
+
'A Button with avatars. Will supersed any `iconLeft` property and will always render avatars.',
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export const WithProfileName: Story = {
|
|
277
|
+
args: {
|
|
278
|
+
avatars: [{ profileName: 'John Doe' }],
|
|
279
|
+
},
|
|
280
|
+
parameters: {
|
|
281
|
+
docs: {
|
|
282
|
+
description: {
|
|
283
|
+
story: 'A Button with a Profile name.',
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
export const WithProfileImage: Story = {
|
|
290
|
+
args: {
|
|
291
|
+
avatars: [{ imgSrc: '../avatar-rectangle-fox.webp' }],
|
|
292
|
+
},
|
|
293
|
+
parameters: {
|
|
294
|
+
docs: {
|
|
295
|
+
description: {
|
|
296
|
+
story: 'A Button with a Profile image.',
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
export const WithAvatarAndIcon: Story = {
|
|
303
|
+
args: {
|
|
304
|
+
avatars: [{ asset: <Freeze /> }],
|
|
305
|
+
iconRight: ArrowRight,
|
|
306
|
+
},
|
|
307
|
+
parameters: {
|
|
308
|
+
docs: {
|
|
309
|
+
description: {
|
|
310
|
+
story: 'A Button with an avatar and an icon.',
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
};
|