@transferwise/components 0.0.0-experimental-db4013c → 0.0.0-experimental-bd6f8cc

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 (118) 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 +79 -84
  6. package/build/button/Button.js.map +1 -1
  7. package/build/button/Button.mjs +80 -85
  8. package/build/button/Button.mjs.map +1 -1
  9. package/build/criticalBanner/CriticalCommsBanner.js +2 -2
  10. package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
  11. package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
  12. package/build/header/Header.js +2 -2
  13. package/build/header/Header.js.map +1 -1
  14. package/build/header/Header.mjs +1 -1
  15. package/build/index.js +2 -2
  16. package/build/index.mjs +1 -1
  17. package/build/link/Link.js +3 -8
  18. package/build/link/Link.js.map +1 -1
  19. package/build/link/Link.mjs +3 -8
  20. package/build/link/Link.mjs.map +1 -1
  21. package/build/main.css +11 -226
  22. package/build/nudge/Nudge.js.map +1 -1
  23. package/build/nudge/Nudge.mjs.map +1 -1
  24. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +4 -2
  25. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
  26. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +4 -2
  27. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
  28. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +5 -3
  29. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
  30. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +5 -3
  31. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
  32. package/build/select/Select.js +2 -2
  33. package/build/select/Select.js.map +1 -1
  34. package/build/select/Select.mjs +1 -1
  35. package/build/styles/avatarLayout/AvatarLayout.css +0 -11
  36. package/build/styles/button/Button.css +15 -207
  37. package/build/styles/main.css +11 -226
  38. package/build/styles/nudge/Nudge.css +11 -0
  39. package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
  40. package/build/types/button/Button.d.ts +23 -2
  41. package/build/types/button/Button.d.ts.map +1 -1
  42. package/build/types/button/index.d.ts +2 -2
  43. package/build/types/button/index.d.ts.map +1 -1
  44. package/build/types/link/Link.d.ts +2 -2
  45. package/build/types/link/Link.d.ts.map +1 -1
  46. package/build/types/nudge/Nudge.d.ts +1 -1
  47. package/build/types/nudge/Nudge.d.ts.map +1 -1
  48. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
  49. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +2 -6
  50. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
  51. package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
  52. package/build/types/test-utils/story-config.d.ts +1 -1
  53. package/build/types/test-utils/story-config.d.ts.map +1 -1
  54. package/build/upload/steps/completeStep/completeStep.js +2 -2
  55. package/build/upload/steps/completeStep/completeStep.js.map +1 -1
  56. package/build/upload/steps/completeStep/completeStep.mjs +1 -1
  57. package/build/upload/steps/processingStep/processingStep.js +2 -2
  58. package/build/upload/steps/processingStep/processingStep.js.map +1 -1
  59. package/build/upload/steps/processingStep/processingStep.mjs +1 -1
  60. package/build/uploadInput/UploadInput.js +3 -3
  61. package/build/uploadInput/UploadInput.js.map +1 -1
  62. package/build/uploadInput/UploadInput.mjs +1 -1
  63. package/package.json +3 -3
  64. package/src/alert/Alert.tests.story.tsx +1 -1
  65. package/src/avatarLayout/AvatarLayout.css +0 -11
  66. package/src/avatarLayout/AvatarLayout.less +1 -18
  67. package/src/avatarLayout/AvatarLayout.tsx +2 -10
  68. package/src/button/Button.css +15 -207
  69. package/src/button/Button.less +14 -214
  70. package/src/button/Button.spec.tsx +224 -188
  71. package/src/button/Button.story.tsx +135 -701
  72. package/src/button/Button.tsx +131 -97
  73. package/src/button/__snapshots__/Button.spec.tsx.snap +309 -0
  74. package/src/button/index.ts +3 -2
  75. package/src/field/Field.story.tsx +1 -1
  76. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +2 -1
  77. package/src/inputs/SelectInput.story.tsx +1 -1
  78. package/src/label/Label.story.tsx +1 -1
  79. package/src/link/Link.tsx +6 -15
  80. package/src/main.css +11 -226
  81. package/src/main.less +0 -1
  82. package/src/nudge/Nudge.css +11 -0
  83. package/src/nudge/Nudge.less +3 -0
  84. package/src/nudge/Nudge.story.tsx +10 -0
  85. package/src/nudge/Nudge.tsx +2 -1
  86. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +8 -2
  87. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +2 -7
  88. package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +3 -1
  89. package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +12 -4
  90. package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +13 -16
  91. package/src/test-utils/Parameters.d.ts +1 -9
  92. package/src/test-utils/story-config.ts +1 -10
  93. package/build/button/Button.resolver.js +0 -74
  94. package/build/button/Button.resolver.js.map +0 -1
  95. package/build/button/Button.resolver.mjs +0 -72
  96. package/build/button/Button.resolver.mjs.map +0 -1
  97. package/build/button/LegacyButton.js +0 -114
  98. package/build/button/LegacyButton.js.map +0 -1
  99. package/build/button/LegacyButton.mjs +0 -112
  100. package/build/button/LegacyButton.mjs.map +0 -1
  101. package/build/styles/button/Button.vars.css +0 -46
  102. package/build/styles/button/LegacyButton.css +0 -23
  103. package/build/types/button/Button.resolver.d.ts +0 -33
  104. package/build/types/button/Button.resolver.d.ts.map +0 -1
  105. package/build/types/button/Button.types.d.ts +0 -67
  106. package/build/types/button/Button.types.d.ts.map +0 -1
  107. package/build/types/button/LegacyButton.d.ts +0 -30
  108. package/build/types/button/LegacyButton.d.ts.map +0 -1
  109. package/src/button/Button.resolver.tsx +0 -73
  110. package/src/button/Button.tests.story.tsx +0 -27
  111. package/src/button/Button.types.ts +0 -94
  112. package/src/button/Button.vars.css +0 -46
  113. package/src/button/Button.vars.less +0 -60
  114. package/src/button/LegacyButton.css +0 -23
  115. package/src/button/LegacyButton.less +0 -24
  116. package/src/button/LegacyButton.spec.tsx +0 -147
  117. package/src/button/LegacyButton.story.tsx +0 -220
  118. package/src/button/LegacyButton.tsx +0 -160
