@transferwise/components 0.0.0-experimental-a656242 → 0.0.0-experimental-887f2e6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/avatarLayout/AvatarLayout.js +9 -2
- package/build/avatarLayout/AvatarLayout.js.map +1 -1
- package/build/avatarLayout/AvatarLayout.mjs +9 -2
- package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
- package/build/avatarView/AvatarView.js +1 -12
- package/build/avatarView/AvatarView.js.map +1 -1
- package/build/avatarView/AvatarView.mjs +1 -12
- package/build/avatarView/AvatarView.mjs.map +1 -1
- package/build/button/Button.js +78 -79
- package/build/button/Button.js.map +1 -1
- package/build/button/Button.mjs +79 -80
- package/build/button/Button.mjs.map +1 -1
- package/build/button/Button.resolver.js +78 -0
- package/build/button/Button.resolver.js.map +1 -0
- package/build/button/Button.resolver.mjs +76 -0
- package/build/button/Button.resolver.mjs.map +1 -0
- package/build/button/LegacyButton.js +114 -0
- package/build/button/LegacyButton.js.map +1 -0
- package/build/button/LegacyButton.mjs +112 -0
- package/build/button/LegacyButton.mjs.map +1 -0
- package/build/circularButton/CircularButton.js +21 -18
- package/build/circularButton/CircularButton.js.map +1 -1
- package/build/circularButton/CircularButton.mjs +22 -19
- package/build/circularButton/CircularButton.mjs.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.js +2 -2
- package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
- package/build/definitionList/DefinitionList.js.map +1 -1
- package/build/definitionList/DefinitionList.mjs.map +1 -1
- package/build/header/Header.js +2 -2
- package/build/header/Header.js.map +1 -1
- package/build/header/Header.mjs +1 -1
- package/build/i18n/de.json +0 -1
- package/build/i18n/de.json.js +0 -1
- package/build/i18n/de.json.js.map +1 -1
- package/build/i18n/de.json.mjs +0 -1
- package/build/i18n/de.json.mjs.map +1 -1
- package/build/i18n/it.json +0 -1
- package/build/i18n/it.json.js +0 -1
- package/build/i18n/it.json.js.map +1 -1
- package/build/i18n/it.json.mjs +0 -1
- package/build/i18n/it.json.mjs.map +1 -1
- package/build/i18n/th.json +0 -1
- package/build/i18n/th.json.js +0 -1
- package/build/i18n/th.json.js.map +1 -1
- package/build/i18n/th.json.mjs +0 -1
- package/build/i18n/th.json.mjs.map +1 -1
- package/build/index.js +2 -2
- package/build/index.mjs +1 -1
- package/build/link/Link.js +8 -3
- package/build/link/Link.js.map +1 -1
- package/build/link/Link.mjs +8 -3
- package/build/link/Link.mjs.map +1 -1
- package/build/main.css +416 -17
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +1 -3
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +1 -3
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +1 -4
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +1 -4
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
- package/build/select/Select.js +5 -3
- package/build/select/Select.js.map +1 -1
- package/build/select/Select.mjs +4 -2
- package/build/select/Select.mjs.map +1 -1
- package/build/styles/avatarLayout/AvatarLayout.css +11 -0
- package/build/styles/button/Button.css +240 -16
- package/build/styles/button/Button.vars.css +55 -0
- package/build/styles/button/LegacyButton.css +23 -0
- package/build/styles/circularButton/CircularButton.css +158 -17
- package/build/styles/main.css +416 -17
- package/build/types/avatarLayout/AvatarLayout.d.ts +1 -2
- package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
- package/build/types/avatarLayout/index.d.ts +1 -0
- package/build/types/avatarLayout/index.d.ts.map +1 -1
- package/build/types/avatarView/AvatarView.d.ts.map +1 -1
- package/build/types/button/Button.d.ts +1 -23
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/button/Button.resolver.d.ts +31 -0
- package/build/types/button/Button.resolver.d.ts.map +1 -0
- package/build/types/button/Button.types.d.ts +67 -0
- package/build/types/button/Button.types.d.ts.map +1 -0
- package/build/types/button/LegacyButton.d.ts +30 -0
- package/build/types/button/LegacyButton.d.ts.map +1 -0
- package/build/types/button/index.d.ts +2 -2
- package/build/types/button/index.d.ts.map +1 -1
- package/build/types/circularButton/CircularButton.d.ts +4 -11
- package/build/types/circularButton/CircularButton.d.ts.map +1 -1
- package/build/types/definitionList/DefinitionList.d.ts +2 -1
- package/build/types/definitionList/DefinitionList.d.ts.map +1 -1
- package/build/types/link/Link.d.ts +2 -2
- package/build/types/link/Link.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +1 -1
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
- package/build/types/select/Select.d.ts.map +1 -1
- package/build/upload/steps/completeStep/completeStep.js +2 -2
- package/build/upload/steps/completeStep/completeStep.js.map +1 -1
- package/build/upload/steps/completeStep/completeStep.mjs +1 -1
- package/build/upload/steps/processingStep/processingStep.js +2 -2
- package/build/upload/steps/processingStep/processingStep.js.map +1 -1
- package/build/upload/steps/processingStep/processingStep.mjs +1 -1
- package/build/uploadInput/UploadInput.js +3 -3
- package/build/uploadInput/UploadInput.js.map +1 -1
- package/build/uploadInput/UploadInput.mjs +1 -1
- package/package.json +3 -3
- package/src/avatarLayout/AvatarLayout.css +11 -0
- package/src/avatarLayout/AvatarLayout.less +18 -1
- package/src/avatarLayout/AvatarLayout.tsx +11 -3
- package/src/avatarLayout/index.ts +1 -0
- package/src/avatarView/AvatarView.tsx +1 -15
- package/src/button/Button.css +240 -16
- package/src/button/Button.less +208 -14
- package/src/button/Button.resolver.tsx +120 -0
- package/src/button/Button.spec.tsx +54 -231
- package/src/button/Button.story.tsx +610 -137
- package/src/button/Button.tsx +88 -132
- package/src/button/Button.types.ts +88 -0
- package/src/button/Button.vars.css +55 -0
- package/src/button/Button.vars.less +69 -0
- package/src/button/LegacyButton.css +23 -0
- package/src/button/LegacyButton.less +24 -0
- package/src/button/LegacyButton.spec.tsx +146 -0
- package/src/button/LegacyButton.story.tsx +224 -0
- package/src/button/LegacyButton.tsx +161 -0
- package/src/button/index.ts +2 -3
- package/src/circularButton/CircularButton.css +158 -17
- package/src/circularButton/CircularButton.less +91 -22
- package/src/circularButton/CircularButton.story.tsx +24 -45
- package/src/circularButton/CircularButton.tsx +25 -38
- package/src/circularButton/_button-label-states.less +34 -0
- package/src/definitionList/DefinitionList.spec.js +91 -0
- package/src/definitionList/DefinitionList.story.tsx +57 -57
- package/src/definitionList/DefinitionList.tsx +1 -1
- package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -1
- package/src/i18n/de.json +0 -1
- package/src/i18n/it.json +0 -1
- package/src/i18n/th.json +0 -1
- package/src/iconButton/IconButton.story.tsx +6 -6
- package/src/inputs/SelectInput.story.tsx +1 -1
- package/src/link/Link.tsx +15 -6
- package/src/main.css +416 -17
- package/src/main.less +1 -0
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +1 -7
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +1 -1
- package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +1 -3
- package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +1 -8
- package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +2 -5
- package/src/select/Select.tsx +1 -0
- package/src/slidingPanel/SlidingPanel.spec.js +56 -0
- package/src/button/__snapshots__/Button.spec.tsx.snap +0 -309
- package/src/slidingPanel/SlidingPanel.spec.tsx +0 -69
|
@@ -0,0 +1,224 @@
|
|
|
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
|
+
},
|
|
33
|
+
argTypes: {
|
|
34
|
+
as: {
|
|
35
|
+
control: {
|
|
36
|
+
type: 'select',
|
|
37
|
+
options: ['button', 'a'],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
type: {
|
|
41
|
+
type: {
|
|
42
|
+
name: 'enum',
|
|
43
|
+
value: ['accent', 'positive', 'negative'],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
size: {
|
|
47
|
+
type: {
|
|
48
|
+
name: 'enum',
|
|
49
|
+
value: ['xs', 'sm', 'md', 'lg'],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
priority: {
|
|
53
|
+
type: {
|
|
54
|
+
name: 'enum',
|
|
55
|
+
value: ['primary', 'secondary', 'tertiary'],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
sentiment: {
|
|
59
|
+
table: {
|
|
60
|
+
disable: true,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
iconStart: {
|
|
64
|
+
table: {
|
|
65
|
+
disable: true,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
iconEnd: {
|
|
69
|
+
table: {
|
|
70
|
+
disable: true,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
avatars: {
|
|
74
|
+
table: {
|
|
75
|
+
disable: true,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
'data-testid': {
|
|
79
|
+
table: {
|
|
80
|
+
disable: true,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
tags: ['autodocs'],
|
|
85
|
+
decorators: [withContainer],
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export default meta;
|
|
89
|
+
|
|
90
|
+
type Story = StoryObj<typeof Button>;
|
|
91
|
+
|
|
92
|
+
export const Basic: Story = {};
|
|
93
|
+
|
|
94
|
+
export const Secondary: Story = {
|
|
95
|
+
args: {
|
|
96
|
+
type: 'accent',
|
|
97
|
+
priority: 'secondary',
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const Tertiary: Story = {
|
|
102
|
+
args: {
|
|
103
|
+
type: 'accent',
|
|
104
|
+
priority: 'tertiary',
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const Negative: Story = {
|
|
109
|
+
args: {
|
|
110
|
+
type: 'negative',
|
|
111
|
+
priority: 'primary',
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const Loading: Story = {
|
|
116
|
+
args: {
|
|
117
|
+
loading: true,
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export const Variants: Story = {
|
|
122
|
+
render: () => {
|
|
123
|
+
return (
|
|
124
|
+
<div className="d-flex flex-column p-b-2 align-items-start">
|
|
125
|
+
<div className="d-flex flex-row p-b-2" style={{ gap: 'var(--size-16)' }}>
|
|
126
|
+
<Button type="accent" priority="primary">
|
|
127
|
+
Primary Accent
|
|
128
|
+
</Button>
|
|
129
|
+
<Button type="accent" priority="secondary">
|
|
130
|
+
Secondary Accent
|
|
131
|
+
</Button>
|
|
132
|
+
<Button type="accent" priority="tertiary">
|
|
133
|
+
Tertiary Accent
|
|
134
|
+
</Button>
|
|
135
|
+
</div>
|
|
136
|
+
<div className="d-flex flex-row p-b-2" style={{ gap: 'var(--size-16)' }}>
|
|
137
|
+
<Button type="positive" priority="primary">
|
|
138
|
+
Primary Positive
|
|
139
|
+
</Button>
|
|
140
|
+
<Button type="positive" priority="secondary">
|
|
141
|
+
Secondary Accent
|
|
142
|
+
</Button>
|
|
143
|
+
</div>
|
|
144
|
+
<div className="d-flex flex-row flex- p-b-2" style={{ gap: 'var(--size-16)' }}>
|
|
145
|
+
<Button type="negative" priority="primary">
|
|
146
|
+
Primary Negative
|
|
147
|
+
</Button>
|
|
148
|
+
<Button type="negative" priority="secondary">
|
|
149
|
+
Secondary Negative
|
|
150
|
+
</Button>
|
|
151
|
+
</div>
|
|
152
|
+
<div className="d-flex flex-row p-b-1" style={{ gap: 'var(--size-16)' }}>
|
|
153
|
+
<Button type="accent" priority="primary" disabled>
|
|
154
|
+
Button Disabled
|
|
155
|
+
</Button>
|
|
156
|
+
<Button type="accent" priority="secondary" disabled>
|
|
157
|
+
Button Disabled
|
|
158
|
+
</Button>
|
|
159
|
+
<Button type="accent" priority="tertiary" disabled>
|
|
160
|
+
Button Disabled
|
|
161
|
+
</Button>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
);
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const wait = async (duration = 500) =>
|
|
169
|
+
new Promise<void>((resolve) => {
|
|
170
|
+
setTimeout(resolve, duration);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
export const Focused: Story = {
|
|
174
|
+
play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {
|
|
175
|
+
const canvas = within(canvasElement);
|
|
176
|
+
const button = canvas.getByRole('button');
|
|
177
|
+
await userEvent.tab();
|
|
178
|
+
await expect(button).toHaveFocus();
|
|
179
|
+
await expect(button).toHaveTextContent('Focused!');
|
|
180
|
+
},
|
|
181
|
+
render: function Render(args: React.ComponentProps<typeof Button>) {
|
|
182
|
+
const [focused, setFocused] = useState(false);
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<Button {...args} onFocus={() => setFocused(true)}>
|
|
186
|
+
{focused ? 'Focused!' : 'Button text'}
|
|
187
|
+
</Button>
|
|
188
|
+
);
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export const SocialMedia: Story = {
|
|
193
|
+
render: () => {
|
|
194
|
+
return (
|
|
195
|
+
<>
|
|
196
|
+
<div className="m-b-2">
|
|
197
|
+
<button type="button" className="btn btn-google">
|
|
198
|
+
Login with Google
|
|
199
|
+
</button>
|
|
200
|
+
</div>
|
|
201
|
+
<div className="m-b-2">
|
|
202
|
+
<button type="button" className="btn btn-facebook">
|
|
203
|
+
Login with Facebook
|
|
204
|
+
</button>
|
|
205
|
+
</div>
|
|
206
|
+
<div className="m-b-2">
|
|
207
|
+
<button type="button" className="btn btn-lg btn-facebook">
|
|
208
|
+
Large Button
|
|
209
|
+
</button>
|
|
210
|
+
</div>
|
|
211
|
+
<div className="m-b-2">
|
|
212
|
+
<button type="button" className="btn btn-block btn-facebook">
|
|
213
|
+
Block Button
|
|
214
|
+
</button>
|
|
215
|
+
</div>
|
|
216
|
+
<div className="m-b-2">
|
|
217
|
+
<button type="button" className="btn btn-lg btn-block btn-facebook">
|
|
218
|
+
Large Block Button
|
|
219
|
+
</button>
|
|
220
|
+
</div>
|
|
221
|
+
</>
|
|
222
|
+
);
|
|
223
|
+
},
|
|
224
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
import { ElementType, forwardRef, MouseEvent } from 'react';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Size,
|
|
7
|
+
ControlType,
|
|
8
|
+
Priority,
|
|
9
|
+
ControlTypeAccent,
|
|
10
|
+
ControlTypeNegative,
|
|
11
|
+
ControlTypePositive,
|
|
12
|
+
PriorityPrimary,
|
|
13
|
+
PrioritySecondary,
|
|
14
|
+
PriorityTertiary,
|
|
15
|
+
SizeExtraSmall,
|
|
16
|
+
SizeSmall,
|
|
17
|
+
SizeMedium,
|
|
18
|
+
SizeLarge,
|
|
19
|
+
} from '../common';
|
|
20
|
+
import ProcessIndicator from '../processIndicator';
|
|
21
|
+
|
|
22
|
+
import messages from '../i18n/commonMessages/Button.messages';
|
|
23
|
+
import { typeClassMap, priorityClassMap } from './classMap';
|
|
24
|
+
import { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';
|
|
25
|
+
|
|
26
|
+
/** @deprecated */
|
|
27
|
+
type DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';
|
|
28
|
+
|
|
29
|
+
/** @deprecated */
|
|
30
|
+
type DeprecatedSizes = SizeExtraSmall;
|
|
31
|
+
|
|
32
|
+
type CommonProps = {
|
|
33
|
+
block?: boolean;
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
loading?: boolean;
|
|
36
|
+
/** @deprecated */
|
|
37
|
+
type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;
|
|
38
|
+
priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;
|
|
39
|
+
size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;
|
|
40
|
+
htmlType?: 'submit' | 'reset' | 'button';
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type ButtonProps = CommonProps &
|
|
44
|
+
Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {
|
|
45
|
+
as?: 'button';
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type AnchorProps = CommonProps &
|
|
49
|
+
Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {
|
|
50
|
+
as?: 'a';
|
|
51
|
+
href?: string;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type LegacyButtonProps = ButtonProps | AnchorProps;
|
|
55
|
+
|
|
56
|
+
export type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated make sure you use new Button component via `<Button v2 .. />` and new props
|
|
60
|
+
*/
|
|
61
|
+
const LegacyButton = forwardRef<ButtonReferenceType, LegacyButtonProps>(
|
|
62
|
+
(
|
|
63
|
+
{
|
|
64
|
+
as: component = 'button',
|
|
65
|
+
block = false,
|
|
66
|
+
children,
|
|
67
|
+
className,
|
|
68
|
+
disabled,
|
|
69
|
+
loading = false,
|
|
70
|
+
priority = Priority.PRIMARY,
|
|
71
|
+
size = Size.MEDIUM,
|
|
72
|
+
type = ControlType.ACCENT,
|
|
73
|
+
onClick,
|
|
74
|
+
...rest
|
|
75
|
+
}: LegacyButtonProps,
|
|
76
|
+
ref,
|
|
77
|
+
) => {
|
|
78
|
+
const intl = useIntl();
|
|
79
|
+
|
|
80
|
+
logDeprecationNotices({ size, type });
|
|
81
|
+
|
|
82
|
+
const newType = establishNewType(type);
|
|
83
|
+
const newPriority = establishNewPriority(priority, type);
|
|
84
|
+
|
|
85
|
+
const classes = clsx(
|
|
86
|
+
`btn btn-${size}`,
|
|
87
|
+
`np-btn np-btn-${size}`,
|
|
88
|
+
{
|
|
89
|
+
'btn-loading': loading,
|
|
90
|
+
'btn-block np-btn-block': block,
|
|
91
|
+
disabled,
|
|
92
|
+
},
|
|
93
|
+
// @ts-expect-error fix when refactor `typeClassMap` to TypeScript
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
95
|
+
typeClassMap[newType],
|
|
96
|
+
// @ts-expect-error fix when refactor `typeClassMap` to TypeScript
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
98
|
+
priorityClassMap[newPriority],
|
|
99
|
+
className,
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
function processIndicatorSize() {
|
|
103
|
+
return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const Element = (component as ElementType) ?? 'button';
|
|
107
|
+
let props;
|
|
108
|
+
|
|
109
|
+
if (Element === 'button') {
|
|
110
|
+
const { htmlType = 'button', ...restProps } = rest as ButtonProps;
|
|
111
|
+
props = {
|
|
112
|
+
...restProps,
|
|
113
|
+
disabled,
|
|
114
|
+
'aria-disabled': loading,
|
|
115
|
+
type: htmlType,
|
|
116
|
+
};
|
|
117
|
+
} else {
|
|
118
|
+
props = {
|
|
119
|
+
...rest,
|
|
120
|
+
'aria-disabled': loading,
|
|
121
|
+
} as AnchorProps;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Ensures that the button cannot be activated in loading or disabled mode,
|
|
126
|
+
* when `aria-disabled` might be used over the `disabled` HTML attribute
|
|
127
|
+
*/
|
|
128
|
+
const handleClick =
|
|
129
|
+
(handler: LegacyButtonProps['onClick']) =>
|
|
130
|
+
(event: MouseEvent<HTMLButtonElement> & MouseEvent<HTMLAnchorElement>) => {
|
|
131
|
+
if (disabled || loading) {
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
} else if (typeof handler === 'function') {
|
|
134
|
+
handler(event);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<Element
|
|
140
|
+
ref={ref as React.Ref<ButtonReferenceType>}
|
|
141
|
+
className={classes}
|
|
142
|
+
onClick={handleClick(onClick)}
|
|
143
|
+
{...props}
|
|
144
|
+
aria-live={loading ? 'polite' : 'off'}
|
|
145
|
+
aria-busy={loading}
|
|
146
|
+
aria-label={loading ? intl.formatMessage(messages.loadingAriaLabel) : rest['aria-label']}
|
|
147
|
+
>
|
|
148
|
+
{children}
|
|
149
|
+
{loading && (
|
|
150
|
+
<ProcessIndicator
|
|
151
|
+
size={processIndicatorSize()}
|
|
152
|
+
className="btn-loader"
|
|
153
|
+
data-testid="ButtonProgressIndicator"
|
|
154
|
+
/>
|
|
155
|
+
)}
|
|
156
|
+
</Element>
|
|
157
|
+
);
|
|
158
|
+
},
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
export default LegacyButton;
|
package/src/button/index.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export { default } from './Button';
|
|
2
|
-
|
|
3
|
-
export type { Props as ButtonProps } from './Button';
|
|
1
|
+
export { default } from './Button.resolver';
|
|
2
|
+
export type { ButtonProps } from './Button.resolver';
|
|
@@ -2,32 +2,173 @@
|
|
|
2
2
|
display: inline-flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
align-items: center;
|
|
5
|
+
text-align: center;
|
|
5
6
|
cursor: pointer;
|
|
7
|
+
position: relative;
|
|
6
8
|
}
|
|
7
|
-
.np-circular-btn
|
|
8
|
-
|
|
9
|
+
.np-circular-btn .tw-icon {
|
|
10
|
+
position: absolute;
|
|
11
|
+
top: 16px;
|
|
12
|
+
top: var(--size-16);
|
|
13
|
+
pointer-events: none;
|
|
14
|
+
color: white;
|
|
15
|
+
transition: color 0.15s ease-in-out;
|
|
16
|
+
width: 100%;
|
|
17
|
+
left: 0;
|
|
18
|
+
}
|
|
19
|
+
[dir="rtl"] .np-circular-btn .tw-icon {
|
|
20
|
+
right: 0;
|
|
21
|
+
left: auto;
|
|
22
|
+
left: initial;
|
|
23
|
+
}
|
|
24
|
+
@media (max-width: 320px) {
|
|
25
|
+
.np-circular-btn .tw-icon {
|
|
26
|
+
top: 12px;
|
|
27
|
+
top: var(--size-12);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
.np-circular-btn .tw-icon > svg {
|
|
31
|
+
margin: 0 auto;
|
|
32
|
+
}
|
|
33
|
+
.np-theme-personal .np-circular-btn {
|
|
34
|
+
/* stylelint-disable-next-line no-duplicate-selectors */
|
|
35
|
+
}
|
|
36
|
+
.np-theme-personal .np-circular-btn .tw-icon,
|
|
37
|
+
.np-theme-personal .np-circular-btn .tw-icon:hover,
|
|
38
|
+
.np-theme-personal .np-circular-btn .tw-icon:active {
|
|
39
|
+
color: var(--color-interactive-control);
|
|
40
|
+
}
|
|
41
|
+
.np-theme-personal .np-circular-btn.negative .tw-icon,
|
|
42
|
+
.np-theme-personal .np-circular-btn.negative.secondary:not(.disabled):not(:disabled):hover .tw-icon,
|
|
43
|
+
.np-theme-personal .np-circular-btn.negative.secondary:not(.disabled):not(:disabled):active .tw-icon {
|
|
44
|
+
color: var(--color-contrast) !important;
|
|
45
|
+
}
|
|
46
|
+
.np-theme-personal .np-circular-btn.negative.secondary:not(.disabled):not(:disabled) .tw-icon {
|
|
47
|
+
color: var(--color-sentiment-negative) !important;
|
|
48
|
+
}
|
|
49
|
+
.np-circular-btn.accent .np-circular-btn__label {
|
|
50
|
+
color: #00a2dd;
|
|
51
|
+
color: var(--color-interactive-accent);
|
|
52
|
+
}
|
|
53
|
+
.np-circular-btn.accent:not(.disabled):not(:disabled):hover .np-circular-btn__label {
|
|
54
|
+
color: #008fc9;
|
|
55
|
+
color: var(--color-interactive-accent-hover);
|
|
56
|
+
}
|
|
57
|
+
.np-circular-btn.accent:active .np-circular-btn__label,
|
|
58
|
+
.np-circular-btn.accent input[type="button"]:active ~ .np-circular-btn__label {
|
|
59
|
+
color: #0081ba;
|
|
60
|
+
color: var(--color-interactive-accent-active);
|
|
61
|
+
}
|
|
62
|
+
.np-circular-btn.accent.secondary .tw-icon {
|
|
63
|
+
color: #00a2dd;
|
|
64
|
+
color: var(--color-interactive-accent);
|
|
65
|
+
}
|
|
66
|
+
.np-circular-btn.accent.secondary:not(.disabled):not(:disabled):hover .tw-icon,
|
|
67
|
+
.np-circular-btn.accent.secondary input[type="button"]:active + .tw-icon {
|
|
68
|
+
color: white;
|
|
69
|
+
}
|
|
70
|
+
.np-circular-btn.positive .np-circular-btn__label {
|
|
71
|
+
color: #2ead4b;
|
|
72
|
+
color: var(--color-interactive-positive);
|
|
73
|
+
}
|
|
74
|
+
.np-circular-btn.positive:not(.disabled):not(:disabled):hover .np-circular-btn__label {
|
|
75
|
+
color: #069939;
|
|
76
|
+
color: var(--color-interactive-positive-hover);
|
|
77
|
+
}
|
|
78
|
+
.np-circular-btn.positive:active .np-circular-btn__label,
|
|
79
|
+
.np-circular-btn.positive input[type="button"]:active ~ .np-circular-btn__label {
|
|
80
|
+
color: #008b2b;
|
|
81
|
+
color: var(--color-interactive-positive-active);
|
|
82
|
+
}
|
|
83
|
+
.np-circular-btn.positive.secondary .tw-icon {
|
|
84
|
+
color: #2ead4b;
|
|
85
|
+
color: var(--color-interactive-positive);
|
|
86
|
+
}
|
|
87
|
+
.np-circular-btn.positive.secondary:not(.disabled):not(:disabled):hover .tw-icon,
|
|
88
|
+
.np-circular-btn.positive.secondary input[type="button"]:active + .tw-icon {
|
|
89
|
+
color: white;
|
|
90
|
+
}
|
|
91
|
+
.np-circular-btn.negative .np-circular-btn__label {
|
|
92
|
+
color: #e74848;
|
|
93
|
+
color: var(--color-interactive-negative);
|
|
94
|
+
}
|
|
95
|
+
.np-circular-btn.negative:not(.disabled):not(:disabled):hover .np-circular-btn__label {
|
|
96
|
+
color: #d03238;
|
|
97
|
+
color: var(--color-interactive-negative-hover);
|
|
98
|
+
}
|
|
99
|
+
.np-circular-btn.negative:active .np-circular-btn__label,
|
|
100
|
+
.np-circular-btn.negative input[type="button"]:active ~ .np-circular-btn__label {
|
|
101
|
+
color: #bf1e2c;
|
|
102
|
+
color: var(--color-interactive-negative-active);
|
|
103
|
+
}
|
|
104
|
+
.np-circular-btn.negative.secondary .tw-icon {
|
|
105
|
+
color: #e74848;
|
|
106
|
+
color: var(--color-interactive-negative);
|
|
107
|
+
}
|
|
108
|
+
.np-circular-btn.negative.secondary:not(.disabled):not(:disabled):hover .tw-icon,
|
|
109
|
+
.np-circular-btn.negative.secondary input[type="button"]:active + .tw-icon {
|
|
110
|
+
color: white;
|
|
111
|
+
}
|
|
112
|
+
.np-theme-personal .np-circular-btn.accent .np-circular-btn__label {
|
|
9
113
|
color: var(--color-interactive-primary);
|
|
10
114
|
}
|
|
11
|
-
.np-
|
|
12
|
-
.np-circular-btn-secondary-default .np-circular-btn-label:not(.disabled):not(:disabled):hover {
|
|
115
|
+
.np-theme-personal .np-circular-btn.accent:not(.disabled):not(:disabled):hover .np-circular-btn__label {
|
|
13
116
|
color: var(--color-interactive-primary-hover);
|
|
14
117
|
}
|
|
15
|
-
.np-
|
|
16
|
-
.np-
|
|
118
|
+
.np-theme-personal .np-circular-btn.accent:active .np-circular-btn__label,
|
|
119
|
+
.np-theme-personal .np-circular-btn.accent input[type="button"]:active ~ .np-circular-btn__label {
|
|
17
120
|
color: var(--color-interactive-primary-active);
|
|
18
121
|
}
|
|
19
|
-
.np-
|
|
20
|
-
|
|
21
|
-
|
|
122
|
+
.np-theme-personal .np-circular-btn.accent.secondary .tw-icon {
|
|
123
|
+
color: var(--color-interactive-primary);
|
|
124
|
+
}
|
|
125
|
+
.np-theme-personal .np-circular-btn.accent.secondary:not(.disabled):not(:disabled):hover .tw-icon,
|
|
126
|
+
.np-theme-personal .np-circular-btn.accent.secondary input[type="button"]:active + .tw-icon {
|
|
127
|
+
color: white;
|
|
128
|
+
color: var(--color-interactive-control);
|
|
129
|
+
}
|
|
130
|
+
.np-theme-personal .np-circular-btn.accent.secondary:active input[type="button"] + .tw-icon {
|
|
131
|
+
color: var(--color-interactive-control);
|
|
132
|
+
}
|
|
133
|
+
.np-theme-personal .np-circular-btn.positive .np-circular-btn__label {
|
|
134
|
+
color: var(--color-interactive-primary);
|
|
135
|
+
}
|
|
136
|
+
.np-theme-personal .np-circular-btn.positive:not(.disabled):not(:disabled):hover .np-circular-btn__label {
|
|
137
|
+
color: var(--color-interactive-primary-hover);
|
|
138
|
+
}
|
|
139
|
+
.np-theme-personal .np-circular-btn.positive:active .np-circular-btn__label,
|
|
140
|
+
.np-theme-personal .np-circular-btn.positive input[type="button"]:active ~ .np-circular-btn__label {
|
|
141
|
+
color: var(--color-interactive-primary-active);
|
|
142
|
+
}
|
|
143
|
+
.np-theme-personal .np-circular-btn.positive.secondary .tw-icon {
|
|
144
|
+
color: var(--color-interactive-primary);
|
|
145
|
+
}
|
|
146
|
+
.np-theme-personal .np-circular-btn.positive.secondary:not(.disabled):not(:disabled):hover .tw-icon,
|
|
147
|
+
.np-theme-personal .np-circular-btn.positive.secondary input[type="button"]:active + .tw-icon {
|
|
148
|
+
color: white;
|
|
149
|
+
color: var(--color-interactive-control);
|
|
150
|
+
}
|
|
151
|
+
.np-theme-personal .np-circular-btn.positive.secondary:active input[type="button"] + .tw-icon {
|
|
152
|
+
color: var(--color-interactive-control);
|
|
153
|
+
}
|
|
154
|
+
.np-theme-personal .np-circular-btn.negative .np-circular-btn__label {
|
|
155
|
+
color: var(--color-sentiment-negative);
|
|
156
|
+
}
|
|
157
|
+
.np-theme-personal .np-circular-btn.negative:not(.disabled):not(:disabled):hover .np-circular-btn__label {
|
|
158
|
+
color: var(--color-sentiment-negative-hover);
|
|
159
|
+
}
|
|
160
|
+
.np-theme-personal .np-circular-btn.negative:active .np-circular-btn__label,
|
|
161
|
+
.np-theme-personal .np-circular-btn.negative input[type="button"]:active ~ .np-circular-btn__label {
|
|
162
|
+
color: var(--color-sentiment-negative-active);
|
|
22
163
|
}
|
|
23
|
-
.np-
|
|
24
|
-
|
|
25
|
-
color: var(--color-sentiment-negative-primary-hover);
|
|
164
|
+
.np-theme-personal .np-circular-btn.negative.secondary .tw-icon {
|
|
165
|
+
color: var(--color-sentiment-negative);
|
|
26
166
|
}
|
|
27
|
-
.np-
|
|
28
|
-
.np-
|
|
29
|
-
color:
|
|
167
|
+
.np-theme-personal .np-circular-btn.negative.secondary:not(.disabled):not(:disabled):hover .tw-icon,
|
|
168
|
+
.np-theme-personal .np-circular-btn.negative.secondary input[type="button"]:active + .tw-icon {
|
|
169
|
+
color: white;
|
|
170
|
+
color: var(--color-interactive-control);
|
|
30
171
|
}
|
|
31
|
-
.np-circular-btn-
|
|
32
|
-
|
|
172
|
+
.np-theme-personal .np-circular-btn.negative.secondary:active input[type="button"] + .tw-icon {
|
|
173
|
+
color: var(--color-interactive-control);
|
|
33
174
|
}
|