@transferwise/components 0.0.0-experimental-58ab0d7 → 0.0.0-experimental-4530892

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 (179) 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/avatarView/AvatarView.js +12 -1
  6. package/build/avatarView/AvatarView.js.map +1 -1
  7. package/build/avatarView/AvatarView.mjs +12 -1
  8. package/build/avatarView/AvatarView.mjs.map +1 -1
  9. package/build/button/Button.js +79 -78
  10. package/build/button/Button.js.map +1 -1
  11. package/build/button/Button.mjs +80 -79
  12. package/build/button/Button.mjs.map +1 -1
  13. package/build/circularButton/CircularButton.js +18 -21
  14. package/build/circularButton/CircularButton.js.map +1 -1
  15. package/build/circularButton/CircularButton.mjs +19 -22
  16. package/build/circularButton/CircularButton.mjs.map +1 -1
  17. package/build/criticalBanner/CriticalCommsBanner.js +2 -2
  18. package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
  19. package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
  20. package/build/definitionList/DefinitionList.js.map +1 -1
  21. package/build/definitionList/DefinitionList.mjs.map +1 -1
  22. package/build/header/Header.js +2 -2
  23. package/build/header/Header.js.map +1 -1
  24. package/build/header/Header.mjs +1 -1
  25. package/build/i18n/de.json +1 -0
  26. package/build/i18n/de.json.js +1 -0
  27. package/build/i18n/de.json.js.map +1 -1
  28. package/build/i18n/de.json.mjs +1 -0
  29. package/build/i18n/de.json.mjs.map +1 -1
  30. package/build/i18n/it.json +1 -0
  31. package/build/i18n/it.json.js +1 -0
  32. package/build/i18n/it.json.js.map +1 -1
  33. package/build/i18n/it.json.mjs +1 -0
  34. package/build/i18n/it.json.mjs.map +1 -1
  35. package/build/i18n/ja.json +1 -0
  36. package/build/i18n/ja.json.js +1 -0
  37. package/build/i18n/ja.json.js.map +1 -1
  38. package/build/i18n/ja.json.mjs +1 -0
  39. package/build/i18n/ja.json.mjs.map +1 -1
  40. package/build/i18n/pt.json +1 -0
  41. package/build/i18n/pt.json.js +1 -0
  42. package/build/i18n/pt.json.js.map +1 -1
  43. package/build/i18n/pt.json.mjs +1 -0
  44. package/build/i18n/pt.json.mjs.map +1 -1
  45. package/build/i18n/ru.json +1 -0
  46. package/build/i18n/ru.json.js +1 -0
  47. package/build/i18n/ru.json.js.map +1 -1
  48. package/build/i18n/ru.json.mjs +1 -0
  49. package/build/i18n/ru.json.mjs.map +1 -1
  50. package/build/i18n/th.json +1 -0
  51. package/build/i18n/th.json.js +1 -0
  52. package/build/i18n/th.json.js.map +1 -1
  53. package/build/i18n/th.json.mjs +1 -0
  54. package/build/i18n/th.json.mjs.map +1 -1
  55. package/build/i18n/zh-HK.json +1 -0
  56. package/build/i18n/zh-HK.json.js +1 -0
  57. package/build/i18n/zh-HK.json.js.map +1 -1
  58. package/build/i18n/zh-HK.json.mjs +1 -0
  59. package/build/i18n/zh-HK.json.mjs.map +1 -1
  60. package/build/index.js +2 -2
  61. package/build/index.mjs +1 -1
  62. package/build/link/Link.js +3 -8
  63. package/build/link/Link.js.map +1 -1
  64. package/build/link/Link.mjs +3 -8
  65. package/build/link/Link.mjs.map +1 -1
  66. package/build/main.css +17 -419
  67. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +3 -1
  68. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
  69. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +3 -1
  70. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
  71. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +4 -1
  72. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
  73. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +4 -1
  74. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
  75. package/build/select/Select.js +3 -5
  76. package/build/select/Select.js.map +1 -1
  77. package/build/select/Select.mjs +2 -4
  78. package/build/select/Select.mjs.map +1 -1
  79. package/build/styles/avatarLayout/AvatarLayout.css +0 -11
  80. package/build/styles/button/Button.css +16 -243
  81. package/build/styles/circularButton/CircularButton.css +17 -158
  82. package/build/styles/main.css +17 -419
  83. package/build/types/avatarLayout/AvatarLayout.d.ts +2 -1
  84. package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
  85. package/build/types/avatarLayout/index.d.ts +0 -1
  86. package/build/types/avatarLayout/index.d.ts.map +1 -1
  87. package/build/types/avatarView/AvatarView.d.ts.map +1 -1
  88. package/build/types/button/Button.d.ts +23 -1
  89. package/build/types/button/Button.d.ts.map +1 -1
  90. package/build/types/button/index.d.ts +2 -2
  91. package/build/types/button/index.d.ts.map +1 -1
  92. package/build/types/circularButton/CircularButton.d.ts +11 -4
  93. package/build/types/circularButton/CircularButton.d.ts.map +1 -1
  94. package/build/types/definitionList/DefinitionList.d.ts +1 -2
  95. package/build/types/definitionList/DefinitionList.d.ts.map +1 -1
  96. package/build/types/link/Link.d.ts +2 -2
  97. package/build/types/link/Link.d.ts.map +1 -1
  98. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
  99. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +1 -1
  100. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
  101. package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
  102. package/build/types/select/Select.d.ts.map +1 -1
  103. package/build/upload/steps/completeStep/completeStep.js +2 -2
  104. package/build/upload/steps/completeStep/completeStep.js.map +1 -1
  105. package/build/upload/steps/completeStep/completeStep.mjs +1 -1
  106. package/build/upload/steps/processingStep/processingStep.js +2 -2
  107. package/build/upload/steps/processingStep/processingStep.js.map +1 -1
  108. package/build/upload/steps/processingStep/processingStep.mjs +1 -1
  109. package/build/uploadInput/UploadInput.js +3 -3
  110. package/build/uploadInput/UploadInput.js.map +1 -1
  111. package/build/uploadInput/UploadInput.mjs +1 -1
  112. package/package.json +3 -3
  113. package/src/avatarLayout/AvatarLayout.css +0 -11
  114. package/src/avatarLayout/AvatarLayout.less +1 -18
  115. package/src/avatarLayout/AvatarLayout.tsx +3 -11
  116. package/src/avatarLayout/index.ts +0 -1
  117. package/src/avatarView/AvatarView.tsx +15 -1
  118. package/src/button/Button.css +16 -243
  119. package/src/button/Button.less +14 -212
  120. package/src/button/Button.spec.tsx +231 -54
  121. package/src/button/Button.story.tsx +137 -644
  122. package/src/button/Button.tsx +132 -98
  123. package/src/button/__snapshots__/Button.spec.tsx.snap +309 -0
  124. package/src/button/index.ts +3 -2
  125. package/src/circularButton/CircularButton.css +17 -158
  126. package/src/circularButton/CircularButton.less +22 -91
  127. package/src/circularButton/CircularButton.story.tsx +45 -24
  128. package/src/circularButton/CircularButton.tsx +38 -25
  129. package/src/dateInput/DateInput.spec.tsx +45 -26
  130. package/src/definitionList/DefinitionList.story.tsx +57 -57
  131. package/src/definitionList/DefinitionList.tsx +1 -1
  132. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -1
  133. package/src/i18n/de.json +1 -0
  134. package/src/i18n/it.json +1 -0
  135. package/src/i18n/ja.json +1 -0
  136. package/src/i18n/pt.json +1 -0
  137. package/src/i18n/ru.json +1 -0
  138. package/src/i18n/th.json +1 -0
  139. package/src/i18n/zh-HK.json +1 -0
  140. package/src/iconButton/IconButton.story.tsx +6 -6
  141. package/src/inputs/SelectInput.story.tsx +1 -1
  142. package/src/link/Link.tsx +6 -15
  143. package/src/main.css +17 -419
  144. package/src/main.less +0 -1
  145. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +7 -1
  146. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +1 -1
  147. package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +3 -1
  148. package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +8 -1
  149. package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +5 -2
  150. package/src/select/Select.tsx +0 -1
  151. package/src/slidingPanel/SlidingPanel.spec.tsx +69 -0
  152. package/build/button/Button.resolver.js +0 -78
  153. package/build/button/Button.resolver.js.map +0 -1
  154. package/build/button/Button.resolver.mjs +0 -76
  155. package/build/button/Button.resolver.mjs.map +0 -1
  156. package/build/button/LegacyButton.js +0 -114
  157. package/build/button/LegacyButton.js.map +0 -1
  158. package/build/button/LegacyButton.mjs +0 -112
  159. package/build/button/LegacyButton.mjs.map +0 -1
  160. package/build/styles/button/Button.vars.css +0 -55
  161. package/build/styles/button/LegacyButton.css +0 -23
  162. package/build/types/button/Button.resolver.d.ts +0 -31
  163. package/build/types/button/Button.resolver.d.ts.map +0 -1
  164. package/build/types/button/Button.types.d.ts +0 -70
  165. package/build/types/button/Button.types.d.ts.map +0 -1
  166. package/build/types/button/LegacyButton.d.ts +0 -30
  167. package/build/types/button/LegacyButton.d.ts.map +0 -1
  168. package/src/button/Button.resolver.tsx +0 -120
  169. package/src/button/Button.types.ts +0 -93
  170. package/src/button/Button.vars.css +0 -55
  171. package/src/button/Button.vars.less +0 -69
  172. package/src/button/LegacyButton.css +0 -23
  173. package/src/button/LegacyButton.less +0 -24
  174. package/src/button/LegacyButton.spec.tsx +0 -146
  175. package/src/button/LegacyButton.story.tsx +0 -224
  176. package/src/button/LegacyButton.tsx +0 -161
  177. package/src/circularButton/_button-label-states.less +0 -34
  178. package/src/definitionList/DefinitionList.spec.js +0 -91
  179. 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 || undefined;