@@ -1,27 +0,0 @@
1
- import { Meta } from '@storybook/react';
2
- import Button from './Button.resolver';
3
- import { expect, userEvent, within } from '@storybook/test';
4
- import { storyConfig } from '../test-utils';
5
-
6
- const meta: Meta<typeof Button> = {
7
- component: Button,
8
- title: 'Actions/Button/Tests',
9
- };
10
- export default meta;
11
-
12
- export const FocusMinimal = storyConfig(
13
- {
14
- render: () => (
15
- <Button v2 priority="minimal">
16
- Focus has underline
17
- </Button>
18
- ),
19
- },
20
- {},
21
- );
22
- FocusMinimal.play = async ({ canvasElement }) => {
23
- await userEvent.tab();
24
- const canvas = within(canvasElement);
25
- const buttonElement: HTMLButtonElement = canvas.getByRole('button');
26
- await expect(buttonElement).toHaveFocus();
27
- };
@@ -1,94 +0,0 @@
1
- import { AnchorHTMLAttributes, ButtonHTMLAttributes, ReactNode } from 'react';
2
- import type { PrimitiveButtonProps, PrimitiveAnchorProps } from '../primitives';
3
- import type { AvatarLayoutProps } from '../avatarLayout';
4
-
5
- export type ButtonSentiment = 'default' | 'negative';
6
- export type ButtonPriority = 'primary' | 'secondary' | 'tertiary' | 'minimal';
7
- export type ButtonSize = 'sm' | 'md' | 'lg';
8
- export type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;
9
-
10
- /**
11
- * Common properties for the Button component.
12
- */
13
- export interface CommonProps {
14
- v2: true;
15
-
16
- /**
17
- * The HTML element to render
18
- * @default 'button'
19
- **/
20
- as?: 'button' | 'a';
21
-
22
- /** Additional class name(s) to apply to the button */
23
- className?: string;
24
-
25
- /**
26
- * @default false
27
- **/
28
- disabled?: boolean;
29
-
30
- href?: string;
31
-
32
- /**
33
- * @default false
34
- * */
35
- loading?: boolean;
36
-
37
- /** Whether the button should take up the full width of its container */
38
- block?: boolean;
39
-
40
- /**
41
- * Size of the button
42
- * @default lg
43
- * */
44
- size?: ButtonSize;
45
-
46
- /**
47
- * Priority of the button
48
- * @default "primary"
49
- */
50
- priority?: ButtonPriority;
51
-
52
- /**
53
- * Sentiment of the button
54
- * @default default
55
- */
56
- sentiment?: ButtonSentiment;
57
-
58
- /** Icon to be displayed on the left side of the button */
59
- iconStart?: React.ElementType;
60
-
61
- /** Icon to be displayed on the right side of the button */
62
- iconEnd?: React.ElementType;
63
-
64
- /** Media to be displayed on the left side of the button */
65
- avatars?: AvatarLayoutProps['avatars'];
66
-
67
- /** Content to be displayed inside the button */
68
- children?: ReactNode;
69
-
70
- addonStart?: ButtonAddonStart;
71
- addonEnd?: ButtonAddonEnd;
72
- }
73
-
74
- type ButtonAddonStart = {
75
- icon?: React.ElementType;
76
- avatars?: AvatarLayoutProps['avatars'];
77
- };
78
-
79
- type ButtonAddonEnd = {
80
- icon?: React.ElementType;
81
- };
82
-
83
- export type ButtonElementProps = Omit<
84
- ButtonHTMLAttributes<HTMLButtonElement>,
85
- 'disabled' | 'className'
86
- > &
87
- CommonProps;
88
- export type AnchorElementProps = Omit<
89
- AnchorHTMLAttributes<HTMLAnchorElement>,
90
- 'type' | 'disabled' | 'href' | 'className'
91
- > &
92
- CommonProps;
93
-
94
- export type ButtonProps = ButtonElementProps | AnchorElementProps;
@@ -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: calc(var(--size-10) * 0.5) var(--size-12);
11
- --Button-avatar-border-color: var(--color-border-neutral);
12
- --Button-transition-duration: 150ms;
13
- --Button-transition-easing: ease-in-out;
14
- --Button-secondary-background: var(--color-interactive-neutral);
15
- --Button-secondary-background-hover: var(--color-interactive-neutral-hover);
16
- --Button-secondary-background-active: var(--color-interactive-neutral-active);
17
- --Button-secondary-color: var(--color-interactive-primary);
18
- --Button-tertiary-background: var(--color-background-neutral);
19
- --Button-tertiary-background-hover: var(--color-background-neutral-hover);
20
- --Button-tertiary-background-active: var(--color-background-neutral-active);
21
- --Button-tertiary-color: var(--color-content-primary);
22
- --Button-minimal-background: transparent;
23
- --Button-minimal-background-hover: var(--color-background-screen-hover);
24
- --Button-minimal-background-active: var(--color-background-screen-active);
25
- --Button-minimal-color: var(--color-interactive-primary);
26
- --Button-primary-negative-background: var(--color-sentiment-negative-primary);
27
- --Button-primary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
28
- --Button-primary-negative-background-active: var(--color-sentiment-negative-primary-active);
29
- --Button-primary-negative-color: var(--color-contrast-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,60 +0,0 @@
1
- .wds-Button {
2
- --Button-background: var(--color-interactive-accent);
3
- --Button-background-hover: var(--color-interactive-accent-hover);
4
- --Button-background-active: var(--color-interactive-accent-active);
5
- --Button-color: var(--color-interactive-control);
6
- --Button-border-radius: var(--radius-full);
7
- --Button-label-gap: var(--size-4);
8
-
9
- --Button-large-padding: var(--size-12) var(--size-16);
10
- --Button-medium-padding: var(--size-8) var(--size-12);
11
- // 5px is required by design
12
- --Button-small-padding: calc(var(--size-10) * .5) var(--size-12);
13
-
14
- --Button-avatar-border-color: var(--color-border-neutral);
15
- --Button-transition-duration: 150ms;
16
- --Button-transition-easing: ease-in-out;
17
-
18
- --Button-secondary-background: var(--color-interactive-neutral);
19
- --Button-secondary-background-hover: var(--color-interactive-neutral-hover);
20
- --Button-secondary-background-active: var(--color-interactive-neutral-active);
21
- --Button-secondary-color: var(--color-interactive-primary);
22
-
23
- --Button-tertiary-background: var(--color-background-neutral);
24
- --Button-tertiary-background-hover: var(--color-background-neutral-hover);
25
- --Button-tertiary-background-active: var(--color-background-neutral-active);
26
- --Button-tertiary-color: var(--color-content-primary);
27
-
28
- --Button-minimal-background: transparent;
29
- --Button-minimal-background-hover: var(--color-background-screen-hover);
30
- --Button-minimal-background-active: var(--color-background-screen-active);
31
- --Button-minimal-color: var(--color-interactive-primary);
32
-
33
- --Button-primary-negative-background: var(--color-sentiment-negative-primary);
34
- --Button-primary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
35
- --Button-primary-negative-background-active: var(--color-sentiment-negative-primary-active);
36
- --Button-primary-negative-color: var(--color-contrast-overlay);
37
-
38
- --Button-secondary-negative-background: var(--color-sentiment-negative-secondary);
39
- --Button-secondary-negative-background-hover: var(--color-sentiment-negative-secondary-hover);
40
- --Button-secondary-negative-background-active: var(--color-sentiment-negative-secondary-active);
41
- --Button-secondary-negative-color: var(--color-sentiment-negative-primary);
42
-
43
-
44
- .np-theme-personal--bright-green & {
45
- --Button-primary-negative-color: var(--color-white);
46
- --Button-secondary-color: var(--color-interactive-control);
47
- --Button-secondary-negative-color: var(--color-white);
48
- }
49
-
50
-
51
- .np-theme-personal--forest-green & {
52
- --Button-secondary-background: var(--color-interactive-neutral);
53
- --Button-secondary-negative-background: var(--color-sentiment-negative-primary);
54
- --Button-secondary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
55
- --Button-secondary-negative-background-active: var(--color-sentiment-negative-primary-active);
56
- --Button-secondary-negative-color: var(--color-contrast-overlay);
57
- }
58
- }
59
-
60
-
@@ -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,220 +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
-
7
- const withContainer = (Story: any) => (
8
- <div
9
- style={{
10
- display: 'flex',
11
- flexDirection: 'initial',
12
- justifyContent: 'center',
13
- flexFlow: 'column',
14
- alignItems: 'center',
15
- }}
16
- >
17
- <Story />
18
- </div>
19
- );
20
-
21
- const meta: Meta<typeof Button> = {
22
- component: Button,
23
- title: 'Actions/Button/Legacy',
24
- args: {
25
- children: 'Button text',
26
- loading: false,
27
- type: undefined,
28
- onClick: fn(),
29
- onBlur: fn(),
30
- onFocus: fn(),
31
- href: 'https://example.com',
32
- as: undefined,
33
- },
34
- argTypes: {
35
- as: {
36
- control: {
37
- name: 'enum',
38
- options: ['button', 'a'],
39
- },
40
- },
41
- type: {
42
- type: {
43
- name: 'enum',
44
- value: ['accent', 'positive', 'negative'],
45
- },
46
- },
47
- size: {
48
- type: {
49
- name: 'enum',
50
- value: ['xs', 'sm', 'md', 'lg'],
51
- },
52
- },
53
- priority: {
54
- type: {
55
- name: 'enum',
56
- value: ['primary', 'secondary', 'tertiary'],
57
- },
58
- },
59
- sentiment: {
60
- table: {
61
- disable: true,
62
- },
63
- },
64
- iconStart: {
65
- table: {
66
- disable: true,
67
- },
68
- },
69
- iconEnd: {
70
- table: {
71
- disable: true,
72
- },
73
- },
74
- avatars: {
75
- table: {
76
- disable: true,
77
- },
78
- },
79
- },
80
- tags: ['autodocs'],
81
- decorators: [withContainer],
82
- };
83
-
84
- export default meta;
85
-
86
- type Story = StoryObj<typeof Button>;
87
-
88
- export const Basic: Story = {};
89
-
90
- export const Secondary: Story = {
91
- args: {
92
- type: 'accent',
93
- priority: 'secondary',
94
- },
95
- };
96
-
97
- export const Tertiary: Story = {
98
- args: {
99
- type: 'accent',
100
- priority: 'tertiary',
101
- },
102
- };
103
-
104
- export const Negative: Story = {
105
- args: {
106
- type: 'negative',
107
- priority: 'primary',
108
- },
109
- };
110
-
111
- export const Loading: Story = {
112
- args: {
113
- loading: true,
114
- },
115
- };
116
-
117
- export const Variants: Story = {
118
- render: () => {
119
- return (
120
- <div className="d-flex flex-column p-b-2 align-items-start">
121
- <div className="d-flex flex-row p-b-2" style={{ gap: 'var(--size-16)' }}>
122
- <Button type="accent" priority="primary">
123
- Primary Accent
124
- </Button>
125
- <Button type="accent" priority="secondary">
126
- Secondary Accent
127
- </Button>
128
- <Button type="accent" priority="tertiary">
129
- Tertiary Accent
130
- </Button>
131
- </div>
132
- <div className="d-flex flex-row p-b-2" style={{ gap: 'var(--size-16)' }}>
133
- <Button type="positive" priority="primary">
134
- Primary Positive
135
- </Button>
136
- <Button type="positive" priority="secondary">
137
- Secondary Accent
138
- </Button>
139
- </div>
140
- <div className="d-flex flex-row flex- p-b-2" style={{ gap: 'var(--size-16)' }}>
141
- <Button type="negative" priority="primary">
142
- Primary Negative
143
- </Button>
144
- <Button type="negative" priority="secondary">
145
- Secondary Negative
146
- </Button>
147
- </div>
148
- <div className="d-flex flex-row p-b-1" style={{ gap: 'var(--size-16)' }}>
149
- <Button type="accent" priority="primary" disabled>
150
- Button Disabled
151
- </Button>
152
- <Button type="accent" priority="secondary" disabled>
153
- Button Disabled
154
- </Button>
155
- <Button type="accent" priority="tertiary" disabled>
156
- Button Disabled
157
- </Button>
158
- </div>
159
- </div>
160
- );
161
- },
162
- };
163
-
164
- const wait = async (duration = 500) =>
165
- new Promise<void>((resolve) => {
166
- setTimeout(resolve, duration);
167
- });
168
-
169
- export const Focused: Story = {
170
- play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {
171
- const canvas = within(canvasElement);
172
- const button = canvas.getByRole('button');
173
- await userEvent.tab();
174
- await expect(button).toHaveFocus();
175
- await expect(button).toHaveTextContent('Focused!');
176
- },
177
- render: function Render(args: React.ComponentProps<typeof Button>) {
178
- const [focused, setFocused] = useState(false);
179
-
180
- return (
181
- <Button {...args} onFocus={() => setFocused(true)}>
182
- {focused ? 'Focused!' : 'Button text'}
183
- </Button>
184
- );
185
- },
186
- };
187
-
188
- export const SocialMedia: Story = {
189
- render: () => {
190
- return (
191
- <>
192
- <div className="m-b-2">
193
- <button type="button" className="btn btn-google">
194
- Login with Google
195
- </button>
196
- </div>
197
- <div className="m-b-2">
198
- <button type="button" className="btn btn-facebook">
199
- Login with Facebook
200
- </button>
201
- </div>
202
- <div className="m-b-2">
203
- <button type="button" className="btn btn-lg btn-facebook">
204
- Large Button
205
- </button>
206
- </div>
207
- <div className="m-b-2">
208
- <button type="button" className="btn btn-block btn-facebook">
209
- Block Button
210
- </button>
211
- </div>
212
- <div className="m-b-2">
213
- <button type="button" className="btn btn-lg btn-block btn-facebook">
214
- Large Block Button
215
- </button>
216
- </div>
217
- </>
218
- );
219
- },
220
- };