@hyphen/hyphen-components 7.8.1 → 7.9.0
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/dist/css/index.css +26 -1
- package/dist/css/utilities.css +37 -1
- package/dist/css/variables.css +9 -0
- package/dist/hyphen-components.cjs.development.js +1 -1
- package/dist/hyphen-components.cjs.development.js.map +1 -1
- package/dist/hyphen-components.cjs.production.min.js +1 -1
- package/dist/hyphen-components.cjs.production.min.js.map +1 -1
- package/dist/hyphen-components.esm.js +1 -1
- package/dist/hyphen-components.esm.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/Button/Button.constants.ts +1 -0
- package/src/components/Button/Button.module.scss +32 -1
- package/src/components/Button/Button.stories.tsx +1 -0
- package/src/components/Button/Button.test.tsx +12 -8
- package/src/components/Button/Button.tsx +1 -0
package/dist/index.d.ts
CHANGED
|
@@ -427,7 +427,7 @@ interface BadgeProps extends BoxProps {
|
|
|
427
427
|
}
|
|
428
428
|
declare const Badge: React__default.ForwardRefExoticComponent<Omit<BadgeProps, "ref"> & React__default.RefAttributes<HTMLDivElement>>;
|
|
429
429
|
|
|
430
|
-
type ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'danger' | 'link';
|
|
430
|
+
type ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'danger' | 'success' | 'link';
|
|
431
431
|
type ButtonSize = 'sm' | 'md' | 'lg';
|
|
432
432
|
interface BaseButtonProps {
|
|
433
433
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyphen/hyphen-components",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.9.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "@hyphen"
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"react-select": "^5.10.0",
|
|
57
57
|
"react-select-event": "^5.5.1",
|
|
58
58
|
"uuid": "^11.1.1",
|
|
59
|
-
"@hyphen/hyphen-design-tokens": "^7.
|
|
59
|
+
"@hyphen/hyphen-design-tokens": "^7.9.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@babel/core": "^7.27.4",
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
:root {
|
|
4
4
|
--button-box-shadow-focus: 0 0 0 4px var(--color-base-grey-300);
|
|
5
5
|
--button-neutral-box-shadow-focus: 0 0 0 4px var(--color-base-grey-200);
|
|
6
|
-
--button-danger-box-shadow-focus: 0 0 0 4px var(--color-base-
|
|
6
|
+
--button-danger-box-shadow-focus: 0 0 0 4px var(--color-base-red-200);
|
|
7
|
+
--button-success-box-shadow-focus: 0 0 0 4px var(--color-base-green-200);
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
@mixin size-sm {
|
|
@@ -245,6 +246,36 @@
|
|
|
245
246
|
}
|
|
246
247
|
}
|
|
247
248
|
|
|
249
|
+
&.success {
|
|
250
|
+
background-color: var(--color-background-button-success);
|
|
251
|
+
color: var(--color-font-button-success);
|
|
252
|
+
|
|
253
|
+
&:not(:disabled):hover {
|
|
254
|
+
background-color: var(--color-background-button-success-hover);
|
|
255
|
+
color: var(--color-font-button-success-hover);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
&:not(:disabled):active {
|
|
259
|
+
background-color: var(--color-background-button-success-active);
|
|
260
|
+
color: var(--color-font-button-success-active);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
&:focus {
|
|
264
|
+
outline: 0;
|
|
265
|
+
box-shadow: var(--button-success-box-shadow-focus);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
&:focus-visible {
|
|
269
|
+
outline: 0;
|
|
270
|
+
box-shadow: var(--button-success-box-shadow-focus);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
&:focus:not(:focus-visible) {
|
|
274
|
+
outline: 0;
|
|
275
|
+
box-shadow: none;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
248
279
|
&.link {
|
|
249
280
|
display: inline-flex;
|
|
250
281
|
background-color: transparent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { BUTTON_SIZES, BUTTON_VARIANTS } from './Button.constants';
|
|
3
|
-
import { Button
|
|
3
|
+
import { Button } from './Button';
|
|
4
4
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
5
5
|
|
|
6
6
|
const renderButton = (props = {}) => render(<Button {...props} />);
|
|
@@ -306,6 +306,16 @@ describe('Button', () => {
|
|
|
306
306
|
const spinnerElement = document.getElementsByClassName('spinner')[0];
|
|
307
307
|
expect(spinnerElement).toBeInTheDocument();
|
|
308
308
|
});
|
|
309
|
+
|
|
310
|
+
test('renders the spinning indicator when button is success', () => {
|
|
311
|
+
renderButton({
|
|
312
|
+
isLoading: true,
|
|
313
|
+
variant: 'success',
|
|
314
|
+
children: 'Button is loading',
|
|
315
|
+
});
|
|
316
|
+
const spinnerElement = document.getElementsByClassName('spinner')[0];
|
|
317
|
+
expect(spinnerElement).toBeInTheDocument();
|
|
318
|
+
});
|
|
309
319
|
});
|
|
310
320
|
|
|
311
321
|
describe('Disabled and Loading', () => {
|
|
@@ -325,13 +335,7 @@ describe('Button', () => {
|
|
|
325
335
|
expect(getButton('primary')).toHaveClass('primary');
|
|
326
336
|
});
|
|
327
337
|
|
|
328
|
-
|
|
329
|
-
'primary',
|
|
330
|
-
'secondary',
|
|
331
|
-
'tertiary',
|
|
332
|
-
'danger',
|
|
333
|
-
];
|
|
334
|
-
variants.forEach((variant) => {
|
|
338
|
+
BUTTON_VARIANTS.forEach((variant) => {
|
|
335
339
|
test(`renders component with variant: ${variant} when passed`, () => {
|
|
336
340
|
renderButton({ variant, children: variant });
|
|
337
341
|
expect(getButton(variant)).toHaveClass(variant);
|