@transferwise/components 0.0.0-experimental-696128b → 0.0.0-experimental-328f2cc
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 +4 -10
- package/build/avatarLayout/AvatarLayout.js.map +1 -1
- package/build/avatarLayout/AvatarLayout.mjs +4 -10
- package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
- package/build/button/Button.js +79 -81
- package/build/button/Button.js.map +1 -1
- package/build/button/Button.mjs +80 -82
- package/build/button/Button.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/index.js +4 -2
- package/build/index.js.map +1 -1
- package/build/index.mjs +2 -1
- package/build/index.mjs.map +1 -1
- package/build/link/Link.js +3 -8
- package/build/link/Link.js.map +1 -1
- package/build/link/Link.mjs +3 -8
- package/build/link/Link.mjs.map +1 -1
- package/build/main.css +13 -224
- package/build/nudge/Nudge.js.map +1 -1
- package/build/nudge/Nudge.mjs.map +1 -1
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +3 -1
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +3 -1
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +4 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +4 -1
- 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 +2 -12
- package/build/styles/button/Button.css +15 -204
- package/build/styles/main.css +13 -224
- package/build/styles/nudge/Nudge.css +11 -0
- package/build/table/Table.js +166 -0
- package/build/table/Table.js.map +1 -0
- package/build/table/Table.messages.js +24 -0
- package/build/table/Table.messages.js.map +1 -0
- package/build/table/Table.messages.mjs +22 -0
- package/build/table/Table.messages.mjs.map +1 -0
- package/build/table/Table.mjs +164 -0
- package/build/table/Table.mjs.map +1 -0
- package/build/table/TableCell.js +86 -0
- package/build/table/TableCell.js.map +1 -0
- package/build/table/TableCell.mjs +84 -0
- package/build/table/TableCell.mjs.map +1 -0
- package/build/table/TableHeader.js +57 -0
- package/build/table/TableHeader.js.map +1 -0
- package/build/table/TableHeader.mjs +55 -0
- package/build/table/TableHeader.mjs.map +1 -0
- package/build/table/TableRow.js +85 -0
- package/build/table/TableRow.js.map +1 -0
- package/build/table/TableRow.mjs +83 -0
- package/build/table/TableRow.mjs.map +1 -0
- package/build/table/TableStatusText.js +54 -0
- package/build/table/TableStatusText.js.map +1 -0
- package/build/table/TableStatusText.mjs +52 -0
- package/build/table/TableStatusText.mjs.map +1 -0
- package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
- package/build/types/button/Button.d.ts +23 -2
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/button/index.d.ts +2 -2
- package/build/types/button/index.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -0
- package/build/types/index.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/nudge/Nudge.d.ts +1 -1
- package/build/types/nudge/Nudge.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 +2 -6
- 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/types/uploadInput/uploadButton/getAllowedFileTypes.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/build/uploadInput/uploadButton/getAllowedFileTypes.js +23 -3
- package/build/uploadInput/uploadButton/getAllowedFileTypes.js.map +1 -1
- package/build/uploadInput/uploadButton/getAllowedFileTypes.mjs +23 -3
- package/build/uploadInput/uploadButton/getAllowedFileTypes.mjs.map +1 -1
- package/package.json +3 -3
- package/src/alert/Alert.tests.story.tsx +1 -1
- package/src/avatarLayout/AvatarLayout.css +2 -12
- package/src/avatarLayout/AvatarLayout.less +2 -19
- package/src/avatarLayout/AvatarLayout.tsx +3 -10
- package/src/button/Button.css +15 -204
- package/src/button/Button.less +14 -211
- package/src/button/Button.spec.tsx +227 -75
- package/src/button/Button.story.tsx +135 -728
- package/src/button/Button.tsx +131 -94
- package/src/button/__snapshots__/Button.spec.tsx.snap +309 -0
- package/src/button/index.ts +3 -2
- package/src/drawer/Drawer.spec.tsx +93 -0
- package/src/field/Field.story.tsx +1 -1
- package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -1
- package/src/index.ts +12 -0
- package/src/inputs/SelectInput.story.tsx +1 -1
- package/src/label/Label.story.tsx +1 -1
- package/src/link/Link.tsx +6 -15
- package/src/main.css +13 -224
- package/src/main.less +0 -1
- package/src/nudge/Nudge.css +11 -0
- package/src/nudge/Nudge.less +3 -0
- package/src/nudge/Nudge.story.tsx +10 -0
- package/src/nudge/Nudge.tsx +2 -1
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +7 -1
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +2 -7
- package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +3 -1
- package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +8 -1
- package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +5 -2
- package/src/test-utils/Parameters.d.ts +1 -9
- package/src/test-utils/story-config.ts +1 -10
- package/src/uploadInput/UploadInput.tests.story.tsx +5 -5
- package/src/uploadInput/uploadButton/getAllowedFileTypes.spec.ts +12 -0
- package/src/uploadInput/uploadButton/getAllowedFileTypes.ts +33 -7
- package/build/button/Button.resolver.js +0 -74
- package/build/button/Button.resolver.js.map +0 -1
- package/build/button/Button.resolver.mjs +0 -72
- package/build/button/Button.resolver.mjs.map +0 -1
- package/build/button/LegacyButton.js +0 -114
- package/build/button/LegacyButton.js.map +0 -1
- package/build/button/LegacyButton.mjs +0 -112
- package/build/button/LegacyButton.mjs.map +0 -1
- package/build/styles/button/Button.vars.css +0 -39
- package/build/styles/button/LegacyButton.css +0 -23
- package/build/types/button/Button.resolver.d.ts +0 -33
- package/build/types/button/Button.resolver.d.ts.map +0 -1
- package/build/types/button/Button.types.d.ts +0 -58
- package/build/types/button/Button.types.d.ts.map +0 -1
- package/build/types/button/LegacyButton.d.ts +0 -30
- package/build/types/button/LegacyButton.d.ts.map +0 -1
- package/src/button/Button.resolver.tsx +0 -73
- package/src/button/Button.tests.story.tsx +0 -27
- package/src/button/Button.types.ts +0 -74
- package/src/button/Button.vars.css +0 -39
- package/src/button/Button.vars.less +0 -50
- package/src/button/LegacyButton.css +0 -23
- package/src/button/LegacyButton.less +0 -24
- package/src/button/LegacyButton.spec.tsx +0 -147
- package/src/button/LegacyButton.story.tsx +0 -225
- package/src/button/LegacyButton.tsx +0 -160
- package/src/drawer/Drawer.rtl.spec.tsx +0 -59
- package/src/drawer/Drawer.spec.js +0 -101
- package/src/drawer/__snapshots__/Drawer.rtl.spec.tsx.snap +0 -55
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ControlTypeAccent, ControlTypeNegative, ControlTypePositive, PriorityPrimary, PrioritySecondary, PriorityTertiary, SizeExtraSmall, SizeSmall, SizeMedium, SizeLarge } from '../common';
|
|
2
|
-
import { ButtonReferenceType } from './Button.types';
|
|
3
|
-
/** @deprecated */
|
|
4
|
-
type DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';
|
|
5
|
-
/** @deprecated */
|
|
6
|
-
type DeprecatedSizes = SizeExtraSmall;
|
|
7
|
-
type CommonProps = {
|
|
8
|
-
v2?: false;
|
|
9
|
-
block?: boolean;
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
loading?: boolean;
|
|
12
|
-
type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;
|
|
13
|
-
priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;
|
|
14
|
-
size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;
|
|
15
|
-
htmlType?: 'submit' | 'reset' | 'button';
|
|
16
|
-
};
|
|
17
|
-
type ButtonProps = CommonProps & Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {
|
|
18
|
-
as?: 'button';
|
|
19
|
-
};
|
|
20
|
-
type AnchorProps = CommonProps & Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {
|
|
21
|
-
as?: 'a';
|
|
22
|
-
href?: string;
|
|
23
|
-
};
|
|
24
|
-
export type LegacyButtonProps = ButtonProps | AnchorProps;
|
|
25
|
-
/**
|
|
26
|
-
* @deprecated make sure you use new Button component via `<Button v2 .. />` and new props
|
|
27
|
-
*/
|
|
28
|
-
declare const LegacyButton: import("react").ForwardRefExoticComponent<(Omit<ButtonProps, "ref"> | Omit<AnchorProps, "ref">) & import("react").RefAttributes<ButtonReferenceType>>;
|
|
29
|
-
export default LegacyButton;
|
|
30
|
-
//# sourceMappingURL=LegacyButton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LegacyButton.d.ts","sourceRoot":"","sources":["../../../src/button/LegacyButton.tsx"],"names":[],"mappings":"AAIA,OAAO,EAIL,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,UAAU,EACV,SAAS,EACV,MAAM,WAAW,CAAC;AAMnB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,kBAAkB;AAClB,KAAK,eAAe,GAAG,SAAS,GAAG,KAAK,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE3E,kBAAkB;AAClB,KAAK,eAAe,GAAG,cAAc,CAAC;AAEtC,KAAK,WAAW,GAAG;IACjB,EAAE,CAAC,EAAE,KAAK,CAAC;IACX,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,iBAAiB,GAAG,mBAAmB,GAAG,mBAAmB,GAAG,eAAe,GAAG,IAAI,CAAC;IAC9F,QAAQ,CAAC,EAAE,eAAe,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,IAAI,CAAC;IACzE,IAAI,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,eAAe,CAAC;IAC5D,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;CAC1C,CAAC;AAEF,KAAK,WAAW,GAAG,WAAW,GAC5B,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,GAAG;IACpD,EAAE,CAAC,EAAE,QAAQ,CAAC;CACf,CAAC;AAEJ,KAAK,WAAW,GAAG,WAAW,GAC5B,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG;IAC/C,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEJ,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,WAAW,CAAC;AAE1D;;GAEG;AACH,QAAA,MAAM,YAAY,uJAkGjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
2
|
-
import LegacyButton, { LegacyButtonProps } from './LegacyButton';
|
|
3
|
-
import { ButtonReferenceType, ButtonProps as NewButtonProps } from './Button.types';
|
|
4
|
-
import NewButton from './Button';
|
|
5
|
-
|
|
6
|
-
export type ButtonProps = LegacyButtonProps | NewButtonProps;
|
|
7
|
-
|
|
8
|
-
const mapProps = (props: LegacyButtonProps): NewButtonProps => {
|
|
9
|
-
const { priority, size, type, ...newProps } = props;
|
|
10
|
-
|
|
11
|
-
const priorityMapping: Record<string, Record<string, NewButtonProps['priority']>> = {
|
|
12
|
-
accent: {
|
|
13
|
-
primary: 'primary',
|
|
14
|
-
secondary: 'tertiary',
|
|
15
|
-
tertiary: 'minimal',
|
|
16
|
-
},
|
|
17
|
-
positive: {
|
|
18
|
-
primary: 'primary',
|
|
19
|
-
secondary: 'tertiary',
|
|
20
|
-
tertiary: 'tertiary',
|
|
21
|
-
},
|
|
22
|
-
negative: {
|
|
23
|
-
primary: 'primary',
|
|
24
|
-
secondary: 'secondary',
|
|
25
|
-
tertiary: 'secondary',
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const mappedPriority =
|
|
30
|
-
type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;
|
|
31
|
-
const mappedSentiment = type === 'negative' ? 'negative' : undefined;
|
|
32
|
-
|
|
33
|
-
const legacyButtonTypes: LegacyButtonProps['type'][] = [
|
|
34
|
-
'accent',
|
|
35
|
-
'negative',
|
|
36
|
-
'positive',
|
|
37
|
-
'primary',
|
|
38
|
-
'pay',
|
|
39
|
-
'secondary',
|
|
40
|
-
'danger',
|
|
41
|
-
'link',
|
|
42
|
-
];
|
|
43
|
-
|
|
44
|
-
const resolveSize = () => {
|
|
45
|
-
if (size) {
|
|
46
|
-
return { xs: 'sm', sm: 'sm', md: 'md', lg: 'lg' }[size] || size;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return size;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
return {
|
|
53
|
-
...newProps,
|
|
54
|
-
size: resolveSize(),
|
|
55
|
-
priority: mappedPriority,
|
|
56
|
-
sentiment: mappedSentiment || ('sentiment' in props ? props.sentiment : null),
|
|
57
|
-
type: type && !legacyButtonTypes.includes(type) ? type : props.htmlType || null,
|
|
58
|
-
v2: true,
|
|
59
|
-
} as NewButtonProps;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const Button = forwardRef<ButtonReferenceType, ButtonProps>(({ v2 = false, ...props }, ref) => {
|
|
63
|
-
if (v2) {
|
|
64
|
-
const mappedProps = mapProps(props as LegacyButtonProps);
|
|
65
|
-
return <NewButton {...mappedProps} ref={ref} />;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return <LegacyButton {...(props as LegacyButtonProps)} ref={ref} />;
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
Button.displayName = 'Button';
|
|
72
|
-
|
|
73
|
-
export default Button;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Meta } from '@storybook/react';
|
|
2
|
-
import Button from './Button.resolver';
|
|
3
|
-
import { expect, userEvent, within } from '@storybook/test';
|
|
4
|
-
import { storyConfig } from '../test-utils';
|
|
5
|
-
|
|
6
|
-
const meta: Meta<typeof Button> = {
|
|
7
|
-
component: Button,
|
|
8
|
-
title: 'Actions/Button/Tests',
|
|
9
|
-
};
|
|
10
|
-
export default meta;
|
|
11
|
-
|
|
12
|
-
export const FocusMinimal = storyConfig(
|
|
13
|
-
{
|
|
14
|
-
render: () => (
|
|
15
|
-
<Button v2 priority="minimal">
|
|
16
|
-
Focus has underline
|
|
17
|
-
</Button>
|
|
18
|
-
),
|
|
19
|
-
},
|
|
20
|
-
{},
|
|
21
|
-
);
|
|
22
|
-
FocusMinimal.play = async ({ canvasElement }) => {
|
|
23
|
-
await userEvent.tab();
|
|
24
|
-
const canvas = within(canvasElement);
|
|
25
|
-
const buttonElement: HTMLButtonElement = canvas.getByRole('button');
|
|
26
|
-
await expect(buttonElement).toHaveFocus();
|
|
27
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import type { PrimitiveButtonProps, PrimitiveAnchorProps } from '../primitives';
|
|
3
|
-
import type { AvatarLayoutProps } from '../avatarLayout';
|
|
4
|
-
|
|
5
|
-
export type ButtonSentiment = 'default' | 'negative';
|
|
6
|
-
export type ButtonPriority = 'primary' | 'secondary' | 'tertiary' | 'minimal';
|
|
7
|
-
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
8
|
-
export type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Common properties for the Button component.
|
|
12
|
-
*/
|
|
13
|
-
export interface CommonProps {
|
|
14
|
-
v2: true;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The HTML element to render
|
|
18
|
-
* @default 'button'
|
|
19
|
-
**/
|
|
20
|
-
as?: 'button' | 'a';
|
|
21
|
-
|
|
22
|
-
/** Additional class name(s) to apply to the button */
|
|
23
|
-
className?: string;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @default false
|
|
27
|
-
**/
|
|
28
|
-
disabled?: boolean;
|
|
29
|
-
|
|
30
|
-
href?: string;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @default false
|
|
34
|
-
* */
|
|
35
|
-
loading?: boolean;
|
|
36
|
-
|
|
37
|
-
/** Whether the button should take up the full width of its container */
|
|
38
|
-
block?: boolean;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Size of the button
|
|
42
|
-
* @default lg
|
|
43
|
-
* */
|
|
44
|
-
size?: ButtonSize;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Priority of the button
|
|
48
|
-
* @default "primary"
|
|
49
|
-
*/
|
|
50
|
-
priority?: ButtonPriority;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Sentiment of the button
|
|
54
|
-
* @default default
|
|
55
|
-
*/
|
|
56
|
-
sentiment?: ButtonSentiment;
|
|
57
|
-
|
|
58
|
-
/** Icon to be displayed on the left side of the button */
|
|
59
|
-
iconStart?: React.ElementType;
|
|
60
|
-
|
|
61
|
-
/** Icon to be displayed on the right side of the button */
|
|
62
|
-
iconEnd?: React.ElementType;
|
|
63
|
-
|
|
64
|
-
/** Media to be displayed on the left side of the button */
|
|
65
|
-
avatars?: AvatarLayoutProps['avatars'];
|
|
66
|
-
|
|
67
|
-
/** Content to be displayed inside the button */
|
|
68
|
-
children?: ReactNode;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export type ButtonElementProps = PrimitiveButtonProps & CommonProps;
|
|
72
|
-
export type AnchorElementProps = PrimitiveAnchorProps & CommonProps;
|
|
73
|
-
|
|
74
|
-
export type ButtonProps = ButtonElementProps | AnchorElementProps;
|
|
@@ -1,39 +0,0 @@
|
|
|
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: calc(var(--size-10) * 0.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);
|
|
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
|
-
--color-contrast: #FFFFFF;
|
|
37
|
-
--Button-secondary-color: var(--color-interactive-control);
|
|
38
|
-
--Button-secondary-negative-color: var(--color-contrast);
|
|
39
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
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
|
-
|
|
9
|
-
--Button-large-padding: var(--size-12) var(--size-16);
|
|
10
|
-
--Button-medium-padding: var(--size-8) var(--size-12);
|
|
11
|
-
// 5px is required by design
|
|
12
|
-
--Button-small-padding: calc(var(--size-10) * .5) var(--size-12);
|
|
13
|
-
|
|
14
|
-
--Button-avatar-border-color: var(--color-border-neutral);
|
|
15
|
-
--Button-transition-duration: 150ms;
|
|
16
|
-
--Button-transition-easing: ease-in-out;
|
|
17
|
-
|
|
18
|
-
--Button-secondary-background: var(--color-interactive-neutral);
|
|
19
|
-
--Button-secondary-background-hover: var(--color-interactive-neutral-hover);
|
|
20
|
-
--Button-secondary-background-active: var(--color-interactive-neutral-active);
|
|
21
|
-
--Button-secondary-color: var(--color-interactive-primary);
|
|
22
|
-
|
|
23
|
-
--Button-tertiary-background: var(--color-background-neutral);
|
|
24
|
-
--Button-tertiary-background-hover: var(--color-background-neutral-hover);
|
|
25
|
-
--Button-tertiary-background-active: var(--color-background-neutral-active);
|
|
26
|
-
--Button-tertiary-color: var(--color-content-primary);
|
|
27
|
-
|
|
28
|
-
--Button-minimal-background: transparent;
|
|
29
|
-
--Button-minimal-background-hover: var(--color-background-screen-hover);
|
|
30
|
-
--Button-minimal-background-active: var(--color-background-screen-active);
|
|
31
|
-
--Button-minimal-color: var(--color-interactive-primary);
|
|
32
|
-
|
|
33
|
-
--Button-primary-negative-background: var(--color-sentiment-negative-primary);
|
|
34
|
-
--Button-primary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
|
|
35
|
-
--Button-primary-negative-background-active: var(--color-sentiment-negative-primary-active);
|
|
36
|
-
--Button-primary-negative-color: var(--color-contrast);
|
|
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
|
-
}
|
|
43
|
-
|
|
44
|
-
.np-theme-personal--bright-green {
|
|
45
|
-
.wds-Button {
|
|
46
|
-
--color-contrast: #FFFFFF;
|
|
47
|
-
--Button-secondary-color: var(--color-interactive-control);
|
|
48
|
-
--Button-secondary-negative-color: var(--color-contrast);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
.np-btn {
|
|
2
|
-
position: relative;
|
|
3
|
-
}
|
|
4
|
-
.np-btn.np-btn-block > span.btn-loader {
|
|
5
|
-
position: absolute;
|
|
6
|
-
left: 24px;
|
|
7
|
-
left: var(--size-24);
|
|
8
|
-
}
|
|
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;
|
|
14
|
-
}
|
|
15
|
-
.np-btn.np-btn-xs > span.btn-loader {
|
|
16
|
-
background-size: 16px 16px;
|
|
17
|
-
}
|
|
18
|
-
.np-btn.np-btn-xs.btn-block > span.btn-loader {
|
|
19
|
-
top: 0;
|
|
20
|
-
}
|
|
21
|
-
.np-btn.disabled[class] {
|
|
22
|
-
pointer-events: auto;
|
|
23
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
@import (reference) "../../node_modules/@transferwise/neptune-css/src/less/mixins/_logical-properties.less";
|
|
2
|
-
|
|
3
|
-
.np-btn {
|
|
4
|
-
position: relative;
|
|
5
|
-
|
|
6
|
-
&.np-btn-block > span.btn-loader {
|
|
7
|
-
position: absolute;
|
|
8
|
-
.left(var(--size-24));
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
&.np-btn-xs > span.btn-loader {
|
|
12
|
-
background-size: 16px 16px;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
&.np-btn-xs.btn-block > span.btn-loader {
|
|
16
|
-
top: 0;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// we do not want pointer events disabled as that
|
|
20
|
-
// prevents the custom cursor to be shown
|
|
21
|
-
&.disabled[class] {
|
|
22
|
-
pointer-events: auto;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { createRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { render, screen, userEvent } from '../test-utils';
|
|
4
|
-
|
|
5
|
-
import LegacyButton from './LegacyButton';
|
|
6
|
-
import messages from '../i18n/commonMessages/Button.messages';
|
|
7
|
-
import { ButtonReferenceType } from './Button.types';
|
|
8
|
-
|
|
9
|
-
describe('LegacyButton', () => {
|
|
10
|
-
// eslint-disable-next-line no-console
|
|
11
|
-
const originalWarn = console.warn;
|
|
12
|
-
let mockedWarn: typeof originalWarn;
|
|
13
|
-
|
|
14
|
-
const props = {
|
|
15
|
-
onClick: jest.fn(),
|
|
16
|
-
onFocus: jest.fn(),
|
|
17
|
-
onBlur: jest.fn(),
|
|
18
|
-
children: 'Send money',
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
beforeAll(() => {
|
|
22
|
-
mockedWarn = jest.fn().mockImplementation((args) => {
|
|
23
|
-
if (typeof args !== 'string' || !args.startsWith('Button has deprecated the')) {
|
|
24
|
-
originalWarn(args);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
// eslint-disable-next-line no-console
|
|
28
|
-
console.warn = mockedWarn;
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
beforeEach(jest.clearAllMocks);
|
|
32
|
-
|
|
33
|
-
afterAll(() => {
|
|
34
|
-
// eslint-disable-next-line no-console
|
|
35
|
-
console.warn = originalWarn;
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe('by default', () => {
|
|
39
|
-
it('renders the text', () => {
|
|
40
|
-
render(<LegacyButton {...props} />);
|
|
41
|
-
expect(screen.getByText(props.children)).toBeInTheDocument();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('set `ref` to be true on Button', () => {
|
|
45
|
-
const reference = createRef<ButtonReferenceType>();
|
|
46
|
-
|
|
47
|
-
expect(reference.current).toBeFalsy();
|
|
48
|
-
render(<LegacyButton ref={reference}>Click me!</LegacyButton>);
|
|
49
|
-
expect(reference.current).toBeTruthy();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('is not disabled', () => {
|
|
53
|
-
render(<LegacyButton {...props} />);
|
|
54
|
-
expect(screen.getByRole('button')).toBeEnabled();
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe('button attributes', () => {
|
|
59
|
-
it('sets the htmlType if set', () => {
|
|
60
|
-
render(<LegacyButton {...props} htmlType="submit" />);
|
|
61
|
-
expect(screen.getByRole('button')).toHaveAttribute('type', 'submit');
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('passes through custom classes if set', () => {
|
|
65
|
-
render(<LegacyButton {...props} className="donkeysarethebest" />);
|
|
66
|
-
expect(screen.getByRole('button')).toHaveClass('donkeysarethebest');
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('passes through aria-label if set', () => {
|
|
70
|
-
render(<LegacyButton {...props} aria-label="unique label" />);
|
|
71
|
-
const loadingButton = screen.getByLabelText('unique label');
|
|
72
|
-
expect(loadingButton).toBeInTheDocument();
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
describe('onClick', () => {
|
|
77
|
-
it('calls onClick when clicked', async () => {
|
|
78
|
-
render(<LegacyButton {...props} />);
|
|
79
|
-
await userEvent.click(screen.getByRole('button'));
|
|
80
|
-
expect(props.onClick).toHaveBeenCalledTimes(1);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('does not call onClick when clicked if disabled', async () => {
|
|
84
|
-
render(<LegacyButton {...props} disabled />);
|
|
85
|
-
await userEvent.click(screen.getByRole('button'));
|
|
86
|
-
expect(props.onClick).toHaveBeenCalledTimes(0);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('does not call onClick when clicked if loading', async () => {
|
|
90
|
-
render(<LegacyButton {...props} loading />);
|
|
91
|
-
await userEvent.click(screen.getByRole('button'));
|
|
92
|
-
expect(props.onClick).toHaveBeenCalledTimes(0);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
describe('onFocus and onBlur', () => {
|
|
97
|
-
it('calls both handlers by default', async () => {
|
|
98
|
-
render(<LegacyButton {...props} />);
|
|
99
|
-
await userEvent.tab();
|
|
100
|
-
expect(props.onFocus).toHaveBeenCalledTimes(1);
|
|
101
|
-
await userEvent.tab();
|
|
102
|
-
expect(props.onFocus).toHaveBeenCalledTimes(1);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('does not call either handler if disabled', async () => {
|
|
106
|
-
render(<LegacyButton {...props} disabled />);
|
|
107
|
-
await userEvent.tab();
|
|
108
|
-
expect(props.onFocus).not.toHaveBeenCalled();
|
|
109
|
-
await userEvent.tab();
|
|
110
|
-
expect(props.onFocus).not.toHaveBeenCalled();
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('calls both handlers if loading', async () => {
|
|
114
|
-
render(<LegacyButton {...props} loading />);
|
|
115
|
-
await userEvent.tab();
|
|
116
|
-
expect(props.onFocus).toHaveBeenCalledTimes(1);
|
|
117
|
-
await userEvent.tab();
|
|
118
|
-
expect(props.onFocus).toHaveBeenCalledTimes(1);
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
describe('other states', () => {
|
|
123
|
-
it('renders as loading if `loading` is true', () => {
|
|
124
|
-
render(<LegacyButton {...props} loading />);
|
|
125
|
-
const button = screen.queryByRole('button', {
|
|
126
|
-
name: messages.loadingAriaLabel.defaultMessage,
|
|
127
|
-
});
|
|
128
|
-
expect(button).toBeInTheDocument();
|
|
129
|
-
expect(button).toBeEnabled();
|
|
130
|
-
expect(button).toHaveClass('btn-loading');
|
|
131
|
-
expect(button).toHaveAttribute('aria-disabled', 'true');
|
|
132
|
-
expect(button).toHaveAttribute('aria-busy', 'true');
|
|
133
|
-
expect(button).toHaveAttribute('aria-live', 'polite');
|
|
134
|
-
expect(screen.getByTestId('ButtonProgressIndicator')).toBeInTheDocument();
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it('disables the button', () => {
|
|
138
|
-
render(<LegacyButton {...props} disabled />);
|
|
139
|
-
const button = screen.queryByRole('button');
|
|
140
|
-
expect(button).toBeDisabled();
|
|
141
|
-
expect(button).toHaveClass('disabled');
|
|
142
|
-
expect(button).toHaveAttribute('aria-disabled', 'false');
|
|
143
|
-
expect(button).toHaveAttribute('aria-busy', 'false');
|
|
144
|
-
expect(button).toHaveAttribute('aria-live', 'off');
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
});
|