@transferwise/components 0.0.0-experimental-9e19bae → 0.0.0-experimental-b762045

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/build/avatarLayout/AvatarLayout.js +2 -9
  2. package/build/avatarLayout/AvatarLayout.js.map +1 -1
  3. package/build/avatarLayout/AvatarLayout.mjs +2 -9
  4. package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
  5. package/build/button/Button.js +97 -76
  6. package/build/button/Button.js.map +1 -1
  7. package/build/button/Button.mjs +97 -76
  8. package/build/button/Button.mjs.map +1 -1
  9. package/build/circularButton/CircularButton.js +19 -24
  10. package/build/circularButton/CircularButton.js.map +1 -1
  11. package/build/circularButton/CircularButton.mjs +20 -25
  12. package/build/circularButton/CircularButton.mjs.map +1 -1
  13. package/build/criticalBanner/CriticalCommsBanner.js +2 -2
  14. package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
  15. package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
  16. package/build/definitionList/DefinitionList.js.map +1 -1
  17. package/build/definitionList/DefinitionList.mjs.map +1 -1
  18. package/build/header/Header.js +2 -2
  19. package/build/header/Header.js.map +1 -1
  20. package/build/header/Header.mjs +1 -1
  21. package/build/i18n/de.json +1 -0
  22. package/build/i18n/de.json.js +1 -0
  23. package/build/i18n/de.json.js.map +1 -1
  24. package/build/i18n/de.json.mjs +1 -0
  25. package/build/i18n/de.json.mjs.map +1 -1
  26. package/build/i18n/it.json +1 -0
  27. package/build/i18n/it.json.js +1 -0
  28. package/build/i18n/it.json.js.map +1 -1
  29. package/build/i18n/it.json.mjs +1 -0
  30. package/build/i18n/it.json.mjs.map +1 -1
  31. package/build/i18n/th.json +1 -0
  32. package/build/i18n/th.json.js +1 -0
  33. package/build/i18n/th.json.js.map +1 -1
  34. package/build/i18n/th.json.mjs +1 -0
  35. package/build/i18n/th.json.mjs.map +1 -1
  36. package/build/index.js +2 -2
  37. package/build/index.mjs +1 -1
  38. package/build/link/Link.js +3 -8
  39. package/build/link/Link.js.map +1 -1
  40. package/build/link/Link.mjs +3 -8
  41. package/build/link/Link.mjs.map +1 -1
  42. package/build/main.css +17 -431
  43. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +3 -1
  44. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
  45. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +3 -1
  46. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
  47. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +4 -1
  48. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
  49. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +4 -1
  50. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
  51. package/build/select/Select.js +3 -5
  52. package/build/select/Select.js.map +1 -1
  53. package/build/select/Select.mjs +2 -4
  54. package/build/select/Select.mjs.map +1 -1
  55. package/build/styles/avatarLayout/AvatarLayout.css +0 -11
  56. package/build/styles/button/Button.css +16 -255
  57. package/build/styles/circularButton/CircularButton.css +17 -158
  58. package/build/styles/main.css +17 -431
  59. package/build/types/avatarLayout/AvatarLayout.d.ts +2 -1
  60. package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
  61. package/build/types/avatarLayout/index.d.ts +0 -1
  62. package/build/types/avatarLayout/index.d.ts.map +1 -1
  63. package/build/types/button/Button.d.ts +23 -1
  64. package/build/types/button/Button.d.ts.map +1 -1
  65. package/build/types/button/index.d.ts +2 -2
  66. package/build/types/button/index.d.ts.map +1 -1
  67. package/build/types/circularButton/CircularButton.d.ts +11 -4
  68. package/build/types/circularButton/CircularButton.d.ts.map +1 -1
  69. package/build/types/definitionList/DefinitionList.d.ts +1 -2
  70. package/build/types/definitionList/DefinitionList.d.ts.map +1 -1
  71. package/build/types/link/Link.d.ts +2 -2
  72. package/build/types/link/Link.d.ts.map +1 -1
  73. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
  74. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +1 -1
  75. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
  76. package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
  77. package/build/types/select/Select.d.ts.map +1 -1
  78. package/build/upload/steps/completeStep/completeStep.js +2 -2
  79. package/build/upload/steps/completeStep/completeStep.js.map +1 -1
  80. package/build/upload/steps/completeStep/completeStep.mjs +1 -1
  81. package/build/upload/steps/processingStep/processingStep.js +2 -2
  82. package/build/upload/steps/processingStep/processingStep.js.map +1 -1
  83. package/build/upload/steps/processingStep/processingStep.mjs +1 -1
  84. package/build/uploadInput/UploadInput.js +3 -3
  85. package/build/uploadInput/UploadInput.js.map +1 -1
  86. package/build/uploadInput/UploadInput.mjs +1 -1
  87. package/package.json +3 -3
  88. package/src/avatarLayout/AvatarLayout.css +0 -11
  89. package/src/avatarLayout/AvatarLayout.less +1 -18
  90. package/src/avatarLayout/AvatarLayout.tsx +3 -11
  91. package/src/avatarLayout/index.ts +0 -1
  92. package/src/button/Button.css +16 -255
  93. package/src/button/Button.less +14 -215
  94. package/src/button/Button.spec.tsx +231 -54
  95. package/src/button/Button.story.tsx +136 -287
  96. package/src/button/Button.tsx +131 -84
  97. package/src/button/__snapshots__/{LegacyButton.spec.tsx.snap → Button.spec.tsx.snap} +22 -22
  98. package/src/button/index.ts +3 -2
  99. package/src/circularButton/CircularButton.css +17 -158
  100. package/src/circularButton/CircularButton.less +22 -91
  101. package/src/circularButton/CircularButton.story.tsx +45 -24
  102. package/src/circularButton/CircularButton.tsx +39 -28
  103. package/src/definitionList/DefinitionList.story.tsx +57 -57
  104. package/src/definitionList/DefinitionList.tsx +1 -1
  105. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -1
  106. package/src/i18n/de.json +1 -0
  107. package/src/i18n/it.json +1 -0
  108. package/src/i18n/th.json +1 -0
  109. package/src/iconButton/IconButton.story.tsx +6 -6
  110. package/src/inputs/SelectInput.story.tsx +1 -1
  111. package/src/link/Link.tsx +6 -15
  112. package/src/main.css +17 -431
  113. package/src/main.less +0 -1
  114. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +7 -1
  115. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +1 -1
  116. package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +3 -1
  117. package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +8 -1
  118. package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +5 -2
  119. package/src/select/Select.tsx +0 -1
  120. package/src/slidingPanel/SlidingPanel.spec.tsx +69 -0
  121. package/build/button/Button.resolver.js +0 -78
  122. package/build/button/Button.resolver.js.map +0 -1
  123. package/build/button/Button.resolver.mjs +0 -76
  124. package/build/button/Button.resolver.mjs.map +0 -1
  125. package/build/button/LegacyButton.js +0 -114
  126. package/build/button/LegacyButton.js.map +0 -1
  127. package/build/button/LegacyButton.mjs +0 -112
  128. package/build/button/LegacyButton.mjs.map +0 -1
  129. package/build/styles/button/Button.vars.css +0 -59
  130. package/build/styles/button/LegacyButton.css +0 -23
  131. package/build/types/button/Button.resolver.d.ts +0 -31
  132. package/build/types/button/Button.resolver.d.ts.map +0 -1
  133. package/build/types/button/Button.types.d.ts +0 -58
  134. package/build/types/button/Button.types.d.ts.map +0 -1
  135. package/build/types/button/LegacyButton.d.ts +0 -30
  136. package/build/types/button/LegacyButton.d.ts.map +0 -1
  137. package/src/button/Button.resolver.tsx +0 -120
  138. package/src/button/Button.types.ts +0 -79
  139. package/src/button/Button.vars.css +0 -59
  140. package/src/button/Button.vars.less +0 -73
  141. package/src/button/LegacyButton.css +0 -23
  142. package/src/button/LegacyButton.less +0 -24
  143. package/src/button/LegacyButton.spec.tsx +0 -245
  144. package/src/button/LegacyButton.story.tsx +0 -224
  145. package/src/button/LegacyButton.tsx +0 -161
  146. package/src/circularButton/_button-label-states.less +0 -34
  147. package/src/definitionList/DefinitionList.spec.js +0 -91
  148. package/src/slidingPanel/SlidingPanel.spec.js +0 -56
