@transferwise/components 0.0.0-experimental-28eac06 → 0.0.0-experimental-9b6d886

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 (202) hide show
  1. package/build/alert/Alert.js +17 -17
  2. package/build/alert/Alert.js.map +1 -1
  3. package/build/alert/Alert.mjs +14 -14
  4. package/build/alert/Alert.mjs.map +1 -1
  5. package/build/avatarLayout/AvatarLayout.js +2 -9
  6. package/build/avatarLayout/AvatarLayout.js.map +1 -1
  7. package/build/avatarLayout/AvatarLayout.mjs +2 -9
  8. package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
  9. package/build/button/Button.js +79 -86
  10. package/build/button/Button.js.map +1 -1
  11. package/build/button/Button.mjs +80 -87
  12. package/build/button/Button.mjs.map +1 -1
  13. package/build/circularButton/CircularButton.js.map +1 -1
  14. package/build/circularButton/CircularButton.mjs.map +1 -1
  15. package/build/common/action/Action.js +15 -26
  16. package/build/common/action/Action.js.map +1 -1
  17. package/build/common/action/Action.mjs +15 -26
  18. package/build/common/action/Action.mjs.map +1 -1
  19. package/build/common/propsValues/sentiment.js +0 -1
  20. package/build/common/propsValues/sentiment.js.map +1 -1
  21. package/build/common/propsValues/sentiment.mjs +0 -1
  22. package/build/common/propsValues/sentiment.mjs.map +1 -1
  23. package/build/criticalBanner/CriticalCommsBanner.js +73 -10
  24. package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
  25. package/build/criticalBanner/CriticalCommsBanner.mjs +74 -11
  26. package/build/criticalBanner/CriticalCommsBanner.mjs.map +1 -1
  27. package/build/header/Header.js +2 -2
  28. package/build/header/Header.js.map +1 -1
  29. package/build/header/Header.mjs +1 -1
  30. package/build/i18n/en.json +0 -1
  31. package/build/i18n/en.json.js +0 -1
  32. package/build/i18n/en.json.js.map +1 -1
  33. package/build/i18n/en.json.mjs +0 -1
  34. package/build/i18n/en.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/zh-HK.json +1 -0
  51. package/build/i18n/zh-HK.json.js +1 -0
  52. package/build/i18n/zh-HK.json.js.map +1 -1
  53. package/build/i18n/zh-HK.json.mjs +1 -0
  54. package/build/i18n/zh-HK.json.mjs.map +1 -1
  55. package/build/index.js +2 -2
  56. package/build/index.mjs +1 -1
  57. package/build/link/Link.js +3 -8
  58. package/build/link/Link.js.map +1 -1
  59. package/build/link/Link.mjs +3 -8
  60. package/build/link/Link.mjs.map +1 -1
  61. package/build/main.css +70 -267
  62. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +4 -2
  63. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
  64. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +4 -2
  65. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
  66. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +5 -3
  67. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
  68. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +5 -3
  69. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
  70. package/build/select/Select.js +2 -2
  71. package/build/select/Select.js.map +1 -1
  72. package/build/select/Select.mjs +1 -1
  73. package/build/statusIcon/StatusIcon.js +1 -5
  74. package/build/statusIcon/StatusIcon.js.map +1 -1
  75. package/build/statusIcon/StatusIcon.messages.js +0 -3
  76. package/build/statusIcon/StatusIcon.messages.js.map +1 -1
  77. package/build/statusIcon/StatusIcon.messages.mjs +0 -3
  78. package/build/statusIcon/StatusIcon.messages.mjs.map +1 -1
  79. package/build/statusIcon/StatusIcon.mjs +1 -5
  80. package/build/statusIcon/StatusIcon.mjs.map +1 -1
  81. package/build/styles/avatarLayout/AvatarLayout.css +0 -11
  82. package/build/styles/button/Button.css +15 -230
  83. package/build/styles/criticalBanner/CriticalCommsBanner.css +73 -21
  84. package/build/styles/main.css +70 -267
  85. package/build/types/alert/Alert.d.ts +4 -3
  86. package/build/types/alert/Alert.d.ts.map +1 -1
  87. package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
  88. package/build/types/button/Button.d.ts +23 -2
  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.map +1 -1
  93. package/build/types/common/action/Action.d.ts +2 -5
  94. package/build/types/common/action/Action.d.ts.map +1 -1
  95. package/build/types/common/propsValues/sentiment.d.ts +0 -1
  96. package/build/types/common/propsValues/sentiment.d.ts.map +1 -1
  97. package/build/types/criticalBanner/CriticalCommsBanner.d.ts.map +1 -1
  98. package/build/types/index.d.ts +1 -0
  99. package/build/types/index.d.ts.map +1 -1
  100. package/build/types/link/Link.d.ts +2 -2
  101. package/build/types/link/Link.d.ts.map +1 -1
  102. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
  103. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +2 -6
  104. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
  105. package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
  106. package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
  107. package/build/types/statusIcon/StatusIcon.messages.d.ts +0 -5
  108. package/build/types/statusIcon/StatusIcon.messages.d.ts.map +1 -1
  109. package/build/types/test-utils/index.d.ts +0 -2
  110. package/build/types/test-utils/index.d.ts.map +1 -1
  111. package/build/types/test-utils/story-config.d.ts +1 -1
  112. package/build/types/test-utils/story-config.d.ts.map +1 -1
  113. package/build/upload/steps/completeStep/completeStep.js +2 -2
  114. package/build/upload/steps/completeStep/completeStep.js.map +1 -1
  115. package/build/upload/steps/completeStep/completeStep.mjs +1 -1
  116. package/build/upload/steps/processingStep/processingStep.js +2 -2
  117. package/build/upload/steps/processingStep/processingStep.js.map +1 -1
  118. package/build/upload/steps/processingStep/processingStep.mjs +1 -1
  119. package/build/uploadInput/UploadInput.js +3 -3
  120. package/build/uploadInput/UploadInput.js.map +1 -1
  121. package/build/uploadInput/UploadInput.mjs +1 -1
  122. package/package.json +3 -3
  123. package/src/alert/Alert.spec.tsx +30 -0
  124. package/src/alert/Alert.story.tsx +1 -34
  125. package/src/alert/Alert.tests.story.tsx +1 -1
  126. package/src/alert/Alert.tsx +15 -20
  127. package/src/avatarLayout/AvatarLayout.css +0 -11
  128. package/src/avatarLayout/AvatarLayout.less +1 -18
  129. package/src/avatarLayout/AvatarLayout.tsx +2 -10
  130. package/src/button/Button.css +15 -230
  131. package/src/button/Button.less +14 -242
  132. package/src/button/Button.spec.tsx +226 -215
  133. package/src/button/Button.story.tsx +134 -761
  134. package/src/button/Button.tsx +132 -103
  135. package/src/button/__snapshots__/Button.spec.tsx.snap +309 -0
  136. package/src/button/index.ts +3 -2
  137. package/src/circularButton/CircularButton.tsx +0 -1
  138. package/src/common/action/Action.tsx +22 -40
  139. package/src/common/propsValues/sentiment.ts +0 -1
  140. package/src/criticalBanner/CriticalCommsBanner.css +73 -21
  141. package/src/criticalBanner/CriticalCommsBanner.less +70 -24
  142. package/src/criticalBanner/CriticalCommsBanner.story.tsx +4 -26
  143. package/src/criticalBanner/CriticalCommsBanner.tsx +50 -8
  144. package/src/field/Field.story.tsx +1 -1
  145. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +2 -1
  146. package/src/i18n/en.json +0 -1
  147. package/src/i18n/ja.json +1 -0
  148. package/src/i18n/pt.json +1 -0
  149. package/src/i18n/ru.json +1 -0
  150. package/src/i18n/zh-HK.json +1 -0
  151. package/src/index.ts +1 -0
  152. package/src/inputs/SelectInput.story.tsx +1 -1
  153. package/src/label/Label.story.tsx +1 -1
  154. package/src/link/Link.tsx +6 -15
  155. package/src/main.css +70 -267
  156. package/src/main.less +0 -1
  157. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +8 -2
  158. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +2 -7
  159. package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +3 -1
  160. package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +12 -4
  161. package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +13 -16
  162. package/src/radio/Radio.spec.tsx +73 -0
  163. package/src/radio/Radio.story.tsx +22 -52
  164. package/src/radioGroup/RadioGroup.spec.tsx +91 -0
  165. package/src/radioGroup/RadioGroup.story.tsx +3 -5
  166. package/src/statusIcon/StatusIcon.less +0 -1
  167. package/src/statusIcon/StatusIcon.messages.ts +0 -6
  168. package/src/statusIcon/StatusIcon.tsx +1 -8
  169. package/src/test-utils/Parameters.d.ts +1 -9
  170. package/src/test-utils/story-config.ts +1 -10
  171. package/build/button/Button.resolver.js +0 -74
  172. package/build/button/Button.resolver.js.map +0 -1
  173. package/build/button/Button.resolver.mjs +0 -72
  174. package/build/button/Button.resolver.mjs.map +0 -1
  175. package/build/button/LegacyButton.js +0 -114
  176. package/build/button/LegacyButton.js.map +0 -1
  177. package/build/button/LegacyButton.mjs +0 -112
  178. package/build/button/LegacyButton.mjs.map +0 -1
  179. package/build/styles/button/Button.vars.css +0 -46
  180. package/build/styles/button/LegacyButton.css +0 -23
  181. package/build/types/button/Button.resolver.d.ts +0 -35
  182. package/build/types/button/Button.resolver.d.ts.map +0 -1
  183. package/build/types/button/Button.types.d.ts +0 -70
  184. package/build/types/button/Button.types.d.ts.map +0 -1
  185. package/build/types/button/LegacyButton.d.ts +0 -44
  186. package/build/types/button/LegacyButton.d.ts.map +0 -1
  187. package/src/button/Button.accessibility.docs.mdx +0 -103
  188. package/src/button/Button.resolver.tsx +0 -73
  189. package/src/button/Button.tests.story.tsx +0 -27
  190. package/src/button/Button.types.ts +0 -92
  191. package/src/button/Button.vars.css +0 -46
  192. package/src/button/Button.vars.less +0 -55
  193. package/src/button/LegacyButton.css +0 -23
  194. package/src/button/LegacyButton.less +0 -24
  195. package/src/button/LegacyButton.spec.tsx +0 -147
  196. package/src/button/LegacyButton.story.tsx +0 -228
  197. package/src/button/LegacyButton.tsx +0 -177
  198. package/src/radio/Radio.rtl.spec.tsx +0 -24
  199. package/src/radio/Radio.spec.js +0 -76
  200. package/src/radio/__snapshots__/Radio.rtl.spec.tsx.snap +0 -49
  201. package/src/radioGroup/RadioGroup.rtl.spec.tsx +0 -30
  202. package/src/radioGroup/RadioGroup.spec.js +0 -90
