@coopdigital/react 0.6.2 → 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.
- package/dist/components/Button/Button.d.ts +4 -2
- package/dist/components/Button/Button.js +17 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/node_modules/tslib/tslib.es6.js +35 -0
- package/package.json +3 -3
- package/src/components/Button/Button.tsx +7 -3
- package/src/index.ts +1 -0
|
@@ -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;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { __rest } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The Button component is an interactive element that people can use to take an action.
|
|
6
|
+
*/
|
|
7
|
+
const Button = (_a) => {
|
|
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
|
+
let element = href ? "a" : "button";
|
|
10
|
+
if (as) {
|
|
11
|
+
element = as;
|
|
12
|
+
}
|
|
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
|
+
return React.createElement(element, Object.assign({}, componentProps), children);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { Button, Button as default };
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { AlertBanner } from './components/AlertBanner/AlertBanner.js';
|
|
2
|
+
export { Button } from './components/Button/Button.js';
|
|
2
3
|
export { EditorialCard } from './components/EditorialCard/EditorialCard.js';
|
|
3
4
|
export { Image } from './components/Image/Image.js';
|
|
4
5
|
export { Pill } from './components/Pill/Pill.js';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */
|
|
15
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function __rest(s, e) {
|
|
19
|
+
var t = {};
|
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
21
|
+
t[p] = s[p];
|
|
22
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
23
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
24
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
25
|
+
t[p[i]] = s[p[i]];
|
|
26
|
+
}
|
|
27
|
+
return t;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
31
|
+
var e = new Error(message);
|
|
32
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { __rest };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coopdigital/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "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.
|
|
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": "
|
|
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:
|
|
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,
|