@hyphen/hyphen-components 7.8.1 → 7.10.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/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.8.1",
3
+ "version": "7.10.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.8.1"
59
+ "@hyphen/hyphen-design-tokens": "^7.10.0"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@babel/core": "^7.27.4",
@@ -5,6 +5,7 @@ export const BUTTON_VARIANTS: ButtonVariant[] = [
5
5
  'secondary',
6
6
  'tertiary',
7
7
  'danger',
8
+ 'success',
8
9
  ];
9
10
 
10
11
  export const BUTTON_SIZES: ButtonSize[] = ['sm', 'md', 'lg'];
@@ -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-danger-200);
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;
@@ -11,6 +11,7 @@ const BUTTON_VARIANTS: ButtonVariant[] = [
11
11
  'secondary',
12
12
  'tertiary',
13
13
  'danger',
14
+ 'success',
14
15
  'link',
15
16
  ];
16
17
  const BUTTON_SIZES: ButtonSize[] = ['sm', 'md', 'lg'];
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { BUTTON_SIZES, BUTTON_VARIANTS } from './Button.constants';
3
- import { Button, ButtonVariant } from './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
- const variants: ButtonVariant[] = [
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);
@@ -13,6 +13,7 @@ export type ButtonVariant =
13
13
  | 'secondary'
14
14
  | 'tertiary'
15
15
  | 'danger'
16
+ | 'success'
16
17
  | 'link';
17
18
 
18
19
  export type ButtonSize = 'sm' | 'md' | 'lg';