@@ -1,46 +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: var(--size-5) var(--size-12);
11
- --Button-avatar-border-color: var(--color-border-neutral);
12
- --Button-transition-duration: 150ms;
13
- --Button-transition-easing: ease-in-out;
14
- --Button-secondary-background: var(--color-interactive-neutral);
15
- --Button-secondary-background-hover: var(--color-interactive-neutral-hover);
16
- --Button-secondary-background-active: var(--color-interactive-neutral-active);
17
- --Button-secondary-color: var(--color-interactive-primary);
18
- --Button-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-overlay);
30
- --Button-secondary-negative-background: var(--color-sentiment-negative-secondary);
31
- --Button-secondary-negative-background-hover: var(--color-sentiment-negative-secondary-hover);
32
- --Button-secondary-negative-background-active: var(--color-sentiment-negative-secondary-active);
33
- --Button-secondary-negative-color: var(--color-sentiment-negative-primary);
34
- }
35
- .np-theme-personal--bright-green .wds-Button {
36
- --Button-primary-negative-color: var(--color-white);
37
- --Button-secondary-color: var(--color-interactive-control);
38
- --Button-secondary-negative-color: var(--color-white);
39
- }
40
- .np-theme-personal--forest-green .wds-Button {
41
- --Button-secondary-background: var(--color-interactive-neutral);
42
- --Button-secondary-negative-background: var(--color-sentiment-negative-primary);
43
- --Button-secondary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
44
- --Button-secondary-negative-background-active: var(--color-sentiment-negative-primary-active);
45
- --Button-secondary-negative-color: var(--color-contrast-overlay);
46
- }
@@ -1,55 +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
- --Button-small-padding: var(--size-5) var(--size-12);
12
-
13
- --Button-avatar-border-color: var(--color-border-neutral);
14
- --Button-transition-duration: 150ms;
15
- --Button-transition-easing: ease-in-out;
16
-
17
- --Button-secondary-background: var(--color-interactive-neutral);
18
- --Button-secondary-background-hover: var(--color-interactive-neutral-hover);
19
- --Button-secondary-background-active: var(--color-interactive-neutral-active);
20
- --Button-secondary-color: var(--color-interactive-primary);
21
-
22
- --Button-tertiary-background: var(--color-background-neutral);
23
- --Button-tertiary-background-hover: var(--color-background-neutral-hover);
24
- --Button-tertiary-background-active: var(--color-background-neutral-active);
25
- --Button-tertiary-color: var(--color-content-primary);
26
-
27
- --Button-minimal-background: transparent;
28
- --Button-minimal-background-hover: var(--color-background-screen-hover);
29
- --Button-minimal-background-active: var(--color-background-screen-active);
30
- --Button-minimal-color: var(--color-interactive-primary);
31
-
32
- --Button-primary-negative-background: var(--color-sentiment-negative-primary);
33
- --Button-primary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
34
- --Button-primary-negative-background-active: var(--color-sentiment-negative-primary-active);
35
- --Button-primary-negative-color: var(--color-contrast-overlay);
36
-
37
- --Button-secondary-negative-background: var(--color-sentiment-negative-secondary);
38
- --Button-secondary-negative-background-hover: var(--color-sentiment-negative-secondary-hover);
39
- --Button-secondary-negative-background-active: var(--color-sentiment-negative-secondary-active);
40
- --Button-secondary-negative-color: var(--color-sentiment-negative-primary);
41
-
42
- .np-theme-personal--bright-green & {
43
- --Button-primary-negative-color: var(--color-white);
44
- --Button-secondary-color: var(--color-interactive-control);
45
- --Button-secondary-negative-color: var(--color-white);
46
- }
47
-
48
- .np-theme-personal--forest-green & {
49
- --Button-secondary-background: var(--color-interactive-neutral);
50
- --Button-secondary-negative-background: var(--color-sentiment-negative-primary);
51
- --Button-secondary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
52
- --Button-secondary-negative-background-active: var(--color-sentiment-negative-primary-active);
53
- --Button-secondary-negative-color: var(--color-contrast-overlay);
54
- }
55
- }
@@ -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
- });
@@ -1,228 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/react';
2
- import { userEvent, within, fn, expect } from '@storybook/test';
3
- import { useState } from 'react';
4
-
5
- import Button from '.';
6
- import LegacyButton from './LegacyButton';
7
-
8
- // needed for the SB to show correct name in the Source blocks
9
- LegacyButton.displayName = 'Button';
10
-
11
- const withContainer = (Story: any) => (
12
- <div
13
- style={{
14
- display: 'flex',
15
- flexDirection: 'initial',
16
- justifyContent: 'center',
17
- flexFlow: 'column',
18
- alignItems: 'center',
19
- }}
20
- >
21
- <Story />
22
- </div>
23
- );
24
-
25
- const meta: Meta<typeof LegacyButton> = {
26
- component: LegacyButton,
27
- title: 'Actions/Button/Legacy Button',
28
- args: {
29
- size: undefined,
30
- priority: undefined,
31
- type: undefined,
32
- block: false,
33
- disabled: false,
34
- loading: false,
35
- href: undefined,
36
- as: undefined,
37
- target: undefined,
38
- htmlType: undefined,
39
- children: 'Button text',
40
- onClick: fn(),
41
- onBlur: fn(),
42
- onFocus: fn(),
43
- },
44
- argTypes: {
45
- href: {
46
- control: 'text',
47
- description: 'If set together with `as="a"`, the component will render as an HTML anchor.',
48
- },
49
- as: {
50
- control: {
51
- name: 'enum',
52
- options: ['button', 'a'],
53
- },
54
- description: 'If set together with `href`, the component will render as an HTML anchor.',
55
- },
56
- type: {
57
- type: {
58
- name: 'enum',
59
- value: ['accent', 'positive', 'negative'],
60
- },
61
- description:
62
- '**NB**: `primary` | `pay` | `secondary` | `danger` | `link` are deprecated.\n\n',
63
- },
64
- size: {
65
- type: {
66
- name: 'enum',
67
- value: ['lg', 'md', 'sm', 'xs'],
68
- },
69
- description: '**NB**: `xs` is deprecated.\n\n',
70
- },
71
- priority: {
72
- type: {
73
- name: 'enum',
74
- value: ['primary', 'secondary', 'tertiary'],
75
- },
76
- },
77
- block: {
78
- table: {
79
- defaultValue: { summary: 'false' },
80
- },
81
- },
82
- v2: {
83
- table: {
84
- disable: true,
85
- },
86
- },
87
- },
88
- tags: ['autodocs'],
89
- decorators: [withContainer],
90
- };
91
-
92
- export default meta;
93
-
94
- type Story = StoryObj<typeof Button>;
95
-
96
- export const Basic: Story = {};
97
-
98
- export const Secondary: Story = {
99
- args: {
100
- type: 'accent',
101
- priority: 'secondary',
102
- },
103
- };
104
-
105
- export const Tertiary: Story = {
106
- args: {
107
- type: 'accent',
108
- priority: 'tertiary',
109
- },
110
- };
111
-
112
- export const Negative: Story = {
113
- args: {
114
- type: 'negative',
115
- priority: 'primary',
116
- },
117
- };
118
-
119
- export const Loading: Story = {
120
- args: {
121
- loading: true,
122
- },
123
- };
124
-
125
- export const Variants: Story = {
126
- render: () => {
127
- return (
128
- <div className="d-flex flex-column p-b-2 align-items-start">
129
- <div className="d-flex flex-row p-b-2" style={{ gap: 'var(--size-16)' }}>
130
- <Button type="accent" priority="primary">
131
- Primary Accent
132
- </Button>
133
- <Button type="accent" priority="secondary">
134
- Secondary Accent
135
- </Button>
136
- <Button type="accent" priority="tertiary">
137
- Tertiary Accent
138
- </Button>
139
- </div>
140
- <div className="d-flex flex-row p-b-2" style={{ gap: 'var(--size-16)' }}>
141
- <Button type="positive" priority="primary">
142
- Primary Positive
143
- </Button>
144
- <Button type="positive" priority="secondary">
145
- Secondary Accent
146
- </Button>
147
- </div>
148
- <div className="d-flex flex-row flex- p-b-2" style={{ gap: 'var(--size-16)' }}>
149
- <Button type="negative" priority="primary">
150
- Primary Negative
151
- </Button>
152
- <Button type="negative" priority="secondary">
153
- Secondary Negative
154
- </Button>
155
- </div>
156
- <div className="d-flex flex-row p-b-1" style={{ gap: 'var(--size-16)' }}>
157
- <Button type="accent" priority="primary" disabled>
158
- Button Disabled
159
- </Button>
160
- <Button type="accent" priority="secondary" disabled>
161
- Button Disabled
162
- </Button>
163
- <Button type="accent" priority="tertiary" disabled>
164
- Button Disabled
165
- </Button>
166
- </div>
167
- </div>
168
- );
169
- },
170
- };
171
-
172
- const wait = async (duration = 500) =>
173
- new Promise<void>((resolve) => {
174
- setTimeout(resolve, duration);
175
- });
176
-
177
- export const Focused: Story = {
178
- play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {
179
- const canvas = within(canvasElement);
180
- const button = canvas.getByRole('button');
181
- await userEvent.tab();
182
- await expect(button).toHaveFocus();
183
- await expect(button).toHaveTextContent('Focused!');
184
- },
185
- render: function Render(args: React.ComponentProps<typeof Button>) {
186
- const [focused, setFocused] = useState(false);
187
-
188
- return (
189
- <Button {...args} onFocus={() => setFocused(true)}>
190
- {focused ? 'Focused!' : 'Button text'}
191
- </Button>
192
- );
193
- },
194
- };
195
-
196
- export const SocialMedia: Story = {
197
- render: () => {
198
- return (
199
- <>
200
- <div className="m-b-2">
201
- <button type="button" className="btn btn-google">
202
- Login with Google
203
- </button>
204
- </div>
205
- <div className="m-b-2">
206
- <button type="button" className="btn btn-facebook">
207
- Login with Facebook
208
- </button>
209
- </div>
210
- <div className="m-b-2">
211
- <button type="button" className="btn btn-lg btn-facebook">
212
- Large Button
213
- </button>
214
- </div>
215
- <div className="m-b-2">
216
- <button type="button" className="btn btn-block btn-facebook">
217
- Block Button
218
- </button>
219
- </div>
220
- <div className="m-b-2">
221
- <button type="button" className="btn btn-lg btn-block btn-facebook">
222
- Large Block Button
223
- </button>
224
- </div>
225
- </>
226
- );
227
- },
228
- };