@coopdigital/react 0.7.0 → 0.8.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.
@@ -10,6 +10,8 @@ export interface ButtonProps extends DetailedHTMLProps<ButtonHTMLAttributes<HTML
10
10
  className?: string;
11
11
  /** **(Optional)** Specifies the URL that the Button component will link to when clicked. */
12
12
  href?: string;
13
+ /** **(Optional)** Specifies whether the Button should look like disabled. Note that isDisabled will not actually disable the button, just make it look disabled. Disabled buttons can be bad UX. */
14
+ isDisabled?: boolean;
13
15
  /** **(Optional)** Specifies whether the Button should be full width. */
14
16
  isFullWidth?: boolean;
15
17
  /** **(Optional)** Specifies whether the Button is loading. */
@@ -17,10 +19,10 @@ export interface ButtonProps extends DetailedHTMLProps<ButtonHTMLAttributes<HTML
17
19
  /** **(Optional)** Specifies the Button size. */
18
20
  size?: "sm" | "md" | "lg" | "xl";
19
21
  /** **(Optional)** Specifies the Button variant. */
20
- variant?: "primary" | "secondary" | "white" | "grey";
22
+ variant?: "primary" | "secondary" | "white" | "grey" | "text";
21
23
  }
22
24
  /**
23
25
  * The Button component is an interactive element that people can use to take an action.
24
26
  */
25
- export declare const Button: ({ ariaLabel, as, children, className, href, isFullWidth, isLoading, size, variant, ...props }: ButtonProps) => JSX.Element;
27
+ export declare const Button: ({ ariaLabel, as, children, className, href, isDisabled, isFullWidth, isLoading, size, variant, ...props }: ButtonProps) => JSX.Element;
26
28
  export default Button;
@@ -5,12 +5,12 @@ import React from 'react';
5
5
  * The Button component is an interactive element that people can use to take an action.
6
6
  */
7
7
  const Button = (_a) => {
8
- var { ariaLabel, as, children, className = "", href, isFullWidth = false, isLoading = false, size = "md", variant = "primary" } = _a, props = __rest(_a, ["ariaLabel", "as", "children", "className", "href", "isFullWidth", "isLoading", "size", "variant"]);
8
+ var { ariaLabel, as, children, className = "", href, isDisabled = false, isFullWidth = false, isLoading = false, size = "md", variant = "primary" } = _a, props = __rest(_a, ["ariaLabel", "as", "children", "className", "href", "isDisabled", "isFullWidth", "isLoading", "size", "variant"]);
9
9
  let element = href ? "a" : "button";
10
10
  if (as) {
11
11
  element = as;
12
12
  }
13
- const componentProps = Object.assign({ "aria-label": ariaLabel, className: `coop-button ${className}`, "data-loading": isLoading ? true : undefined, "data-size": size.length && size != "md" ? size : undefined, "data-variant": variant, "data-width": isFullWidth ? "full" : undefined, href }, props);
13
+ const componentProps = Object.assign({ "aria-disabled": isDisabled ? true : undefined, "aria-label": ariaLabel, className: `${variant == "text" ? "coop-link" : "coop-button"} ${isDisabled ? "grayscale" : ""} ${className}`, "data-loading": isLoading ? true : undefined, "data-size": size.length && size != "md" ? size : undefined, "data-variant": variant !== "text" ? variant : undefined, "data-width": isFullWidth ? "full" : undefined, href }, props);
14
14
  return React.createElement(element, Object.assign({}, componentProps), children);
15
15
  };
16
16
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coopdigital/react",
3
3
  "type": "module",
4
- "version": "0.7.0",
4
+ "version": "0.8.0",
5
5
  "main": "dist/index.js",
6
6
  "private": false,
7
7
  "publishConfig": {
@@ -39,7 +39,7 @@
39
39
  "description": "",
40
40
  "devDependencies": {
41
41
  "@axe-core/playwright": "^4.10.1",
42
- "@coopdigital/styles": "^0.6.1",
42
+ "@coopdigital/styles": "^0.7.0",
43
43
  "@playwright/test": "^1.51.1",
44
44
  "@rollup/plugin-node-resolve": "^16.0.1",
45
45
  "@rollup/plugin-typescript": "^12.1.2",
@@ -65,5 +65,5 @@
65
65
  "react": "^19.0.0",
66
66
  "react-dom": "^19.0.0"
67
67
  },
68
- "gitHead": "72f25fbdb8f540969522cfab1f28a38945fb4531"
68
+ "gitHead": "0005324d74508d5df4479b54d79068555137e391"
69
69
  }
@@ -19,6 +19,8 @@ export interface ButtonProps
19
19
  className?: string
20
20
  /** **(Optional)** Specifies the URL that the Button component will link to when clicked. */
21
21
  href?: string
22
+ /** **(Optional)** Specifies whether the Button should look like disabled. Note that isDisabled will not actually disable the button, just make it look disabled. Disabled buttons can be bad UX. */
23
+ isDisabled?: boolean
22
24
  /** **(Optional)** Specifies whether the Button should be full width. */
23
25
  isFullWidth?: boolean
24
26
  /** **(Optional)** Specifies whether the Button is loading. */
@@ -26,7 +28,7 @@ export interface ButtonProps
26
28
  /** **(Optional)** Specifies the Button size. */
27
29
  size?: "sm" | "md" | "lg" | "xl"
28
30
  /** **(Optional)** Specifies the Button variant. */
29
- variant?: "primary" | "secondary" | "white" | "grey"
31
+ variant?: "primary" | "secondary" | "white" | "grey" | "text"
30
32
  }
31
33
 
32
34
  /**
@@ -38,6 +40,7 @@ export const Button = ({
38
40
  children,
39
41
  className = "",
40
42
  href,
43
+ isDisabled = false,
41
44
  isFullWidth = false,
42
45
  isLoading = false,
43
46
  size = "md",
@@ -50,11 +53,12 @@ export const Button = ({
50
53
  }
51
54
 
52
55
  const componentProps = {
56
+ "aria-disabled": isDisabled ? true : undefined,
53
57
  "aria-label": ariaLabel,
54
- className: `coop-button ${className}`,
58
+ className: `${variant == "text" ? "coop-link" : "coop-button"} ${isDisabled ? "grayscale" : ""} ${className}`,
55
59
  "data-loading": isLoading ? true : undefined,
56
60
  "data-size": size.length && size != "md" ? size : undefined,
57
- "data-variant": variant,
61
+ "data-variant": variant !== "text" ? variant : undefined,
58
62
  "data-width": isFullWidth ? "full" : undefined,
59
63
  href,
60
64
  ...props,