64
- const mappedSentiment = type === 'negative' ? 'negative' : undefined;
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,93 +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
- /**
27
- * The HTML element to render
28
- * @default 'button'
29
- **/
30
- as?: 'button' | 'a' | null;
31
-
32
- /** Additional class name(s) to apply to the button */
33
- className?: string;
34
-
35
- /**
36
- * Whether the button is disabled
37
- * @default false
38
- **/
39
- disabled?: boolean;
40
-
41
- href?: string;
42
-
43
- /**
44
- * Whether the button is in a loading state
45
- * @default false
46
- * */
47
- loading?: boolean;
48
-
49
- /** Whether the button should take up the full width of its container */
50
- block?: boolean;
51
-
52
- /**
53
- * Size of the button
54
- * @default lg
55
- * */
56
- size?: ButtonSize;
57
-
58
- /**
59
- * Priority of the button
60
- * @default "primary"
61
- */
62
- priority?: ButtonPriority;
63
-
64
- /**
65
- * Sentiment of the button
66
- * @default default
67
- */
68
- sentiment?: ButtonSentiment;
69
-
70
- /** Icon to be displayed on the left side of the button */
71
- iconStart?: React.ElementType;
72
-
73
- /** Icon to be displayed on the right side of the button */
74
- iconEnd?: React.ElementType;
75
-
76
- /** Media to be displayed on the left side of the button */
77
- avatars?: SingleAvatarType[];
78
-
79
- /** Optional property to provide component Ref */
80
- ref?: ButtonRefType;
81
-
82
- /** Content to be displayed inside the button */
83
- children?: ReactNode;
84
-
85
- startMedia?: ReactNode;
86
- endMedia?: ReactNode;
87
-
88
- lol?: string;
89
- }
90
-
91
- export type ButtonElementProps = PrimitiveButtonProps & CommonButtonProps;
92
- export type AnchorElementProps = PrimitiveAnchorProps & CommonButtonProps;
93
- export type ButtonProps = ButtonElementProps | AnchorElementProps;
@@ -1,55 +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-size-small-padding: 5px var(--size-12);
9
- --Button-size-medium-padding: var(--size-8) var(--size-12);
10
- --Button-size-large-padding: var(--size-12) var(--size-16);
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-primary-netative-avatar-border-color: rgba(255,255,255,0.2);
31
- --Button-secondary-negative-background: var(--color-sentiment-negative-secondary);
32
- --Button-secondary-negative-background-hover: var(--color-sentiment-negative-secondary-hover);
33
- --Button-secondary-negative-background-active: var(--color-sentiment-negative-secondary-active);
34
- --Button-secondary-negative-color: var(--color-sentiment-negative-primary);
35
- --Button-secondary-netative-avatar-border-color: rgba(168,32,13,0.12157);
36
- }
37
- .np-theme-personal--dark .wds-Button {
38
- --Button-primary-netative-avatar-border-color: rgba(14,15,12,0.12157);
39
- }
40
- .np-theme-personal--forest-green .wds-Button {
41
- --color-interactive-neutral: rgba(159,232,112,0.2);
42
- --color-interactive-neutral-hover: rgba(205,255,173,0.2);
43
- --color-interactive-neutral-active: rgba(236,255,224,0.2);
44
- --color-sentiment-negative-secondary: rgba(255,196,194,0.2);
45
- --color-sentiment-negative-secondary-hover: rgba(255,220,219,0.2);
46
- --color-sentiment-negative-secondary-active: rgba(255,235,235,0.2);
47
- --Button-primary-netative-avatar-border-color: rgba(14,15,12,0.12157);
48
- --Button-secondary-netative-avatar-border-color: rgba(14,15,12,0.12157);
49
- }
50
- .np-theme-personal--bright-green .wds-Button {
51
- --color-contrast: #FFFFFF;
52
- --Button-secondary-color: var(--color-interactive-control);
53
- --Button-secondary-negative-color: var(--color-contrast);
54
- --Button-secondary-netative-avatar-border-color: var(--Button-primary-netative-avatar-border-color);
55
- }
@@ -1,69 +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-size-small-padding: 5px var(--size-12);
9
- --Button-size-medium-padding: var(--size-8) var(--size-12);
10
- --Button-size-large-padding: var(--size-12) var(--size-16);
11
- --Button-avatar-border-color: var(--color-border-neutral);
12
- --Button-transition-duration: 150ms;
13
- --Button-transition-easing: ease-in-out;
14
-
15
- --Button-secondary-background: var(--color-interactive-neutral);
16
- --Button-secondary-background-hover: var(--color-interactive-neutral-hover);
17
- --Button-secondary-background-active: var(--color-interactive-neutral-active);
18
- --Button-secondary-color: var(--color-interactive-primary);
19
-
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
-
25
- --Button-minimal-background: transparent;
26
- --Button-minimal-background-hover: var(--color-background-screen-hover);
27
- --Button-minimal-background-active: var(--color-background-screen-active);
28
- --Button-minimal-color: var(--color-interactive-primary);
29
-
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: #FFFFFF33;
35
-
36
- --Button-secondary-negative-background: var(--color-sentiment-negative-secondary);
37
- --Button-secondary-negative-background-hover: var(--color-sentiment-negative-secondary-hover);
38
- --Button-secondary-negative-background-active: var(--color-sentiment-negative-secondary-active);
39
- --Button-secondary-negative-color: var(--color-sentiment-negative-primary);
40
- --Button-secondary-netative-avatar-border-color: #A8200D1F;
41
- }
42
-
43
- .np-theme-personal--dark {
44
- .wds-Button {
45
- --Button-primary-netative-avatar-border-color: #0E0F0C1F;
46
- }
47
- }
48
-
49
- .np-theme-personal--forest-green {
50
- .wds-Button {
51
- --color-interactive-neutral: #9FE87033;
52
- --color-interactive-neutral-hover: #CDFFAD33;
53
- --color-interactive-neutral-active: #ECFFE033;
54
- --color-sentiment-negative-secondary: #FFC4C233;
55
- --color-sentiment-negative-secondary-hover: #FFDCDB33;
56
- --color-sentiment-negative-secondary-active: #FFEBEB33;
57
- --Button-primary-netative-avatar-border-color: #0E0F0C1F;
58
- --Button-secondary-netative-avatar-border-color: #0E0F0C1F;
59
- }
60
- }
61
-
62
- .np-theme-personal--bright-green {
63
- .wds-Button {
64
- --color-contrast: #FFFFFF;
65
- --Button-secondary-color: var(--color-interactive-control);
66
- --Button-secondary-negative-color: var(--color-contrast);
67
- --Button-secondary-netative-avatar-border-color: var(--Button-primary-netative-avatar-border-color);
68
- }
69
- }
@@ -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,146 +0,0 @@
1
- import { createRef } from 'react';
2
-
3
- import { render, screen, userEvent } from '../test-utils';
4
-
5
- import LegacyButton, { ButtonReferenceType } from './LegacyButton';
6
- import messages from '../i18n/commonMessages/Button.messages';
7
-
8
- describe('LegacyButton', () => {
9
- // eslint-disable-next-line no-console
10
- const originalWarn = console.warn;
11
- let mockedWarn: typeof originalWarn;
12
-
13
- const props = {
14
- onClick: jest.fn(),
15
- onFocus: jest.fn(),
16
- onBlur: jest.fn(),
17
- children: 'Send money',
18
- };
19
-
20
- beforeAll(() => {
21
- mockedWarn = jest.fn().mockImplementation((args) => {
22
- if (typeof args !== 'string' || !args.startsWith('Button has deprecated the')) {
23
- originalWarn(args);
24
- }
25
- });
26
- // eslint-disable-next-line no-console
27
- console.warn = mockedWarn;
28
- });
29
-
30
- beforeEach(jest.clearAllMocks);
31
-
32
- afterAll(() => {
33
- // eslint-disable-next-line no-console
34
- console.warn = originalWarn;
35
- });
36
-
37
- describe('by default', () => {
38
- it('renders the text', () => {
39
- render(<LegacyButton {...props} />);
40
- expect(screen.getByText(props.children)).toBeInTheDocument();
41
- });
42
-
43
- it('set `ref` to be true on Button', () => {
44
- const reference = createRef<ButtonReferenceType>();
45
-
46
- expect(reference.current).toBeFalsy();
47
- render(<LegacyButton ref={reference}>Click me!</LegacyButton>);
48
- expect(reference.current).toBeTruthy();
49
- });
50
-
51
- it('is not disabled', () => {
52
- render(<LegacyButton {...props} />);
53
- expect(screen.getByRole('button')).toBeEnabled();
54
- });
55
- });
56
-
57
- describe('button attributes', () => {
58
- it('sets the htmlType if set', () => {
59
- render(<LegacyButton {...props} htmlType="submit" />);
60
- expect(screen.getByRole('button')).toHaveAttribute('type', 'submit');
61
- });
62
-
63
- it('passes through custom classes if set', () => {
64
- render(<LegacyButton {...props} className="donkeysarethebest" />);
65
- expect(screen.getByRole('button')).toHaveClass('donkeysarethebest');
66
- });
67
-
68
- it('passes through aria-label if set', () => {
69
- render(<LegacyButton {...props} aria-label="unique label" />);
70
- const loadingButton = screen.getByLabelText('unique label');
71
- expect(loadingButton).toBeInTheDocument();
72
- });
73
- });
74
-
75
- describe('onClick', () => {
76
- it('calls onClick when clicked', async () => {
77
- render(<LegacyButton {...props} />);
78
- await userEvent.click(screen.getByRole('button'));
79
- expect(props.onClick).toHaveBeenCalledTimes(1);
80
- });
81
-
82
- it('does not call onClick when clicked if disabled', async () => {
83
- render(<LegacyButton {...props} disabled />);
84
- await userEvent.click(screen.getByRole('button'));
85
- expect(props.onClick).toHaveBeenCalledTimes(0);
86
- });
87
-
88
- it('does not call onClick when clicked if loading', async () => {
89
- render(<LegacyButton {...props} loading />);
90
- await userEvent.click(screen.getByRole('button'));
91
- expect(props.onClick).toHaveBeenCalledTimes(0);
92
- });
93
- });
94
-
95
- describe('onFocus and onBlur', () => {
96
- it('calls both handlers by default', async () => {
97
- render(<LegacyButton {...props} />);
98
- await userEvent.tab();
99
- expect(props.onFocus).toHaveBeenCalledTimes(1);
100
- await userEvent.tab();
101
- expect(props.onFocus).toHaveBeenCalledTimes(1);
102
- });
103
-
104
- it('does not call either handler if disabled', async () => {
105
- render(<LegacyButton {...props} disabled />);
106
- await userEvent.tab();
107
- expect(props.onFocus).not.toHaveBeenCalled();
108
- await userEvent.tab();
109
- expect(props.onFocus).not.toHaveBeenCalled();
110
- });
111
-
112
- it('calls both handlers if loading', async () => {
113
- render(<LegacyButton {...props} loading />);
114
- await userEvent.tab();
115
- expect(props.onFocus).toHaveBeenCalledTimes(1);
116
- await userEvent.tab();
117
- expect(props.onFocus).toHaveBeenCalledTimes(1);
118
- });
119
- });
120
-
121
- describe('other states', () => {
122
- it('renders as loading if `loading` is true', () => {
123
- render(<LegacyButton {...props} loading />);
124
- const button = screen.queryByRole('button', {
125
- name: messages.loadingAriaLabel.defaultMessage,
126
- });
127
- expect(button).toBeInTheDocument();
128
- expect(button).toBeEnabled();
129
- expect(button).toHaveClass('btn-loading');
130
- expect(button).toHaveAttribute('aria-disabled', 'true');
131
- expect(button).toHaveAttribute('aria-busy', 'true');
132
- expect(button).toHaveAttribute('aria-live', 'polite');
133
- expect(screen.getByTestId('ButtonProgressIndicator')).toBeInTheDocument();
134
- });
135
-
136
- it('disables the button', () => {
137
- render(<LegacyButton {...props} disabled />);
138
- const button = screen.queryByRole('button');
139
- expect(button).toBeDisabled();
140
- expect(button).toHaveClass('disabled');
141
- expect(button).toHaveAttribute('aria-disabled', 'false');
142
- expect(button).toHaveAttribute('aria-busy', 'false');
143
- expect(button).toHaveAttribute('aria-live', 'off');
144
- });
145
- });
146
- });