@transferwise/components 0.0.0-experimental-2524bc4 → 0.0.0-experimental-0ee6ecc
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/button/Button/src/Button.js +93 -0
- package/build/button/Button/src/Button.js.map +1 -0
- package/build/button/Button/src/Button.mjs +91 -0
- package/build/button/Button/src/Button.mjs.map +1 -0
- package/build/button/{Button.js → LegacyButton/Button.js} +25 -24
- package/build/button/LegacyButton/Button.js.map +1 -0
- package/build/button/{Button.mjs → LegacyButton/Button.mjs} +25 -24
- package/build/button/LegacyButton/Button.mjs.map +1 -0
- package/build/button/LegacyButton/classMap.js +42 -0
- package/build/button/LegacyButton/classMap.js.map +1 -0
- package/build/button/LegacyButton/classMap.mjs +39 -0
- package/build/button/LegacyButton/classMap.mjs.map +1 -0
- package/build/button/{legacyUtils → LegacyButton/legacyUtils}/legacyUtils.js +21 -21
- package/build/button/LegacyButton/legacyUtils/legacyUtils.js.map +1 -0
- package/build/button/{legacyUtils → LegacyButton/legacyUtils}/legacyUtils.mjs +21 -21
- package/build/button/LegacyButton/legacyUtils/legacyUtils.mjs.map +1 -0
- package/build/button/src/Button.js +64 -0
- package/build/button/src/Button.js.map +1 -0
- package/build/button/src/Button.mjs +62 -0
- package/build/button/src/Button.mjs.map +1 -0
- package/build/circularButton/CircularButton.js +1 -1
- package/build/circularButton/CircularButton.js.map +1 -1
- package/build/circularButton/CircularButton.mjs +1 -1
- package/build/circularButton/CircularButton.mjs.map +1 -1
- package/build/common/action/Action.js +1 -1
- package/build/common/action/Action.js.map +1 -1
- package/build/common/action/Action.mjs +1 -1
- package/build/common/action/Action.mjs.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.js +1 -1
- package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
- package/build/header/Header.js +1 -1
- package/build/header/Header.mjs +1 -1
- package/build/i18n/es.json +0 -1
- package/build/i18n/es.json.js +0 -1
- package/build/i18n/es.json.js.map +1 -1
- package/build/i18n/es.json.mjs +0 -1
- package/build/i18n/es.json.mjs.map +1 -1
- package/build/i18n/fr.json +5 -6
- package/build/i18n/fr.json.js +5 -6
- package/build/i18n/fr.json.js.map +1 -1
- package/build/i18n/fr.json.mjs +5 -6
- package/build/i18n/fr.json.mjs.map +1 -1
- package/build/i18n/hu.json +0 -1
- package/build/i18n/hu.json.js +0 -1
- package/build/i18n/hu.json.js.map +1 -1
- package/build/i18n/hu.json.mjs +0 -1
- package/build/i18n/hu.json.mjs.map +1 -1
- package/build/i18n/id.json +0 -1
- package/build/i18n/id.json.js +0 -1
- package/build/i18n/id.json.js.map +1 -1
- package/build/i18n/id.json.mjs +0 -1
- package/build/i18n/id.json.mjs.map +1 -1
- package/build/i18n/ro.json +0 -1
- package/build/i18n/ro.json.js +0 -1
- package/build/i18n/ro.json.js.map +1 -1
- package/build/i18n/ro.json.mjs +0 -1
- package/build/i18n/ro.json.mjs.map +1 -1
- package/build/index.js +1 -1
- 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 +288 -29
- package/build/nudge/Nudge.js +1 -1
- package/build/nudge/Nudge.js.map +1 -1
- package/build/nudge/Nudge.mjs +1 -1
- package/build/nudge/Nudge.mjs.map +1 -1
- package/build/select/Select.js +1 -1
- package/build/select/Select.mjs +1 -1
- package/build/styles/avatarLayout/AvatarLayout.css +11 -0
- package/build/styles/button/Button/less/Button.css +253 -0
- package/build/styles/button/Button/less/Button.vars.css +57 -0
- package/build/styles/iconButton/IconButton.css +24 -29
- package/build/styles/main.css +288 -29
- 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/button/Button/index.d.ts +3 -0
- package/build/types/button/Button/index.d.ts.map +1 -0
- package/build/types/button/Button/src/Button.d.ts +4 -0
- package/build/types/button/Button/src/Button.d.ts.map +1 -0
- package/build/types/button/Button/src/Button.types.d.ts +50 -0
- package/build/types/button/Button/src/Button.types.d.ts.map +1 -0
- package/build/types/button/Button/src/index.d.ts +2 -0
- package/build/types/button/Button/src/index.d.ts.map +1 -0
- package/build/types/button/{Button.d.ts → LegacyButton/Button.d.ts} +6 -5
- package/build/types/button/LegacyButton/Button.d.ts.map +1 -0
- package/build/types/button/LegacyButton/classMap.d.ts.map +1 -0
- package/build/types/button/LegacyButton/index.d.ts +3 -0
- package/build/types/button/LegacyButton/index.d.ts.map +1 -0
- package/build/types/button/LegacyButton/legacyUtils/index.d.ts.map +1 -0
- package/build/types/button/{legacyUtils → LegacyButton/legacyUtils}/legacyUtils.d.ts +1 -1
- package/build/types/button/LegacyButton/legacyUtils/legacyUtils.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/button/src/Button.d.ts +40 -0
- package/build/types/button/src/Button.d.ts.map +1 -0
- package/build/types/button/src/index.d.ts +3 -0
- package/build/types/button/src/index.d.ts.map +1 -0
- package/build/types/link/Link.d.ts +2 -2
- package/build/types/link/Link.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/build/upload/steps/completeStep/completeStep.js +1 -1
- package/build/upload/steps/completeStep/completeStep.mjs +1 -1
- package/build/upload/steps/processingStep/processingStep.js +1 -1
- package/build/upload/steps/processingStep/processingStep.mjs +1 -1
- package/build/uploadInput/UploadInput.js +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/avatarWrapper/AvatarWrapper.story.tsx +2 -0
- package/src/button/Button/index.ts +2 -0
- package/src/button/Button/less/Button.css +253 -0
- package/src/button/Button/less/Button.less +221 -0
- package/src/button/Button/less/Button.vars.css +57 -0
- package/src/button/Button/less/Button.vars.less +65 -0
- package/src/button/Button/src/Button.tsx +116 -0
- package/src/button/Button/src/Button.types.ts +70 -0
- package/src/button/Button/src/index.ts +1 -0
- package/src/button/Button/stories/Button.story.tsx +314 -0
- package/src/button/Button/stories/Button.tests.story.tsx +288 -0
- package/src/button/Button/test/Button.spec.tsx +328 -0
- package/src/button/{Button.less → LegacyButton/Button.less} +1 -1
- package/src/button/{Button.spec.tsx → LegacyButton/Button.spec.tsx} +3 -3
- package/src/button/LegacyButton/Button.story.tsx +224 -0
- package/src/button/{Button.tsx → LegacyButton/Button.tsx} +12 -9
- package/src/button/{classMap.ts → LegacyButton/classMap.ts} +1 -1
- package/src/button/LegacyButton/index.ts +3 -0
- package/src/button/{legacyUtils → LegacyButton/legacyUtils}/legacyUtils.spec.tsx +2 -2
- package/src/button/{legacyUtils → LegacyButton/legacyUtils}/legacyUtils.ts +2 -2
- package/src/button/index.ts +2 -3
- package/src/button/src/Button.tsx +60 -0
- package/src/button/src/index.ts +2 -0
- package/src/button/test/Button.spec.tsx +32 -0
- package/src/circularButton/CircularButton.tsx +1 -1
- package/src/common/action/Action.tsx +1 -1
- package/src/i18n/es.json +0 -1
- package/src/i18n/fr.json +5 -6
- package/src/i18n/hu.json +0 -1
- package/src/i18n/id.json +0 -1
- package/src/i18n/ro.json +0 -1
- package/src/iconButton/IconButton.css +24 -29
- package/src/iconButton/IconButton.less +4 -4
- package/src/link/Link.tsx +15 -6
- package/src/main.css +288 -29
- package/src/main.less +2 -1
- package/src/nudge/Nudge.tsx +1 -1
- package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.story.tsx +1 -1
- package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +1 -1
- package/src/primitives/PrimitiveButton/stories/PrimitiveButton.story.tsx +1 -1
- package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +2 -3
- package/src/test-utils/index.tsx +0 -1
- package/build/button/Button.js.map +0 -1
- package/build/button/Button.mjs.map +0 -1
- package/build/button/classMap.js +0 -42
- package/build/button/classMap.js.map +0 -1
- package/build/button/classMap.mjs +0 -39
- package/build/button/classMap.mjs.map +0 -1
- package/build/button/legacyUtils/legacyUtils.js.map +0 -1
- package/build/button/legacyUtils/legacyUtils.mjs.map +0 -1
- package/build/types/button/Button.d.ts.map +0 -1
- package/build/types/button/classMap.d.ts.map +0 -1
- package/build/types/button/legacyUtils/index.d.ts.map +0 -1
- package/build/types/button/legacyUtils/legacyUtils.d.ts.map +0 -1
- package/src/button/Button.story.tsx +0 -163
- /package/build/styles/button/{Button.css → LegacyButton/Button.css} +0 -0
- /package/build/types/button/{classMap.d.ts → LegacyButton/classMap.d.ts} +0 -0
- /package/build/types/button/{legacyUtils → LegacyButton/legacyUtils}/index.d.ts +0 -0
- /package/src/button/{Button.css → LegacyButton/Button.css} +0 -0
- /package/src/button/{__snapshots__ → LegacyButton/__snapshots__}/Button.spec.tsx.snap +0 -0
- /package/src/button/{legacyUtils → LegacyButton/legacyUtils}/index.ts +0 -0
|
@@ -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
|
+
appearance: {
|
|
59
|
+
table: {
|
|
60
|
+
disable: true,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
iconLeft: {
|
|
64
|
+
table: {
|
|
65
|
+
disable: true,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
iconRight: {
|
|
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
|
+
};
|
|
@@ -16,10 +16,10 @@ import {
|
|
|
16
16
|
SizeSmall,
|
|
17
17
|
SizeMedium,
|
|
18
18
|
SizeLarge,
|
|
19
|
-
} from '
|
|
20
|
-
import ProcessIndicator from '
|
|
19
|
+
} from '../../common';
|
|
20
|
+
import ProcessIndicator from '../../processIndicator';
|
|
21
21
|
|
|
22
|
-
import messages from '
|
|
22
|
+
import messages from '../../i18n/commonMessages/Button.messages';
|
|
23
23
|
import { typeClassMap, priorityClassMap } from './classMap';
|
|
24
24
|
import { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';
|
|
25
25
|
|
|
@@ -38,15 +38,16 @@ type CommonProps = {
|
|
|
38
38
|
size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
type ButtonProps = CommonProps &
|
|
41
|
+
export type ButtonProps = CommonProps &
|
|
42
42
|
Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {
|
|
43
|
-
as?: 'button';
|
|
43
|
+
as?: 'button' | undefined;
|
|
44
44
|
htmlType?: 'submit' | 'reset' | 'button';
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
type AnchorProps = CommonProps &
|
|
47
|
+
export type AnchorProps = CommonProps &
|
|
48
48
|
Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {
|
|
49
|
-
as?: 'a';
|
|
49
|
+
as?: 'a' | undefined;
|
|
50
|
+
href?: string;
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
export type Props = ButtonProps | AnchorProps;
|
|
@@ -68,7 +69,7 @@ const Button = forwardRef<ButtonReferenceType, Props>(
|
|
|
68
69
|
onClick,
|
|
69
70
|
...rest
|
|
70
71
|
}: Props,
|
|
71
|
-
|
|
72
|
+
ref,
|
|
72
73
|
) => {
|
|
73
74
|
const intl = useIntl();
|
|
74
75
|
|
|
@@ -132,7 +133,7 @@ const Button = forwardRef<ButtonReferenceType, Props>(
|
|
|
132
133
|
|
|
133
134
|
return (
|
|
134
135
|
<Element
|
|
135
|
-
ref={
|
|
136
|
+
ref={ref}
|
|
136
137
|
className={classes}
|
|
137
138
|
onClick={handleClick(onClick)}
|
|
138
139
|
{...props}
|
|
@@ -153,4 +154,6 @@ const Button = forwardRef<ButtonReferenceType, Props>(
|
|
|
153
154
|
},
|
|
154
155
|
);
|
|
155
156
|
|
|
157
|
+
Button.displayName = 'Button';
|
|
158
|
+
|
|
156
159
|
export default Button;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
import { ControlType, Priority, Size, Type } from '
|
|
3
|
-
import { cleanup } from '
|
|
2
|
+
import { ControlType, Priority, Size, Type } from '../../../common';
|
|
3
|
+
import { cleanup } from '../../../test-utils';
|
|
4
4
|
|
|
5
5
|
import { establishNewPriority, establishNewType, logDeprecationNotices } from '.';
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ControlType, Priority, Size, Type } from '
|
|
2
|
-
import { logActionRequired, logActionRequiredIf } from '
|
|
1
|
+
import { ControlType, Priority, Size, Type } from '../../../common';
|
|
2
|
+
import { logActionRequired, logActionRequiredIf } from '../../../utilities';
|
|
3
3
|
|
|
4
4
|
const deprecatedTypeMap: Record<Type, ControlType> = {
|
|
5
5
|
[Type.PRIMARY]: ControlType.ACCENT,
|
package/src/button/index.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export { default } from './
|
|
2
|
-
|
|
3
|
-
export type { Props as ButtonProps } from './Button';
|
|
1
|
+
export { default } from './src';
|
|
2
|
+
export * from './src';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import LegacyButton, { ButtonProps as LegacyButtonProps } from '../LegacyButton';
|
|
4
|
+
import NewButton from '../Button';
|
|
5
|
+
import { ButtonProps as NewButtonProps } from '../Button/src/Button.types';
|
|
6
|
+
|
|
7
|
+
export type ButtonProps = {
|
|
8
|
+
useNewButton?: boolean;
|
|
9
|
+
} & (LegacyButtonProps | NewButtonProps);
|
|
10
|
+
|
|
11
|
+
const mapProps = (props: LegacyButtonProps): NewButtonProps => {
|
|
12
|
+
const { priority, size, type, as, ...newProps } = props;
|
|
13
|
+
|
|
14
|
+
const priorityMapping: Record<string, Record<string, NewButtonProps['priority']>> = {
|
|
15
|
+
accent: {
|
|
16
|
+
primary: 'primary',
|
|
17
|
+
secondary: 'tertiary',
|
|
18
|
+
tertiary: 'minimal',
|
|
19
|
+
},
|
|
20
|
+
positive: {
|
|
21
|
+
primary: 'primary',
|
|
22
|
+
secondary: 'tertiary',
|
|
23
|
+
tertiary: 'tertiary',
|
|
24
|
+
},
|
|
25
|
+
negative: {
|
|
26
|
+
primary: 'primary',
|
|
27
|
+
secondary: 'secondary',
|
|
28
|
+
tertiary: 'secondary',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const mappedPriority =
|
|
33
|
+
type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;
|
|
34
|
+
const mappedAppearance = type === 'negative' ? 'negative' : undefined;
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
...newProps,
|
|
38
|
+
size:
|
|
39
|
+
size === 'xs' || size === 'sm' ? 'sm' : size === 'md' ? 'md' : size === 'lg' ? 'lg' : size,
|
|
40
|
+
priority: mappedPriority,
|
|
41
|
+
appearance: mappedAppearance || ('appearance' in props ? props.appearance : undefined),
|
|
42
|
+
type: as === 'button' ? props.htmlType : undefined,
|
|
43
|
+
href: as === 'a' ? props.href || '' : undefined,
|
|
44
|
+
} as NewButtonProps;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(
|
|
48
|
+
({ useNewButton = false, ...props }, ref) => {
|
|
49
|
+
if (useNewButton) {
|
|
50
|
+
const mappedProps = mapProps(props as LegacyButtonProps);
|
|
51
|
+
return <NewButton {...mappedProps} ref={ref as any} />;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return <LegacyButton {...(props as LegacyButtonProps)} ref={ref} />;
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
Button.displayName = 'Button';
|
|
59
|
+
|
|
60
|
+
export default Button;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { render, screen } from '../../test-utils';
|
|
2
|
+
import Button, { ButtonProps } from '..';
|
|
3
|
+
|
|
4
|
+
describe('Button', () => {
|
|
5
|
+
const legacyProps: ButtonProps = {
|
|
6
|
+
priority: 'primary',
|
|
7
|
+
size: 'md',
|
|
8
|
+
type: 'accent',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const newProps: ButtonProps = {
|
|
12
|
+
useNewButton: true,
|
|
13
|
+
priority: 'primary',
|
|
14
|
+
size: 'md',
|
|
15
|
+
type: 'accent',
|
|
16
|
+
testId: 'new-button',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
it('renders LegacyButton when useNewButton is false', () => {
|
|
20
|
+
render(<Button {...legacyProps}>Legacy Button</Button>);
|
|
21
|
+
const button = screen.getByText('Legacy Button');
|
|
22
|
+
expect(button).toBeInTheDocument();
|
|
23
|
+
expect(button).toHaveClass('btn btn-md np-btn np-btn-md btn-accent btn-priority-1');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('renders the new Button when useNewButton is true', () => {
|
|
27
|
+
render(<Button {...newProps}>New Button</Button>);
|
|
28
|
+
const button = screen.getByTestId('new-button');
|
|
29
|
+
expect(button).toBeInTheDocument();
|
|
30
|
+
expect(button).toHaveClass('wds-Button wds-Button--medium wds-Button--primary');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -2,7 +2,7 @@ import { clsx } from 'clsx';
|
|
|
2
2
|
import { cloneElement } from 'react';
|
|
3
3
|
|
|
4
4
|
import Body from '../body/Body';
|
|
5
|
-
import { typeClassMap, priorityClassMap } from '../button/classMap';
|
|
5
|
+
import { typeClassMap, priorityClassMap } from '../button/LegacyButton/classMap';
|
|
6
6
|
import { Breakpoint, ControlType, Priority, Typography } from '../common';
|
|
7
7
|
import Circle from '../common/circle';
|
|
8
8
|
import { useMedia } from '../common/hooks/useMedia';
|
|
@@ -22,7 +22,7 @@ export function Action({ action, className, variant = 'button' }: Props) {
|
|
|
22
22
|
if ('href' in action) {
|
|
23
23
|
return (
|
|
24
24
|
<Link
|
|
25
|
-
href={action.href}
|
|
25
|
+
href={action.href ?? ''}
|
|
26
26
|
className={className}
|
|
27
27
|
aria-label={action['aria-label']}
|
|
28
28
|
target={action.target}
|
package/src/i18n/es.json
CHANGED
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"neptune.UploadButton.allFileTypes": "Todos los tipos de archivos",
|
|
55
55
|
"neptune.UploadButton.dropFiles": "Arrastra un archivo para subirlo",
|
|
56
56
|
"neptune.UploadButton.instructions": "{fileTypes}, menor que {size}MB",
|
|
57
|
-
"neptune.UploadButton.maximumFiles": "Máximo {maxFiles} archivos.",
|
|
58
57
|
"neptune.UploadButton.uploadFile": "Subir archivo",
|
|
59
58
|
"neptune.UploadButton.uploadFiles": "Subir archivos",
|
|
60
59
|
"neptune.UploadInput.deleteModalBody": "La eliminación de este archivo lo borrará de nuestro sistema.",
|
package/src/i18n/fr.json
CHANGED
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"neptune.SelectInput.noResultsFound": "Aucun résultat trouvé",
|
|
28
28
|
"neptune.SelectOption.action.label": "Sélectionner",
|
|
29
29
|
"neptune.SelectOption.selected.action.label": "Modifier l'option choisie",
|
|
30
|
-
"neptune.StatusIcon.iconLabel.error": "Erreur
|
|
31
|
-
"neptune.StatusIcon.iconLabel.information": "Informations
|
|
30
|
+
"neptune.StatusIcon.iconLabel.error": "Erreur:",
|
|
31
|
+
"neptune.StatusIcon.iconLabel.information": "Informations:",
|
|
32
32
|
"neptune.StatusIcon.iconLabel.pending": "En attente :",
|
|
33
|
-
"neptune.StatusIcon.iconLabel.success": "
|
|
34
|
-
"neptune.StatusIcon.iconLabel.warning": "
|
|
33
|
+
"neptune.StatusIcon.iconLabel.success": "Terminé:",
|
|
34
|
+
"neptune.StatusIcon.iconLabel.warning": "Attention:",
|
|
35
35
|
"neptune.Summary.statusDone": "Validé",
|
|
36
36
|
"neptune.Summary.statusNotDone": "À compléter",
|
|
37
37
|
"neptune.Summary.statusPending": "En attente",
|
|
@@ -47,14 +47,13 @@
|
|
|
47
47
|
"neptune.Upload.csWrongTypeMessage": "Format non pris en charge. Veuillez réessayer avec un fichier différent",
|
|
48
48
|
"neptune.Upload.psButtonText": "Annuler",
|
|
49
49
|
"neptune.Upload.psProcessingText": "Téléchargement...",
|
|
50
|
-
"neptune.Upload.retry": "
|
|
50
|
+
"neptune.Upload.retry": "Réessayez",
|
|
51
51
|
"neptune.Upload.usButtonText": "Ou sélectionnez un fichier",
|
|
52
52
|
"neptune.Upload.usDropMessage": "Déposer un fichier pour démarrer le téléchargement",
|
|
53
53
|
"neptune.Upload.usPlaceholder": "Glissez-déposez un fichier de moins de {maxSize} Mo",
|
|
54
54
|
"neptune.UploadButton.allFileTypes": "Tous types de fichiers",
|
|
55
55
|
"neptune.UploadButton.dropFiles": "Déposer un fichier pour démarrer le téléchargement",
|
|
56
56
|
"neptune.UploadButton.instructions": "{fileTypes}, inférieur à {size} Mo",
|
|
57
|
-
"neptune.UploadButton.maximumFiles": "Max. {maxFiles} fichiers",
|
|
58
57
|
"neptune.UploadButton.uploadFile": "Envoyer le fichier",
|
|
59
58
|
"neptune.UploadButton.uploadFiles": "Transférer des documents",
|
|
60
59
|
"neptune.UploadInput.deleteModalBody": "La suppression de ce fichier sera définitive sur notre système.",
|
package/src/i18n/hu.json
CHANGED
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"neptune.UploadButton.allFileTypes": "Összes fájltípus",
|
|
55
55
|
"neptune.UploadButton.dropFiles": "Húzd a fájlokat ide a feltöltéshez",
|
|
56
56
|
"neptune.UploadButton.instructions": "{fileTypes}, legfeljebb {size}MB",
|
|
57
|
-
"neptune.UploadButton.maximumFiles": "Maximum {maxFiles} fájl.",
|
|
58
57
|
"neptune.UploadButton.uploadFile": "Fájl feltöltése",
|
|
59
58
|
"neptune.UploadButton.uploadFiles": "Fájlok feltöltése",
|
|
60
59
|
"neptune.UploadInput.deleteModalBody": "Ha törlöd ezt a fájlt, azzal a rendszerünkből is eltávolítod.",
|
package/src/i18n/id.json
CHANGED
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"neptune.UploadButton.allFileTypes": "Semua jenis file",
|
|
55
55
|
"neptune.UploadButton.dropFiles": "Lepaskan file untuk mulai mengunggah",
|
|
56
56
|
"neptune.UploadButton.instructions": "{fileTypes}, kurang dari {size}MB",
|
|
57
|
-
"neptune.UploadButton.maximumFiles": "Maksimal {maxFiles} file.",
|
|
58
57
|
"neptune.UploadButton.uploadFile": "Unggah file",
|
|
59
58
|
"neptune.UploadButton.uploadFiles": "Unggah file",
|
|
60
59
|
"neptune.UploadInput.deleteModalBody": "Menghapus file ini akan menghilangkannya dari sistem kami.",
|
package/src/i18n/ro.json
CHANGED
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"neptune.UploadButton.allFileTypes": "Toate tipurile de fișiere",
|
|
55
55
|
"neptune.UploadButton.dropFiles": "Trage fișierul pentru a începe încărcarea",
|
|
56
56
|
"neptune.UploadButton.instructions": "{fileTypes}, de maximum {size}MB",
|
|
57
|
-
"neptune.UploadButton.maximumFiles": "Maximum {maxFiles} fișiere.",
|
|
58
57
|
"neptune.UploadButton.uploadFile": "Încarcă fișier",
|
|
59
58
|
"neptune.UploadButton.uploadFiles": "Încarcă fișiere",
|
|
60
59
|
"neptune.UploadInput.deleteModalBody": "Eliminarea acestui fișier îl va șterge din sistemul nostru.",
|
|
@@ -2,77 +2,72 @@
|
|
|
2
2
|
border: none;
|
|
3
3
|
}
|
|
4
4
|
.np-icon-button-tertiary-default {
|
|
5
|
-
color: var(--color-interactive-primary);
|
|
6
|
-
background
|
|
7
|
-
background-color: var(--color-background-neutral);
|
|
5
|
+
--Button-color: var(--color-interactive-primary);
|
|
6
|
+
--Button-background: var(--color-background-neutral);
|
|
8
7
|
}
|
|
9
8
|
.np-icon-button-tertiary-default:not(.disabled):not(:disabled):hover {
|
|
10
|
-
background-
|
|
9
|
+
--Button-background-hover: var(--color-background-neutral-hover);
|
|
11
10
|
}
|
|
12
11
|
.np-icon-button-tertiary-default:not(.disabled):not(:disabled):active {
|
|
13
|
-
background-
|
|
12
|
+
--Button-background-active: var(--color-background-neutral-active);
|
|
14
13
|
}
|
|
15
14
|
.np-icon-button-primary-default {
|
|
16
|
-
color: var(--color-interactive-control);
|
|
17
|
-
background
|
|
18
|
-
background-color: var(--color-interactive-accent);
|
|
15
|
+
--Button-color: var(--color-interactive-control);
|
|
16
|
+
--Button-background: var(--color-interactive-accent);
|
|
19
17
|
}
|
|
20
18
|
.np-icon-button-primary-default:not(.disabled):not(:disabled):hover {
|
|
21
|
-
background-
|
|
22
|
-
background-color: var(--color-interactive-accent-hover);
|
|
19
|
+
--Button-background-hover: var(--color-interactive-accent-hover);
|
|
23
20
|
}
|
|
24
21
|
.np-icon-button-primary-default:not(.disabled):not(:disabled):active {
|
|
25
|
-
background-
|
|
26
|
-
background-color: var(--color-interactive-accent-active);
|
|
22
|
+
--Button-background-active: var(--color-interactive-accent-active);
|
|
27
23
|
}
|
|
28
24
|
.np-icon-button-primary-negative {
|
|
29
|
-
color: var(--color-contrast-overlay);
|
|
30
|
-
background
|
|
25
|
+
--Button-color: var(--color-contrast-overlay);
|
|
26
|
+
--Button-background: var(--color-sentiment-negative-primary);
|
|
31
27
|
}
|
|
32
28
|
.np-icon-button-primary-negative:not(.disabled):not(:disabled):hover {
|
|
33
|
-
background-
|
|
29
|
+
--Button-background-hover: var(--color-sentiment-negative-primary-hover);
|
|
34
30
|
}
|
|
35
31
|
.np-icon-button-primary-negative:not(.disabled):not(:disabled):active {
|
|
36
|
-
background-
|
|
32
|
+
--Button-background-active: var(--color-sentiment-negative-primary-active);
|
|
37
33
|
}
|
|
38
34
|
.np-theme-personal--bright-green .np-icon-button-primary-negative {
|
|
39
35
|
color: var(--color-white);
|
|
40
36
|
}
|
|
41
37
|
.np-icon-button-minimal-default {
|
|
42
|
-
color: var(--color-interactive-primary);
|
|
43
|
-
background
|
|
44
|
-
background-color: var(--color-background-screen);
|
|
38
|
+
--Button-color: var(--color-interactive-primary);
|
|
39
|
+
--Button-background: var(--color-background-screen);
|
|
45
40
|
background-color: transparent;
|
|
46
41
|
}
|
|
47
42
|
.np-icon-button-minimal-default:not(.disabled):not(:disabled):hover {
|
|
48
|
-
background-
|
|
43
|
+
--Button-background-hover: var(--color-background-screen-hover);
|
|
49
44
|
}
|
|
50
45
|
.np-icon-button-minimal-default:not(.disabled):not(:disabled):active {
|
|
51
|
-
background-
|
|
46
|
+
--Button-background-active: var(--color-background-screen-active);
|
|
52
47
|
}
|
|
53
48
|
.np-icon-button-secondary-default {
|
|
54
|
-
color: var(--color-interactive-primary);
|
|
55
|
-
background
|
|
49
|
+
--Button-color: var(--color-interactive-primary);
|
|
50
|
+
--Button-background: var(--color-interactive-neutral);
|
|
56
51
|
}
|
|
57
52
|
.np-icon-button-secondary-default:not(.disabled):not(:disabled):hover {
|
|
58
|
-
background-
|
|
53
|
+
--Button-background-hover: var(--color-interactive-neutral-hover);
|
|
59
54
|
}
|
|
60
55
|
.np-icon-button-secondary-default:not(.disabled):not(:disabled):active {
|
|
61
|
-
background-
|
|
56
|
+
--Button-background-active: var(--color-interactive-neutral-active);
|
|
62
57
|
}
|
|
63
58
|
.np-theme-personal--bright-green .np-icon-button-secondary-default,
|
|
64
59
|
.np-theme-personal--forest-green .np-icon-button-secondary-default {
|
|
65
60
|
color: var(--color-interactive-control);
|
|
66
61
|
}
|
|
67
62
|
.np-icon-button-secondary-negative {
|
|
68
|
-
color: var(--color-sentiment-negative-primary);
|
|
69
|
-
background
|
|
63
|
+
--Button-color: var(--color-sentiment-negative-primary);
|
|
64
|
+
--Button-background: var(--color-sentiment-negative-secondary);
|
|
70
65
|
}
|
|
71
66
|
.np-icon-button-secondary-negative:not(.disabled):not(:disabled):hover {
|
|
72
|
-
background-
|
|
67
|
+
--Button-background-hover: var(--color-sentiment-negative-secondary-hover);
|
|
73
68
|
}
|
|
74
69
|
.np-icon-button-secondary-negative:not(.disabled):not(:disabled):active {
|
|
75
|
-
background-
|
|
70
|
+
--Button-background-active: var(--color-sentiment-negative-secondary-active);
|
|
76
71
|
}
|
|
77
72
|
.np-theme-personal--bright-green .np-icon-button-secondary-negative {
|
|
78
73
|
color: var(--color-white);
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
.colors(@icon-color, @bg-color) {
|
|
45
|
-
color: var(@icon-color);
|
|
46
|
-
background
|
|
45
|
+
--Button-color: var(@icon-color);
|
|
46
|
+
--Button-background: var(@bg-color);
|
|
47
47
|
|
|
48
48
|
&:not(.disabled, :disabled):hover {
|
|
49
|
-
background-
|
|
49
|
+
--Button-background-hover:~"var(@{bg-color}-hover)";
|
|
50
50
|
}
|
|
51
51
|
&:not(.disabled, :disabled):active {
|
|
52
|
-
background-
|
|
52
|
+
--Button-background-active:~"var(@{bg-color}-active)";
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|