@@ -1,30 +0,0 @@
1
- import { ControlTypeAccent, ControlTypeNegative, ControlTypePositive, PriorityPrimary, PrioritySecondary, PriorityTertiary, SizeExtraSmall, SizeSmall, SizeMedium, SizeLarge } from '../common';
2
- /** @deprecated */
3
- type DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';
4
- /** @deprecated */
5
- type DeprecatedSizes = SizeExtraSmall;
6
- type CommonProps = {
7
- block?: boolean;
8
- disabled?: boolean;
9
- loading?: boolean;
10
- /** @deprecated */
11
- type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;
12
- priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;
13
- size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;
14
- htmlType?: 'submit' | 'reset' | 'button';
15
- };
16
- export type ButtonProps = CommonProps & Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {
17
- as?: 'button';
18
- };
19
- export type AnchorProps = CommonProps & Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {
20
- as?: 'a';
21
- href?: string;
22
- };
23
- export type LegacyButtonProps = ButtonProps | AnchorProps;
24
- export type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;
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;AAOnB,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,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kBAAkB;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,MAAM,MAAM,WAAW,GAAG,WAAW,GACnC,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,GAAG;IACpD,EAAE,CAAC,EAAE,QAAQ,CAAC;CACf,CAAC;AAEJ,MAAM,MAAM,WAAW,GAAG,WAAW,GACnC,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,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AAExE;;GAEG;AACH,QAAA,MAAM,YAAY,uJAkGjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,120 +0,0 @@
1
- import { forwardRef } from 'react';
2
- import LegacyButton, { LegacyButtonProps } from './LegacyButton';
3
- import { ButtonProps as NewButtonProps } from './Button.types';
4
- import NewButton from './Button';
5
-
6
- type LegacyButtonType =
7
- | 'accent'
8
- | 'negative'
9
- | 'positive'
10
- | 'primary'
11
- | 'pay'
12
- | 'secondary'
13
- | 'danger'
14
- | 'link'
15
- | null
16
- | undefined;
17
-
18
- type NewButtonType = 'button' | 'submit' | 'reset' | LegacyButtonType | undefined;
19
-
20
- type CommonButtonProps = {
21
- href?: string;
22
- target?: string;
23
- ref?: React.Ref<HTMLButtonElement | HTMLAnchorElement>;
24
- };
25
-
26
- export type ButtonProps =
27
- | (Omit<LegacyButtonProps, 'ref'> &
28
- CommonButtonProps & {
29
- priority?: LegacyButtonProps['priority'];
30
- type?: LegacyButtonType;
31
- htmlType?: string;
32
- v2?: false;
33
- })
34
- | (Omit<Omit<NewButtonProps, 'type'>, 'ref'> &
35
- CommonButtonProps & {
36
- priority?: NewButtonProps['priority'];
37
- type?: NewButtonType;
38
- v2: true;
39
- });
40
-
41
- const mapProps = (props: LegacyButtonProps): NewButtonProps => {
42
- const { priority, size, type, as, ...newProps } = props;
43
-
44
- const priorityMapping: Record<string, Record<string, NewButtonProps['priority']>> = {
45
- accent: {
46
- primary: 'primary',
47
- secondary: 'tertiary',
48
- tertiary: 'minimal',
49
- },
50
- positive: {
51
- primary: 'primary',
52
- secondary: 'tertiary',
53
- tertiary: 'tertiary',
54
- },
55
- negative: {
56
- primary: 'primary',
57
- secondary: 'secondary',
58
- tertiary: 'secondary',
59
- },
60
- };
61
-
62
- const mappedPriority =
63
- type && priority ? priorityMapping[type]?.[priority] || priority : priority || null;
64
- const mappedSentiment = type === 'negative' ? 'negative' : null;
65
-
66
- const legacyButtonTypes: LegacyButtonType[] = [
67
- 'accent',
68
- 'negative',
69
- 'positive',
70
- 'primary',
71
- 'pay',
72
- 'secondary',
73
- 'danger',
74
- 'link',
75
- ];
76
-
77
- const resolveSize = () => {
78
- if (size) {
79
- return { xs: 'sm', sm: 'sm', md: 'md', lg: 'lg' }[size] || size;
80
- }
81
-
82
- return size;
83
- };
84
-
85
- return {
86
- ...newProps,
87
- size: resolveSize(),
88
- priority: mappedPriority,
89
- sentiment: mappedSentiment || ('sentiment' in props ? props.sentiment : null),
90
- type:
91
- type && !legacyButtonTypes.includes(type as LegacyButtonType) ? type : props.htmlType || null,
92
- href: as === 'a' ? props.href || '' : null,
93
- } as NewButtonProps;
94
- };
95
-
96
- const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>((props, ref) => {
97
- const { v2 = false, as, ...rest } = props;
98
-
99
- if (v2) {
100
- const mappedProps = mapProps(props as LegacyButtonProps);
101
- return (
102
- <NewButton
103
- {...mappedProps}
104
- ref={ref as React.Ref<HTMLButtonElement | HTMLAnchorElement>}
105
- as={as}
106
- />
107
- );
108
- }
109
-
110
- return (
111
- <LegacyButton
112
- {...(rest as LegacyButtonProps)}
113
- ref={ref as React.Ref<HTMLButtonElement | HTMLAnchorElement>}
114
- />
115
- );
116
- });
117
-
118
- Button.displayName = 'Button';
119
-
120
- export default Button;
@@ -1,79 +0,0 @@
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 ButtonSentiment = 'default' | 'negative';
11
- export type ButtonPriority = 'primary' | 'secondary' | 'tertiary' | 'minimal';
12
- export type ButtonType = 'button' | 'submit' | 'reset';
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
- /**
21
- * If set, toggles the new Button API
22
- * @default false
23
- * */
24
- v2?: boolean;
25
-
26
- /** The HTML element to render */
27
- as?: 'button' | 'a' | null;
28
-
29
- /** Additional class name(s) to apply to the button */
30
- className?: string;
31
-
32
- /** Whether the button is disabled */
33
- disabled?: boolean;
34
-
35
- href?: string;
36
-
37
- /** Whether the button is in a loading state */
38
- loading?: boolean;
39
-
40
- /** Whether the button should take up the full width of its container */
41
- block?: boolean;
42
-
43
- /**
44
- * Size of the button
45
- * @default lg
46
- * */
47
- size?: ButtonSize;
48
-
49
- /**
50
- * Priority of the button
51
- * @default "primary"
52
- */
53
- priority?: ButtonPriority;
54
-
55
- /**
56
- * Sentiment of the button
57
- * @default default
58
- */
59
- sentiment?: ButtonSentiment;
60
-
61
- /** Icon to be displayed on the left side of the button */
62
- iconStart?: React.ElementType;
63
-
64
- /** Icon to be displayed on the right side of the button */
65
- iconEnd?: React.ElementType;
66
-
67
- /** Media to be displayed on the left side of the button */
68
- avatars?: SingleAvatarType[];
69
-
70
- /** Optional property to provide component Ref */
71
- ref?: ButtonRefType;
72
-
73
- /** Content to be displayed inside the button */
74
- children?: ReactNode;
75
- }
76
-
77
- export type ButtonElementProps = PrimitiveButtonProps & CommonButtonProps;
78
- export type AnchorElementProps = PrimitiveAnchorProps & CommonButtonProps;
79
- export type ButtonProps = ButtonElementProps | AnchorElementProps;
@@ -1,59 +0,0 @@
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-transition-duration: 150ms;
17
- --Button-transition-easing: ease-in-out;
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
- --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
- --Button-minimal-background: transparent;
27
- --Button-minimal-background-hover: var(--color-background-screen-hover);
28
- --Button-minimal-background-active: var(--color-background-screen-active);
29
- --Button-minimal-color: var(--color-interactive-primary);
30
- --Button-primary-negative-background: var(--color-sentiment-negative-primary);
31
- --Button-primary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
32
- --Button-primary-negative-background-active: var(--color-sentiment-negative-primary-active);
33
- --Button-primary-negative-color: var(--color-contrast);
34
- --Button-primary-netative-avatar-border-color: rgba(255,255,255,0.2);
35
- --Button-secondary-negative-background: var(--color-sentiment-negative-secondary);
36
- --Button-secondary-negative-background-hover: var(--color-sentiment-negative-secondary-hover);
37
- --Button-secondary-negative-background-active: var(--color-sentiment-negative-secondary-active);
38
- --Button-secondary-negative-color: var(--color-sentiment-negative-primary);
39
- --Button-secondary-netative-avatar-border-color: rgba(168,32,13,0.12157);
40
- }
41
- .np-theme-personal--dark .wds-Button {
42
- --Button-primary-netative-avatar-border-color: rgba(14,15,12,0.12157);
43
- }
44
- .np-theme-personal--forest-green .wds-Button {
45
- --color-interactive-neutral: rgba(159,232,112,0.2);
46
- --color-interactive-neutral-hover: rgba(205,255,173,0.2);
47
- --color-interactive-neutral-active: rgba(236,255,224,0.2);
48
- --color-sentiment-negative-secondary: rgba(255,196,194,0.2);
49
- --color-sentiment-negative-secondary-hover: rgba(255,220,219,0.2);
50
- --color-sentiment-negative-secondary-active: rgba(255,235,235,0.2);
51
- --Button-primary-netative-avatar-border-color: rgba(14,15,12,0.12157);
52
- --Button-secondary-netative-avatar-border-color: rgba(14,15,12,0.12157);
53
- }
54
- .np-theme-personal--bright-green .wds-Button {
55
- --color-contrast: #FFFFFF;
56
- --Button-secondary-color: var(--color-interactive-control);
57
- --Button-secondary-negative-color: var(--color-contrast);
58
- --Button-secondary-netative-avatar-border-color: var(--Button-primary-netative-avatar-border-color);
59
- }
@@ -1,73 +0,0 @@
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-transition-duration: 150ms;
17
- --Button-transition-easing: ease-in-out;
18
-
19
- --Button-secondary-background: var(--color-interactive-neutral);
20
- --Button-secondary-background-hover: var(--color-interactive-neutral-hover);
21
- --Button-secondary-background-active: var(--color-interactive-neutral-active);
22
- --Button-secondary-color: var(--color-interactive-primary);
23
-
24
- --Button-tertiary-background: var(--color-background-neutral);
25
- --Button-tertiary-background-hover: var(--color-background-neutral-hover);
26
- --Button-tertiary-background-active: var(--color-background-neutral-active);
27
- --Button-tertiary-color: var(--color-content-primary);
28
-
29
- --Button-minimal-background: transparent;
30
- --Button-minimal-background-hover: var(--color-background-screen-hover);
31
- --Button-minimal-background-active: var(--color-background-screen-active);
32
- --Button-minimal-color: var(--color-interactive-primary);
33
-
34
- --Button-primary-negative-background: var(--color-sentiment-negative-primary);
35
- --Button-primary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
36
- --Button-primary-negative-background-active: var(--color-sentiment-negative-primary-active);
37
- --Button-primary-negative-color: var(--color-contrast);
38
- --Button-primary-netative-avatar-border-color: #FFFFFF33;
39
-
40
- --Button-secondary-negative-background: var(--color-sentiment-negative-secondary);
41
- --Button-secondary-negative-background-hover: var(--color-sentiment-negative-secondary-hover);
42
- --Button-secondary-negative-background-active: var(--color-sentiment-negative-secondary-active);
43
- --Button-secondary-negative-color: var(--color-sentiment-negative-primary);
44
- --Button-secondary-netative-avatar-border-color: #A8200D1F;
45
- }
46
-
47
- .np-theme-personal--dark {
48
- .wds-Button {
49
- --Button-primary-netative-avatar-border-color: #0E0F0C1F;
50
- }
51
- }
52
-
53
- .np-theme-personal--forest-green {
54
- .wds-Button {
55
- --color-interactive-neutral: #9FE87033;
56
- --color-interactive-neutral-hover: #CDFFAD33;
57
- --color-interactive-neutral-active: #ECFFE033;
58
- --color-sentiment-negative-secondary: #FFC4C233;
59
- --color-sentiment-negative-secondary-hover: #FFDCDB33;
60
- --color-sentiment-negative-secondary-active: #FFEBEB33;
61
- --Button-primary-netative-avatar-border-color: #0E0F0C1F;
62
- --Button-secondary-netative-avatar-border-color: #0E0F0C1F;
63
- }
64
- }
65
-
66
- .np-theme-personal--bright-green {
67
- .wds-Button {
68
- --color-contrast: #FFFFFF;
69
- --Button-secondary-color: var(--color-interactive-control);
70
- --Button-secondary-negative-color: var(--color-contrast);
71
- --Button-secondary-netative-avatar-border-color: var(--Button-primary-netative-avatar-border-color);
72
- }
73
- }
@@ -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,245 +0,0 @@
1
- import { createRef } from 'react';
2
-
3
- import { ControlType, Type, Priority, Size } from '../common';
4
- import { render, screen, userEvent } from '../test-utils';
5
-
6
- import LegacyButton, { ButtonReferenceType } from './LegacyButton';
7
- import messages from '../i18n/commonMessages/Button.messages';
8
-
9
- const { ACCENT, POSITIVE, NEGATIVE } = ControlType;
10
- const { PAY, LINK, DANGER } = Type;
11
- const { PRIMARY, SECONDARY, TERTIARY } = Priority;
12
- const { SMALL, MEDIUM, LARGE } = Size;
13
-
14
- describe('LegacyButton', () => {
15
- // eslint-disable-next-line no-console
16
- const originalWarn = console.warn;
17
- let mockedWarn: typeof originalWarn;
18
-
19
- const props = {
20
- onClick: jest.fn(),
21
- onFocus: jest.fn(),
22
- onBlur: jest.fn(),
23
- children: 'Send money',
24
- };
25
-
26
- beforeAll(() => {
27
- mockedWarn = jest.fn().mockImplementation((args) => {
28
- if (typeof args !== 'string' || !args.startsWith('Button has deprecated the')) {
29
- originalWarn(args);
30
- }
31
- });
32
- // eslint-disable-next-line no-console
33
- console.warn = mockedWarn;
34
- });
35
-
36
- beforeEach(jest.clearAllMocks);
37
-
38
- afterAll(() => {
39
- // eslint-disable-next-line no-console
40
- console.warn = originalWarn;
41
- });
42
-
43
- describe('by default', () => {
44
- it('renders the text', () => {
45
- render(<LegacyButton {...props} />);
46
- expect(screen.getByText(props.children)).toBeInTheDocument();
47
- });
48
-
49
- it('set `ref` to be true on Button', () => {
50
- const reference = createRef<ButtonReferenceType>();
51
-
52
- expect(reference.current).toBeFalsy();
53
- render(<LegacyButton ref={reference}>Click me!</LegacyButton>);
54
- expect(reference.current).toBeTruthy();
55
- });
56
-
57
- it('is not disabled', () => {
58
- render(<LegacyButton {...props} />);
59
- expect(screen.getByRole('button')).toBeEnabled();
60
- });
61
-
62
- it('renders a medium button of type accent and priority primary', () => {
63
- expect(render(<LegacyButton {...props} />).container).toMatchSnapshot();
64
- });
65
-
66
- it('renders an anchor tag with button styles of type accent and priority primary', () => {
67
- expect(render(<LegacyButton {...props} as="a" href="#" />).container).toMatchSnapshot();
68
- });
69
- });
70
-
71
- describe('button attributes', () => {
72
- it('sets the htmlType if set', () => {
73
- render(<LegacyButton {...props} htmlType="submit" />);
74
- expect(screen.getByRole('button')).toHaveAttribute('type', 'submit');
75
- });
76
-
77
- it('passes through custom classes if set', () => {
78
- render(<LegacyButton {...props} className="donkeysarethebest" />);
79
- expect(screen.getByRole('button')).toHaveClass('donkeysarethebest');
80
- });
81
-
82
- it('passes through aria-label if set', () => {
83
- render(<LegacyButton {...props} aria-label="unique label" />);
84
- const loadingButton = screen.getByLabelText('unique label');
85
- expect(loadingButton).toBeInTheDocument();
86
- });
87
- });
88
-
89
- describe('onClick', () => {
90
- it('calls onClick when clicked', async () => {
91
- render(<LegacyButton {...props} />);
92
- await userEvent.click(screen.getByRole('button'));
93
- expect(props.onClick).toHaveBeenCalledTimes(1);
94
- });
95
-
96
- it('does not call onClick when clicked if disabled', async () => {
97
- render(<LegacyButton {...props} disabled />);
98
- await userEvent.click(screen.getByRole('button'));
99
- expect(props.onClick).toHaveBeenCalledTimes(0);
100
- });
101
-
102
- it('does not call onClick when clicked if loading', async () => {
103
- render(<LegacyButton {...props} loading />);
104
- await userEvent.click(screen.getByRole('button'));
105
- expect(props.onClick).toHaveBeenCalledTimes(0);
106
- });
107
- });
108
-
109
- describe('onFocus and onBlur', () => {
110
- it('calls both handlers by default', async () => {
111
- render(<LegacyButton {...props} />);
112
- await userEvent.tab();
113
- expect(props.onFocus).toHaveBeenCalledTimes(1);
114
- await userEvent.tab();
115
- expect(props.onFocus).toHaveBeenCalledTimes(1);
116
- });
117
-
118
- it('does not call either handler if disabled', async () => {
119
- render(<LegacyButton {...props} disabled />);
120
- await userEvent.tab();
121
- expect(props.onFocus).not.toHaveBeenCalled();
122
- await userEvent.tab();
123
- expect(props.onFocus).not.toHaveBeenCalled();
124
- });
125
-
126
- it('calls both handlers if loading', async () => {
127
- render(<LegacyButton {...props} loading />);
128
- await userEvent.tab();
129
- expect(props.onFocus).toHaveBeenCalledTimes(1);
130
- await userEvent.tab();
131
- expect(props.onFocus).toHaveBeenCalledTimes(1);
132
- });
133
- });
134
-
135
- describe('sizes', () => {
136
- it('renders small buttons', () => {
137
- expect(render(<LegacyButton {...props} size={SMALL} />).container).toMatchSnapshot();
138
- });
139
-
140
- it('renders medium buttons', () => {
141
- expect(render(<LegacyButton {...props} size={MEDIUM} />).container).toMatchSnapshot();
142
- });
143
-
144
- it('renders large buttons', () => {
145
- expect(render(<LegacyButton {...props} size={LARGE} />).container).toMatchSnapshot();
146
- });
147
- });
148
-
149
- describe('types', () => {
150
- it('renders accent buttons', () => {
151
- expect(render(<LegacyButton {...props} type={ACCENT} />).container).toMatchSnapshot();
152
- });
153
-
154
- it('renders positive buttons', () => {
155
- expect(render(<LegacyButton {...props} type={POSITIVE} />).container).toMatchSnapshot();
156
- });
157
-
158
- it('renders negative buttons', () => {
159
- expect(render(<LegacyButton {...props} type={NEGATIVE} />).container).toMatchSnapshot();
160
- });
161
- });
162
-
163
- describe('priorities', () => {
164
- it('renders primary buttons', () => {
165
- [ACCENT, POSITIVE, NEGATIVE].forEach((type) =>
166
- expect(
167
- render(<LegacyButton {...props} priority={PRIMARY} type={type} />).container,
168
- ).toMatchSnapshot(),
169
- );
170
- });
171
-
172
- it('renders secondary buttons', () => {
173
- [ACCENT, POSITIVE, NEGATIVE].forEach((type) =>
174
- expect(
175
- render(<LegacyButton {...props} priority={SECONDARY} type={type} />).container,
176
- ).toMatchSnapshot(),
177
- );
178
- });
179
-
180
- it('renders tertiary buttons', () => {
181
- expect(
182
- render(<LegacyButton {...props} priority={TERTIARY} type={ACCENT} />).container,
183
- ).toMatchSnapshot();
184
- });
185
-
186
- it('defaults tertiary buttons to secondary for positive buttons', () => {
187
- [POSITIVE, NEGATIVE].forEach((type) =>
188
- expect(
189
- render(<LegacyButton {...props} priority={TERTIARY} type={type} />).container,
190
- ).toMatchSnapshot(),
191
- );
192
- });
193
- });
194
-
195
- describe('other states', () => {
196
- it('renders as loading if `loading` is true', () => {
197
- render(<LegacyButton {...props} loading />);
198
- const button = screen.queryByRole('button', {
199
- name: messages.loadingAriaLabel.defaultMessage,
200
- });
201
- expect(button).toBeInTheDocument();
202
- expect(button).toBeEnabled();
203
- expect(button).toHaveClass('btn-loading');
204
- expect(button).toHaveAttribute('aria-disabled', 'true');
205
- expect(button).toHaveAttribute('aria-busy', 'true');
206
- expect(button).toHaveAttribute('aria-live', 'polite');
207
- expect(screen.getByTestId('ButtonProgressIndicator')).toBeInTheDocument();
208
- });
209
-
210
- it('disables the button', () => {
211
- render(<LegacyButton {...props} disabled />);
212
- const button = screen.queryByRole('button');
213
- expect(button).toBeDisabled();
214
- expect(button).toHaveClass('disabled');
215
- expect(button).toHaveAttribute('aria-disabled', 'false');
216
- expect(button).toHaveAttribute('aria-busy', 'false');
217
- expect(button).toHaveAttribute('aria-live', 'off');
218
- });
219
-
220
- it('renders as block if block is true', () => {
221
- expect(render(<LegacyButton {...props} block />).container).toMatchSnapshot();
222
- });
223
- });
224
-
225
- describe('deprecated types', () => {
226
- it('renders primary as accent buttons and logs a warning', () => {
227
- expect(render(<LegacyButton {...props} type={PRIMARY} />).container).toMatchSnapshot();
228
- expect(mockedWarn).toHaveBeenCalledTimes(1);
229
- });
230
-
231
- it('renders pay as positive buttons and logs a warning', () => {
232
- expect(render(<LegacyButton {...props} type={PAY} />).container).toMatchSnapshot();
233
- expect(mockedWarn).toHaveBeenCalledTimes(1);
234
- });
235
-
236
- it('renders danger as negative buttons with priority secondary and logs a warning', () => {
237
- expect(render(<LegacyButton {...props} type={DANGER} />).container).toMatchSnapshot();
238
- expect(mockedWarn).toHaveBeenCalledTimes(1);
239
- });
240
-
241
- it('renders link as accent buttons with priority tertiary and logs a warning', () => {
242
- expect(render(<LegacyButton {...props} type={LINK} />).container).toMatchSnapshot();
243
- });
244
- });
245
- });