@coopdigital/react 0.18.1 → 0.19.1
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 +1 -1
- package/dist/components/Button/Button.js +2 -4
- package/dist/components/Card/Card.d.ts +3 -2
- package/dist/components/Card/Card.js +4 -2
- package/dist/components/Expandable/Expandable.d.ts +2 -1
- package/dist/components/Expandable/Expandable.js +5 -3
- package/dist/components/Icon/LoadingIcon.d.ts +6 -0
- package/dist/components/Icon/LoadingIcon.js +12 -0
- package/dist/components/Icon/index.d.ts +1 -0
- package/dist/components/Pill/Pill.d.ts +5 -4
- package/dist/components/Pill/Pill.js +7 -3
- package/dist/components/SearchBox/SearchBox.d.ts +1 -1
- package/dist/components/SearchBox/SearchBox.js +2 -2
- package/dist/components/Squircle/Squircle.d.ts +17 -0
- package/dist/components/Squircle/Squircle.js +14 -0
- package/dist/components/Squircle/index.d.ts +4 -0
- package/dist/components/Tag/Tag.d.ts +4 -3
- package/dist/components/Tag/Tag.js +4 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/node_modules/clsx/dist/clsx.js +3 -0
- package/dist/types/colors.d.ts +11 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +3 -0
- package/package.json +6 -3
- package/src/components/Button/Button.tsx +13 -18
- package/src/components/Card/Card.tsx +16 -6
- package/src/components/Expandable/Expandable.tsx +9 -16
- package/src/components/Icon/LoadingIcon.tsx +27 -0
- package/src/components/Icon/index.tsx +1 -0
- package/src/components/Pill/Pill.tsx +20 -10
- package/src/components/SearchBox/SearchBox.tsx +11 -3
- package/src/components/Squircle/Squircle.tsx +41 -0
- package/src/components/Squircle/index.ts +5 -0
- package/src/components/Tag/Tag.tsx +9 -15
- package/src/index.ts +1 -0
- package/src/types/colors.ts +41 -0
- package/src/types/react.d.ts +8 -0
- package/src/utils/index.ts +2 -0
|
@@ -22,7 +22,7 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
22
22
|
/** **(Optional)** Specifies the Button size. */
|
|
23
23
|
size?: "sm" | "md" | "lg" | "xl";
|
|
24
24
|
/** **(Optional)** Specifies the Button variant. */
|
|
25
|
-
variant?: "
|
|
25
|
+
variant?: "green" | "blue" | "white" | "grey" | "green-ghost" | "blue-ghost" | "white-ghost" | "grey-ghost" | "text";
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* The Button component is an interactive element that people can use to take an action.
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { __rest, __awaiter } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
2
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import React, { useState, useCallback } from 'react';
|
|
4
|
+
import { LoadingIcon } from '../Icon/LoadingIcon.js';
|
|
4
5
|
|
|
5
|
-
const LoadingIcon = () => {
|
|
6
|
-
return (jsx("svg", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" }) }));
|
|
7
|
-
};
|
|
8
6
|
/**
|
|
9
7
|
* The Button component is an interactive element that people can use to take an action.
|
|
10
8
|
*/
|
|
11
9
|
const Button = (_a) => {
|
|
12
|
-
var { as, children, className = "", href, isDisabled = false, isFullWidth = false, isLoading = false, loadingText = "Loading", onClick, size = "md", variant = "
|
|
10
|
+
var { as, children, className = "", href, isDisabled = false, isFullWidth = false, isLoading = false, loadingText = "Loading", onClick, size = "md", variant = "green" } = _a, props = __rest(_a, ["as", "children", "className", "href", "isDisabled", "isFullWidth", "isLoading", "loadingText", "onClick", "size", "variant"]);
|
|
13
11
|
let element = href ? "a" : "button";
|
|
14
12
|
if (as) {
|
|
15
13
|
element = as;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { AnchorHTMLAttributes, ForwardRefExoticComponent, HTMLAttributes, JSX } from "react";
|
|
2
2
|
import React from "react";
|
|
3
|
+
import { Lights, Tints } from "../../types/colors";
|
|
3
4
|
import { ImageProps } from "../Image";
|
|
4
5
|
export interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
6
|
/** **(Optional)** Specifies the custom element to override default `a` */
|
|
6
7
|
as?: React.FC<AnchorHTMLAttributes<HTMLElement>> | ForwardRefExoticComponent<any> | string;
|
|
7
8
|
/** **(Optional)** Specifies the background color of the card. */
|
|
8
|
-
background?:
|
|
9
|
+
background?: Tints;
|
|
9
10
|
/** **(Optional)** Represents the content inside the badge. */
|
|
10
11
|
badge?: React.ReactNode;
|
|
11
12
|
/** **(Optional)** Specify badge position relative to top right corner. */
|
|
@@ -29,7 +30,7 @@ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
29
30
|
/** **(Optional)** Specifies the label of the Card */
|
|
30
31
|
label?: string;
|
|
31
32
|
/** **(Optional)** Specifies the label background of the Card */
|
|
32
|
-
labelBackground?:
|
|
33
|
+
labelBackground?: Lights;
|
|
33
34
|
/** **(Optional)** Specifies the layout of the Card */
|
|
34
35
|
layout?: "vertical" | "horizontal";
|
|
35
36
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { __rest } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { clsx } from '../../node_modules/clsx/dist/clsx.js';
|
|
3
4
|
import React from 'react';
|
|
5
|
+
import { bgPropToClass } from '../../utils/index.js';
|
|
4
6
|
import { Image } from '../Image/Image.js';
|
|
5
7
|
|
|
6
8
|
function getCardLinkElement(as, href) {
|
|
@@ -23,8 +25,8 @@ const Card = (_a) => {
|
|
|
23
25
|
var { as, background, badge, badgePosition = "inset", chevron = false, children, className = "", heading, headingLevel = "h3", href, image, imagePosition = "left", label = "", labelBackground, layout = "vertical" } = _a, props = __rest(_a, ["as", "background", "badge", "badgePosition", "chevron", "children", "className", "heading", "headingLevel", "href", "image", "imagePosition", "label", "labelBackground", "layout"]);
|
|
24
26
|
const linkElement = getCardLinkElement(as, href);
|
|
25
27
|
const imageProps = Object.assign({ crop: "wide" }, image);
|
|
26
|
-
const componentProps = Object.assign({ className:
|
|
27
|
-
return (jsxs("article", Object.assign({}, componentProps, { children: [image && jsx(Image, Object.assign({}, imageProps)), badge && jsx("div", { className: "coop-card--badge", children: badge }), jsxs("div", { className: "coop-card--inner", children: [jsxs("div", { className: "coop-card--content", children: [label && jsx("span", { className: "coop-card--label", children: label }), React.createElement(linkElement.element, linkElement.props, React.createElement(headingLevel, { className: "coop-card--heading" }, heading)), children] }), chevron && (jsx("span", { "aria-hidden": "true", className: "coop-card--icon", role: "presentation", children: jsx("svg", { viewBox: "0 0 16 29", children: jsx("path", { d: "M2 28.1a1.6 1.6 0 0 1-1.2-2.7l11-10.9-11-11A1.6 1.6 0 1 1 3 1.5l12 12a1.6 1.6 0 0 1 0 2.2l-12 12c-.3.4-.7.5-1 .5z" }) }) }))] })] })));
|
|
28
|
+
const componentProps = Object.assign({ className: clsx("coop-card", background && bgPropToClass(background, className), className), "data-badge-pos": badgePosition, "data-image-pos": imagePosition, "data-layout": layout !== "vertical" ? layout : undefined }, props);
|
|
29
|
+
return (jsxs("article", Object.assign({}, componentProps, { children: [image && jsx(Image, Object.assign({}, imageProps)), badge && jsx("div", { className: "coop-card--badge", children: badge }), jsxs("div", { className: "coop-card--inner", children: [jsxs("div", { className: "coop-card--content", children: [label && (jsx("span", { className: clsx("coop-card--label", labelBackground && bgPropToClass(labelBackground, className)), children: label })), React.createElement(linkElement.element, linkElement.props, React.createElement(headingLevel, { className: "coop-card--heading" }, heading)), children] }), chevron && (jsx("span", { "aria-hidden": "true", className: "coop-card--icon", role: "presentation", children: jsx("svg", { viewBox: "0 0 16 29", children: jsx("path", { d: "M2 28.1a1.6 1.6 0 0 1-1.2-2.7l11-10.9-11-11A1.6 1.6 0 1 1 3 1.5l12 12a1.6 1.6 0 0 1 0 2.2l-12 12c-.3.4-.7.5-1 .5z" }) }) }))] })] })));
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
export { Card, Card as default };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { DetailsHTMLAttributes, JSX } from "react";
|
|
2
|
+
import { None, Tints, White } from "../../types/colors";
|
|
2
3
|
export interface ExpandableProps extends DetailsHTMLAttributes<HTMLDetailsElement> {
|
|
3
4
|
/** **(Optional)** Specifies the Expandable background color from the available options. */
|
|
4
|
-
background?:
|
|
5
|
+
background?: Tints | White | None;
|
|
5
6
|
/** Represents the content inside the Expandable component, only visible when expanded. It can be any valid JSX or string. */
|
|
6
7
|
children: React.ReactNode;
|
|
7
8
|
/** **(Optional)** Receives any className to be applied to Expandable component. */
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { __rest } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { clsx } from '../../node_modules/clsx/dist/clsx.js';
|
|
4
|
+
import { bgPropToClass } from '../../utils/index.js';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* The Expandable component wraps content in an expandable block using the details/summary HTML elements.
|
|
6
8
|
* It can be used to reveal more context for a specific issue or action.
|
|
7
9
|
*/
|
|
8
10
|
const Expandable = (_a) => {
|
|
9
|
-
var { background = "grey", children, className = "", summary } = _a, props = __rest(_a, ["background", "children", "className", "summary"]);
|
|
10
|
-
const componentProps = Object.assign({ className:
|
|
11
|
-
return (jsxs("details", Object.assign({}, componentProps, { children: [jsxs("summary", { children: [summary, jsx("svg", { fill: "none", height: "24", width: "24", xmlns: "http://www.w3.org/2000/svg", children: jsx("path", { d: "m20.25 9.75-6.22 6.22a.75.75 0 0 1-1.06 0L6.75 9.75", stroke: "black", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "1.5" }) })] }), jsx("div", { className: "coop-expandable--content", children: children })] })));
|
|
11
|
+
var { background = "tint-grey", children, className = "", summary } = _a, props = __rest(_a, ["background", "children", "className", "summary"]);
|
|
12
|
+
const componentProps = Object.assign({ className: clsx("coop-expandable", bgPropToClass(background, className), className) }, props);
|
|
13
|
+
return (jsxs("details", Object.assign({}, componentProps, { style: { "--background-color": `var(--color-${background})` }, children: [jsxs("summary", { children: [summary, jsx("svg", { fill: "none", height: "24", width: "24", xmlns: "http://www.w3.org/2000/svg", children: jsx("path", { d: "m20.25 9.75-6.22 6.22a.75.75 0 0 1-1.06 0L6.75 9.75", stroke: "black", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "1.5" }) })] }), jsx("div", { className: "coop-expandable--content", children: children })] })));
|
|
12
14
|
};
|
|
13
15
|
|
|
14
16
|
export { Expandable, Expandable as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { __rest } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useId } from 'react';
|
|
4
|
+
|
|
5
|
+
const LoadingIcon = (_a) => {
|
|
6
|
+
var { alt, className } = _a, props = __rest(_a, ["alt", "className"]);
|
|
7
|
+
const id = useId();
|
|
8
|
+
const componentProps = Object.assign({ "aria-labelledby": alt ? id : undefined, className: `coop-icon ${className !== null && className !== void 0 ? className : ""}`.trim(), "data-icon": "loading", fill: "none", role: alt ? "img" : undefined, viewBox: "0 0 24 24" }, props);
|
|
9
|
+
return (jsxs("svg", Object.assign({}, componentProps, { children: [alt ? jsx("title", { id: id, children: alt }) : null, jsx("path", { d: "M10.72 19.9a8 8 0 0 1-6.5-9.79 7.77 7.77 0 0 1 6.18-5.95 8 8 0 0 1 9.49 6.52A1.54 1.54 0 0 0 21.38 12h.13a1.37 1.37 0 0 0 1.38-1.54 11 11 0 1 0-12.7 12.39A1.54 1.54 0 0 0 12 21.34a1.47 1.47 0 0 0-1.28-1.44", fill: "currentColor" })] })));
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { LoadingIcon };
|
|
@@ -20,6 +20,7 @@ export { CoopLocationIcon } from "./CoopLocationIcon";
|
|
|
20
20
|
export { DownloadIcon } from "./DownloadIcon";
|
|
21
21
|
export { HomeIcon } from "./HomeIcon";
|
|
22
22
|
export { InformationIcon } from "./InformationIcon";
|
|
23
|
+
export { LoadingIcon } from "./LoadingIcon";
|
|
23
24
|
export { LocationIcon } from "./LocationIcon";
|
|
24
25
|
export { MailIcon } from "./MailIcon";
|
|
25
26
|
export { MenuIcon } from "./MenuIcon";
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import type { AnchorHTMLAttributes, ForwardRefExoticComponent, HTMLAttributes, JSX } from "react";
|
|
2
2
|
import React from "react";
|
|
3
|
+
import { Darks, OffersRed, Tints } from "../../types/colors";
|
|
3
4
|
export interface PillProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
4
5
|
/** **(Optional)** Specifies the custom element to override default `a` or `span`. */
|
|
5
6
|
as?: React.FC<AnchorHTMLAttributes<HTMLElement>> | ForwardRefExoticComponent<any> | string;
|
|
7
|
+
/** **(Optional)** Specifies the Pill background color from the available options. */
|
|
8
|
+
background?: Tints;
|
|
6
9
|
/** **(Optional)** Specifies what text Pill should display on the badge. */
|
|
7
10
|
badge?: string;
|
|
8
11
|
/** **(Optional)** Specifies the badge background color from the available options. */
|
|
9
|
-
|
|
12
|
+
badgeBackground?: Darks | OffersRed;
|
|
10
13
|
/** **(Optional)** Represents the content inside the Pill component. It can be any valid JSX or string. */
|
|
11
14
|
children?: React.ReactNode;
|
|
12
15
|
/** **(Optional)** Receives any className to be applied to Pill component. */
|
|
13
16
|
className?: string;
|
|
14
17
|
/** **(Optional)** Specifies the URL that the Pill component will link to when clicked. */
|
|
15
18
|
href?: string;
|
|
16
|
-
/** **(Optional)** Specifies the Pill background color from the available options. */
|
|
17
|
-
pillColor?: "blue" | "pink";
|
|
18
19
|
/** **(Optional)** Specifies what should be the Pill size. */
|
|
19
20
|
size?: "sm" | "md" | "lg" | "xl";
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
23
|
* The Pill component is a small, sligtly rounded label used to link and highlight information such as categories or articles. It can be customised with different content and styles to suit various use cases.
|
|
23
24
|
*/
|
|
24
|
-
export declare const Pill: ({ as, badge,
|
|
25
|
+
export declare const Pill: ({ as, background, badge, badgeBackground, children, className, href, size, ...props }: PillProps) => JSX.Element;
|
|
25
26
|
export default Pill;
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { __rest } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { clsx } from '../../node_modules/clsx/dist/clsx.js';
|
|
2
4
|
import React from 'react';
|
|
5
|
+
import { bgPropToClass } from '../../utils/index.js';
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* The Pill component is a small, sligtly rounded label used to link and highlight information such as categories or articles. It can be customised with different content and styles to suit various use cases.
|
|
6
9
|
*/
|
|
7
10
|
const Pill = (_a) => {
|
|
8
|
-
var { as, badge,
|
|
11
|
+
var { as, background = "tint-grey", badge, badgeBackground = "offers-red", children, className = "", href, size = "md" } = _a, props = __rest(_a, ["as", "background", "badge", "badgeBackground", "children", "className", "href", "size"]);
|
|
9
12
|
let element = href ? "a" : "span";
|
|
10
13
|
if (as) {
|
|
11
14
|
element = as;
|
|
12
15
|
}
|
|
13
|
-
const componentProps = Object.assign({ className:
|
|
14
|
-
|
|
16
|
+
const componentProps = Object.assign({ className: clsx("coop-pill", bgPropToClass(background, className), className), "data-size": size.length && size !== "md" ? size : undefined, href }, props);
|
|
17
|
+
const finalChildren = badge ? (jsxs(Fragment, { children: [children, jsx("span", { className: clsx("coop-pill--badge", bgPropToClass(badgeBackground)), children: badge })] })) : (children);
|
|
18
|
+
return React.createElement(element, Object.assign({}, componentProps), finalChildren);
|
|
15
19
|
};
|
|
16
20
|
|
|
17
21
|
export { Pill, Pill as default };
|
|
@@ -25,7 +25,7 @@ export interface SearchBoxProps extends HTMLAttributes<HTMLInputElement> {
|
|
|
25
25
|
/** **(Optional)** Receives any size to be applied to SearchBox component. */
|
|
26
26
|
size?: string;
|
|
27
27
|
/** **(Optional)** Receives the variant to be applied to SearchBox component. */
|
|
28
|
-
variant?: "
|
|
28
|
+
variant?: "green" | "blue" | "white" | "grey" | "green-ghost" | "blue-ghost" | "white-ghost" | "grey-ghost";
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* SearchBox component allows a person to enter a word or a phrase to find relevant content.
|
|
@@ -27,7 +27,7 @@ const defaultButtonProps = {
|
|
|
27
27
|
*/
|
|
28
28
|
const SearchBox = (_a) => {
|
|
29
29
|
var _b, _c;
|
|
30
|
-
var { action, "aria-placeholder": ariaPlaceholder, autoCapitalize = "off", autoComplete = "off", button = defaultButtonProps, className, label, labelVisible = false, name = "query", onSubmit, placeholder, size = "md", variant = "
|
|
30
|
+
var { action, "aria-placeholder": ariaPlaceholder, autoCapitalize = "off", autoComplete = "off", button = defaultButtonProps, className, label, labelVisible = false, name = "query", onSubmit, placeholder, size = "md", variant = "green" } = _a, props = __rest(_a, ["action", "aria-placeholder", "autoCapitalize", "autoComplete", "button", "className", "label", "labelVisible", "name", "onSubmit", "placeholder", "size", "variant"]);
|
|
31
31
|
const [isPending, setIsPending] = useState(false);
|
|
32
32
|
const handleSubmit = useCallback((event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
33
|
event.preventDefault();
|
|
@@ -46,7 +46,7 @@ const SearchBox = (_a) => {
|
|
|
46
46
|
action: action !== null && action !== void 0 ? action : undefined,
|
|
47
47
|
className: `coop-search-box ${className !== null && className !== void 0 ? className : ""}`.trim(),
|
|
48
48
|
"data-size": size.length && size !== "md" ? size : undefined,
|
|
49
|
-
"data-variant": variant.length && variant !== "
|
|
49
|
+
"data-variant": variant.length && variant !== "green" ? variant : undefined,
|
|
50
50
|
onSubmit: onSubmit ? handleSubmit : undefined,
|
|
51
51
|
};
|
|
52
52
|
const buttonProps = {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
import { CoopBlue, Green, OffersRed } from "../../types/colors";
|
|
3
|
+
export interface SquircleProps {
|
|
4
|
+
/** **(Optional)** Specifies the background color of the Squircle. */
|
|
5
|
+
background?: OffersRed | CoopBlue | Green;
|
|
6
|
+
/** **(Optional)** Represents the content inside the Squircle component. It can be any valid JSX or string. */
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/** **(Optional)** Receives any className to be applied to Squircle component. */
|
|
9
|
+
className?: string;
|
|
10
|
+
/** **(Optional)** Specifies what should be the Squircle size */
|
|
11
|
+
size?: "sm" | "md" | "lg";
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Squircle to use on components like Cards, etc.
|
|
15
|
+
*/
|
|
16
|
+
export declare const Squircle: ({ background, children, className, size, ...props }: SquircleProps) => JSX.Element;
|
|
17
|
+
export default Squircle;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { __rest } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { bgPropToClass } from '../../utils/index.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Squircle to use on components like Cards, etc.
|
|
7
|
+
*/
|
|
8
|
+
const Squircle = (_a) => {
|
|
9
|
+
var { background = "offers-red", children, className, size = "lg" } = _a, props = __rest(_a, ["background", "children", "className", "size"]);
|
|
10
|
+
const componentProps = Object.assign({ className: `coop-squircle ${bgPropToClass(background, className)} ${className !== null && className !== void 0 ? className : ""}`, "data-size": size.length && size !== "lg" ? size : undefined }, props);
|
|
11
|
+
return (jsx("figure", Object.assign({}, componentProps, { children: jsx("figcaption", { children: children }) })));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { Squircle, Squircle as default };
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import type { AnchorHTMLAttributes, ForwardRefExoticComponent, HTMLAttributes, JSX } from "react";
|
|
2
2
|
import React from "react";
|
|
3
|
+
import type { Black, Darks, Greys, Lights, Tints, White } from "../../types/colors";
|
|
3
4
|
export interface TagProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
4
5
|
/** **(Optional)** Specifies the custom element to override default `a` or `span`. */
|
|
5
6
|
as?: React.FC<AnchorHTMLAttributes<HTMLElement>> | ForwardRefExoticComponent<any> | string;
|
|
7
|
+
/** **(Optional)** Specifies the Tag background color from the available options. */
|
|
8
|
+
background?: Lights | Darks | Tints | Greys | White | Black;
|
|
6
9
|
/** **(Optional)** Represents the content inside the Tag component. It can be any valid JSX or string. */
|
|
7
10
|
children?: React.ReactNode;
|
|
8
11
|
/** **(Optional)** Receives any className to be applied to Tag component. */
|
|
9
12
|
className?: string;
|
|
10
13
|
/** **(Optional)** Specifies the URL that the Tag component will link to when clicked. */
|
|
11
14
|
href?: string;
|
|
12
|
-
/** **(Optional)** Specifies the Tag background color from the available options. */
|
|
13
|
-
tagColor?: "white" | "grey" | "purple" | "pink" | "green" | "orange" | "red" | "yellow" | "lilac" | "blue";
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
17
|
* Tag is a simple component that is meant to communicate a brief message such as categories.
|
|
@@ -22,5 +23,5 @@ export interface TagProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
|
22
23
|
* - Tag components should be used as tags to communicate brief message while Pill component is more versatile and has more styling options
|
|
23
24
|
*
|
|
24
25
|
*/
|
|
25
|
-
export declare const Tag: ({ as, children, className, href,
|
|
26
|
+
export declare const Tag: ({ as, background, children, className, href, ...props }: TagProps) => JSX.Element;
|
|
26
27
|
export default Tag;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { __rest } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { clsx } from '../../node_modules/clsx/dist/clsx.js';
|
|
2
3
|
import React from 'react';
|
|
4
|
+
import { bgPropToClass } from '../../utils/index.js';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* Tag is a simple component that is meant to communicate a brief message such as categories.
|
|
@@ -12,9 +14,9 @@ import React from 'react';
|
|
|
12
14
|
*
|
|
13
15
|
*/
|
|
14
16
|
const Tag = (_a) => {
|
|
15
|
-
var { as,
|
|
17
|
+
var { as, background = "tint-grey", children, className = "", href } = _a, props = __rest(_a, ["as", "background", "children", "className", "href"]);
|
|
16
18
|
let element = href ? "a" : "span";
|
|
17
|
-
const componentProps = Object.assign({ className:
|
|
19
|
+
const componentProps = Object.assign({ className: clsx("coop-tag", bgPropToClass(background, className), className), href }, props);
|
|
18
20
|
if (as) {
|
|
19
21
|
element = as;
|
|
20
22
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -9,4 +9,5 @@ export { RootSVG } from './components/RootSVG/RootSVG.js';
|
|
|
9
9
|
export { SearchBox } from './components/SearchBox/SearchBox.js';
|
|
10
10
|
export { Signpost } from './components/Signpost/Signpost.js';
|
|
11
11
|
export { SkipNav } from './components/SkipNav/SkipNav.js';
|
|
12
|
+
export { Squircle } from './components/Squircle/Squircle.js';
|
|
12
13
|
export { Tag } from './components/Tag/Tag.js';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
2
|
+
|
|
3
|
+
export { clsx, clsx as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type Darks = "dark-blue" | "dark-yellow" | "dark-green" | "dark-lilac" | "dark-orange" | "dark-pink" | "dark-purple" | "dark-red";
|
|
2
|
+
export type Tints = "tint-blue" | "tint-brown" | "tint-yellow" | "tint-green" | "tint-grey" | "tint-lilac" | "tint-orange" | "tint-pink" | "tint-purple" | "tint-red";
|
|
3
|
+
export type Lights = "light-blue" | "light-yellow" | "light-green" | "light-lilac" | "light-orange" | "light-pink" | "light-purple" | "light-red";
|
|
4
|
+
export type Greys = "dark-grey" | "mid-dark-grey" | "mid-grey" | "mid-light-grey" | "light-grey";
|
|
5
|
+
export type White = "white";
|
|
6
|
+
export type Black = "black";
|
|
7
|
+
export type None = "none";
|
|
8
|
+
export type CoopBlue = "coop-blue";
|
|
9
|
+
export type OffersRed = "offers-red";
|
|
10
|
+
export type Green = "green";
|
|
11
|
+
export type Blue = "blue";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const bgPropToClass: (color: string, userClasses?: string) => string;
|
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.19.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"description": "",
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@axe-core/playwright": "^4.10.1",
|
|
48
|
-
"@coopdigital/styles": "^0.
|
|
48
|
+
"@coopdigital/styles": "^0.16.1",
|
|
49
49
|
"@playwright/test": "^1.52.0",
|
|
50
50
|
"@storybook/addon-a11y": "^8.6.12",
|
|
51
51
|
"@storybook/addon-essentials": "^8.6.12",
|
|
@@ -67,5 +67,8 @@
|
|
|
67
67
|
"react": "^19.1.0",
|
|
68
68
|
"react-dom": "^19.1.0"
|
|
69
69
|
},
|
|
70
|
-
"
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"clsx": "^2.1.1"
|
|
72
|
+
},
|
|
73
|
+
"gitHead": "8c11cfec54452dacb609b1a61075a2dbc1142ad1"
|
|
71
74
|
}
|
|
@@ -7,6 +7,8 @@ import type {
|
|
|
7
7
|
|
|
8
8
|
import React, { useCallback, useState } from "react"
|
|
9
9
|
|
|
10
|
+
import { LoadingIcon } from "../Icon"
|
|
11
|
+
|
|
10
12
|
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
11
13
|
/** **(Optional)** Specifies the custom element to override default `a` or `button`. */
|
|
12
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -30,29 +32,22 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
30
32
|
/** **(Optional)** Specifies the Button size. */
|
|
31
33
|
size?: "sm" | "md" | "lg" | "xl"
|
|
32
34
|
/** **(Optional)** Specifies the Button variant. */
|
|
33
|
-
variant?:
|
|
35
|
+
variant?:
|
|
36
|
+
| "green"
|
|
37
|
+
| "blue"
|
|
38
|
+
| "white"
|
|
39
|
+
| "grey"
|
|
40
|
+
| "green-ghost"
|
|
41
|
+
| "blue-ghost"
|
|
42
|
+
| "white-ghost"
|
|
43
|
+
| "grey-ghost"
|
|
44
|
+
| "text"
|
|
34
45
|
}
|
|
35
46
|
|
|
36
47
|
type OnClickHandler =
|
|
37
48
|
| React.MouseEventHandler<HTMLButtonElement | HTMLAnchorElement>
|
|
38
49
|
| ((event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => Promise<void>)
|
|
39
50
|
|
|
40
|
-
const LoadingIcon = () => {
|
|
41
|
-
return (
|
|
42
|
-
<svg
|
|
43
|
-
fill="none"
|
|
44
|
-
stroke="currentColor"
|
|
45
|
-
strokeLinecap="round"
|
|
46
|
-
strokeLinejoin="round"
|
|
47
|
-
strokeWidth="2"
|
|
48
|
-
viewBox="0 0 24 24"
|
|
49
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
50
|
-
>
|
|
51
|
-
<path d="M21 12a9 9 0 1 1-6.219-8.56" />
|
|
52
|
-
</svg>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
51
|
/**
|
|
57
52
|
* The Button component is an interactive element that people can use to take an action.
|
|
58
53
|
*/
|
|
@@ -67,7 +62,7 @@ export const Button = ({
|
|
|
67
62
|
loadingText = "Loading",
|
|
68
63
|
onClick,
|
|
69
64
|
size = "md",
|
|
70
|
-
variant = "
|
|
65
|
+
variant = "green",
|
|
71
66
|
...props
|
|
72
67
|
}: ButtonProps): JSX.Element => {
|
|
73
68
|
let element: ButtonProps["as"] = href ? "a" : "button"
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { AnchorHTMLAttributes, ForwardRefExoticComponent, HTMLAttributes, JSX } from "react"
|
|
2
2
|
|
|
3
|
+
import clsx from "clsx"
|
|
3
4
|
import React from "react"
|
|
4
5
|
|
|
6
|
+
import { bgPropToClass } from "../../../src/utils"
|
|
7
|
+
import { Lights, Tints } from "../../types/colors"
|
|
5
8
|
import { Image, ImageProps } from "../Image"
|
|
6
9
|
|
|
7
10
|
export interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
@@ -10,7 +13,7 @@ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
10
13
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
14
|
as?: React.FC<AnchorHTMLAttributes<HTMLElement>> | ForwardRefExoticComponent<any> | string
|
|
12
15
|
/** **(Optional)** Specifies the background color of the card. */
|
|
13
|
-
background?:
|
|
16
|
+
background?: Tints
|
|
14
17
|
/** **(Optional)** Represents the content inside the badge. */
|
|
15
18
|
badge?: React.ReactNode
|
|
16
19
|
/** **(Optional)** Specify badge position relative to top right corner. */
|
|
@@ -34,7 +37,7 @@ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
34
37
|
/** **(Optional)** Specifies the label of the Card */
|
|
35
38
|
label?: string
|
|
36
39
|
/** **(Optional)** Specifies the label background of the Card */
|
|
37
|
-
labelBackground?:
|
|
40
|
+
labelBackground?: Lights
|
|
38
41
|
/** **(Optional)** Specifies the layout of the Card */
|
|
39
42
|
layout?: "vertical" | "horizontal"
|
|
40
43
|
}
|
|
@@ -84,11 +87,9 @@ export const Card = ({
|
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
const componentProps = {
|
|
87
|
-
className:
|
|
90
|
+
className: clsx("coop-card", background && bgPropToClass(background, className), className),
|
|
88
91
|
"data-badge-pos": badgePosition,
|
|
89
|
-
"data-bg": background,
|
|
90
92
|
"data-image-pos": imagePosition,
|
|
91
|
-
"data-label-bg": labelBackground,
|
|
92
93
|
"data-layout": layout !== "vertical" ? layout : undefined,
|
|
93
94
|
...props,
|
|
94
95
|
}
|
|
@@ -99,7 +100,16 @@ export const Card = ({
|
|
|
99
100
|
{badge && <div className="coop-card--badge">{badge}</div>}
|
|
100
101
|
<div className="coop-card--inner">
|
|
101
102
|
<div className="coop-card--content">
|
|
102
|
-
{label &&
|
|
103
|
+
{label && (
|
|
104
|
+
<span
|
|
105
|
+
className={clsx(
|
|
106
|
+
"coop-card--label",
|
|
107
|
+
labelBackground && bgPropToClass(labelBackground, className)
|
|
108
|
+
)}
|
|
109
|
+
>
|
|
110
|
+
{label}
|
|
111
|
+
</span>
|
|
112
|
+
)}
|
|
103
113
|
{React.createElement(
|
|
104
114
|
linkElement.element,
|
|
105
115
|
linkElement.props,
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import type { DetailsHTMLAttributes, JSX } from "react"
|
|
2
2
|
|
|
3
|
+
import { clsx } from "clsx"
|
|
4
|
+
|
|
5
|
+
import { bgPropToClass } from "../../../src/utils"
|
|
6
|
+
import { None, Tints, White } from "../../types/colors"
|
|
7
|
+
|
|
3
8
|
export interface ExpandableProps extends DetailsHTMLAttributes<HTMLDetailsElement> {
|
|
4
9
|
/** **(Optional)** Specifies the Expandable background color from the available options. */
|
|
5
|
-
background?:
|
|
6
|
-
| "grey"
|
|
7
|
-
| "purple"
|
|
8
|
-
| "pink"
|
|
9
|
-
| "green"
|
|
10
|
-
| "orange"
|
|
11
|
-
| "red"
|
|
12
|
-
| "yellow"
|
|
13
|
-
| "lilac"
|
|
14
|
-
| "blue"
|
|
15
|
-
| "white"
|
|
16
|
-
| "transparent"
|
|
10
|
+
background?: Tints | White | None
|
|
17
11
|
/** Represents the content inside the Expandable component, only visible when expanded. It can be any valid JSX or string. */
|
|
18
12
|
children: React.ReactNode
|
|
19
13
|
/** **(Optional)** Receives any className to be applied to Expandable component. */
|
|
@@ -28,19 +22,18 @@ export interface ExpandableProps extends DetailsHTMLAttributes<HTMLDetailsElemen
|
|
|
28
22
|
*/
|
|
29
23
|
|
|
30
24
|
export const Expandable = ({
|
|
31
|
-
background = "grey",
|
|
25
|
+
background = "tint-grey",
|
|
32
26
|
children,
|
|
33
27
|
className = "",
|
|
34
28
|
summary,
|
|
35
29
|
...props
|
|
36
30
|
}: ExpandableProps): JSX.Element => {
|
|
37
31
|
const componentProps = {
|
|
38
|
-
className:
|
|
39
|
-
"data-bg": background,
|
|
32
|
+
className: clsx("coop-expandable", bgPropToClass(background, className), className),
|
|
40
33
|
...props,
|
|
41
34
|
}
|
|
42
35
|
return (
|
|
43
|
-
<details {...componentProps}>
|
|
36
|
+
<details {...componentProps} style={{ "--background-color": `var(--color-${background})` }}>
|
|
44
37
|
<summary>
|
|
45
38
|
{summary}
|
|
46
39
|
<svg fill="none" height="24" width="24" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type SVGProps, useId } from "react"
|
|
2
|
+
|
|
3
|
+
interface IconProps extends SVGProps<SVGSVGElement> {
|
|
4
|
+
alt?: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const LoadingIcon = ({ alt, className, ...props }: IconProps) => {
|
|
8
|
+
const id = useId()
|
|
9
|
+
const componentProps = {
|
|
10
|
+
"aria-labelledby": alt ? id : undefined,
|
|
11
|
+
className: `coop-icon ${className ?? ""}`.trim(),
|
|
12
|
+
"data-icon": "loading",
|
|
13
|
+
fill: "none",
|
|
14
|
+
role: alt ? "img" : undefined,
|
|
15
|
+
viewBox: "0 0 24 24",
|
|
16
|
+
...props,
|
|
17
|
+
}
|
|
18
|
+
return (
|
|
19
|
+
<svg {...componentProps}>
|
|
20
|
+
{alt ? <title id={id}>{alt}</title> : null}
|
|
21
|
+
<path
|
|
22
|
+
d="M10.72 19.9a8 8 0 0 1-6.5-9.79 7.77 7.77 0 0 1 6.18-5.95 8 8 0 0 1 9.49 6.52A1.54 1.54 0 0 0 21.38 12h.13a1.37 1.37 0 0 0 1.38-1.54 11 11 0 1 0-12.7 12.39A1.54 1.54 0 0 0 12 21.34a1.47 1.47 0 0 0-1.28-1.44"
|
|
23
|
+
fill="currentColor"
|
|
24
|
+
/>
|
|
25
|
+
</svg>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
@@ -20,6 +20,7 @@ export { CoopLocationIcon } from "./CoopLocationIcon"
|
|
|
20
20
|
export { DownloadIcon } from "./DownloadIcon"
|
|
21
21
|
export { HomeIcon } from "./HomeIcon"
|
|
22
22
|
export { InformationIcon } from "./InformationIcon"
|
|
23
|
+
export { LoadingIcon } from "./LoadingIcon"
|
|
23
24
|
export { LocationIcon } from "./LocationIcon"
|
|
24
25
|
export { MailIcon } from "./MailIcon"
|
|
25
26
|
export { MenuIcon } from "./MenuIcon"
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import type { AnchorHTMLAttributes, ForwardRefExoticComponent, HTMLAttributes, JSX } from "react"
|
|
2
2
|
|
|
3
|
+
import clsx from "clsx"
|
|
3
4
|
import React from "react"
|
|
4
5
|
|
|
6
|
+
import { bgPropToClass } from "../../../src/utils"
|
|
7
|
+
import { Darks, OffersRed, Tints } from "../../types/colors"
|
|
8
|
+
|
|
5
9
|
export interface PillProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
6
10
|
/** **(Optional)** Specifies the custom element to override default `a` or `span`. */
|
|
7
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
12
|
as?: React.FC<AnchorHTMLAttributes<HTMLElement>> | ForwardRefExoticComponent<any> | string
|
|
13
|
+
/** **(Optional)** Specifies the Pill background color from the available options. */
|
|
14
|
+
background?: Tints
|
|
9
15
|
/** **(Optional)** Specifies what text Pill should display on the badge. */
|
|
10
16
|
badge?: string
|
|
11
17
|
/** **(Optional)** Specifies the badge background color from the available options. */
|
|
12
|
-
|
|
18
|
+
badgeBackground?: Darks | OffersRed
|
|
13
19
|
/** **(Optional)** Represents the content inside the Pill component. It can be any valid JSX or string. */
|
|
14
20
|
children?: React.ReactNode
|
|
15
21
|
/** **(Optional)** Receives any className to be applied to Pill component. */
|
|
16
22
|
className?: string
|
|
17
23
|
/** **(Optional)** Specifies the URL that the Pill component will link to when clicked. */
|
|
18
24
|
href?: string
|
|
19
|
-
/** **(Optional)** Specifies the Pill background color from the available options. */
|
|
20
|
-
pillColor?: "blue" | "pink"
|
|
21
25
|
/** **(Optional)** Specifies what should be the Pill size. */
|
|
22
26
|
size?: "sm" | "md" | "lg" | "xl"
|
|
23
27
|
}
|
|
@@ -27,12 +31,12 @@ export interface PillProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
|
27
31
|
*/
|
|
28
32
|
export const Pill = ({
|
|
29
33
|
as,
|
|
34
|
+
background = "tint-grey",
|
|
30
35
|
badge,
|
|
31
|
-
|
|
36
|
+
badgeBackground = "offers-red",
|
|
32
37
|
children,
|
|
33
38
|
className = "",
|
|
34
39
|
href,
|
|
35
|
-
pillColor = "blue",
|
|
36
40
|
size = "md",
|
|
37
41
|
...props
|
|
38
42
|
}: PillProps): JSX.Element => {
|
|
@@ -43,15 +47,21 @@ export const Pill = ({
|
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
const componentProps = {
|
|
46
|
-
className:
|
|
47
|
-
"data-badge": badge?.length ? badge : undefined,
|
|
48
|
-
"data-badge-color": badgeColor,
|
|
49
|
-
"data-pill-color": pillColor,
|
|
50
|
+
className: clsx("coop-pill", bgPropToClass(background, className), className),
|
|
50
51
|
"data-size": size.length && size !== "md" ? size : undefined,
|
|
51
52
|
href,
|
|
52
53
|
...props,
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
|
|
56
|
+
const finalChildren = badge ? (
|
|
57
|
+
<>
|
|
58
|
+
{children}
|
|
59
|
+
<span className={clsx("coop-pill--badge", bgPropToClass(badgeBackground))}>{badge}</span>
|
|
60
|
+
</>
|
|
61
|
+
) : (
|
|
62
|
+
children
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
return React.createElement(element, { ...componentProps }, finalChildren)
|
|
56
66
|
}
|
|
57
67
|
export default Pill
|
|
@@ -26,7 +26,15 @@ export interface SearchBoxProps extends HTMLAttributes<HTMLInputElement> {
|
|
|
26
26
|
/** **(Optional)** Receives any size to be applied to SearchBox component. */
|
|
27
27
|
size?: string
|
|
28
28
|
/** **(Optional)** Receives the variant to be applied to SearchBox component. */
|
|
29
|
-
variant?:
|
|
29
|
+
variant?:
|
|
30
|
+
| "green"
|
|
31
|
+
| "blue"
|
|
32
|
+
| "white"
|
|
33
|
+
| "grey"
|
|
34
|
+
| "green-ghost"
|
|
35
|
+
| "blue-ghost"
|
|
36
|
+
| "white-ghost"
|
|
37
|
+
| "grey-ghost"
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
const defaultButtonProps: SearchBoxProps["button"] = {
|
|
@@ -64,7 +72,7 @@ export const SearchBox = ({
|
|
|
64
72
|
onSubmit,
|
|
65
73
|
placeholder,
|
|
66
74
|
size = "md",
|
|
67
|
-
variant = "
|
|
75
|
+
variant = "green",
|
|
68
76
|
...props
|
|
69
77
|
}: SearchBoxProps): JSX.Element => {
|
|
70
78
|
const [isPending, setIsPending] = useState(false)
|
|
@@ -92,7 +100,7 @@ export const SearchBox = ({
|
|
|
92
100
|
action: action ?? undefined,
|
|
93
101
|
className: `coop-search-box ${className ?? ""}`.trim(),
|
|
94
102
|
"data-size": size.length && size !== "md" ? size : undefined,
|
|
95
|
-
"data-variant": variant.length && variant !== "
|
|
103
|
+
"data-variant": variant.length && variant !== "green" ? variant : undefined,
|
|
96
104
|
onSubmit: onSubmit ? handleSubmit : undefined,
|
|
97
105
|
}
|
|
98
106
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { JSX } from "react"
|
|
2
|
+
|
|
3
|
+
import { bgPropToClass } from "../../../src/utils"
|
|
4
|
+
import { CoopBlue, Green, OffersRed } from "../../types/colors"
|
|
5
|
+
|
|
6
|
+
export interface SquircleProps {
|
|
7
|
+
/** **(Optional)** Specifies the background color of the Squircle. */
|
|
8
|
+
background?: OffersRed | CoopBlue | Green
|
|
9
|
+
/** **(Optional)** Represents the content inside the Squircle component. It can be any valid JSX or string. */
|
|
10
|
+
children?: React.ReactNode
|
|
11
|
+
/** **(Optional)** Receives any className to be applied to Squircle component. */
|
|
12
|
+
className?: string
|
|
13
|
+
/** **(Optional)** Specifies what should be the Squircle size */
|
|
14
|
+
size?: "sm" | "md" | "lg"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Squircle to use on components like Cards, etc.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export const Squircle = ({
|
|
22
|
+
background = "offers-red",
|
|
23
|
+
children,
|
|
24
|
+
className,
|
|
25
|
+
size = "lg",
|
|
26
|
+
...props
|
|
27
|
+
}: SquircleProps): JSX.Element => {
|
|
28
|
+
const componentProps = {
|
|
29
|
+
className: `coop-squircle ${bgPropToClass(background, className)} ${className ?? ""}`,
|
|
30
|
+
"data-size": size.length && size !== "lg" ? size : undefined,
|
|
31
|
+
...props,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<figure {...componentProps}>
|
|
36
|
+
<figcaption>{children}</figcaption>
|
|
37
|
+
</figure>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default Squircle
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import type { AnchorHTMLAttributes, ForwardRefExoticComponent, HTMLAttributes, JSX } from "react"
|
|
2
2
|
|
|
3
|
+
import clsx from "clsx"
|
|
3
4
|
import React from "react"
|
|
4
5
|
|
|
6
|
+
import type { Black, Darks, Greys, Lights, Tints, White } from "../../types/colors"
|
|
7
|
+
|
|
8
|
+
import { bgPropToClass } from "../../../src/utils"
|
|
9
|
+
|
|
5
10
|
export interface TagProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
6
11
|
/** **(Optional)** Specifies the custom element to override default `a` or `span`. */
|
|
7
12
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
13
|
as?: React.FC<AnchorHTMLAttributes<HTMLElement>> | ForwardRefExoticComponent<any> | string
|
|
14
|
+
/** **(Optional)** Specifies the Tag background color from the available options. */
|
|
15
|
+
background?: Lights | Darks | Tints | Greys | White | Black
|
|
9
16
|
/** **(Optional)** Represents the content inside the Tag component. It can be any valid JSX or string. */
|
|
10
17
|
children?: React.ReactNode
|
|
11
18
|
/** **(Optional)** Receives any className to be applied to Tag component. */
|
|
12
19
|
className?: string
|
|
13
20
|
/** **(Optional)** Specifies the URL that the Tag component will link to when clicked. */
|
|
14
21
|
href?: string
|
|
15
|
-
/** **(Optional)** Specifies the Tag background color from the available options. */
|
|
16
|
-
tagColor?:
|
|
17
|
-
| "white"
|
|
18
|
-
| "grey"
|
|
19
|
-
| "purple"
|
|
20
|
-
| "pink"
|
|
21
|
-
| "green"
|
|
22
|
-
| "orange"
|
|
23
|
-
| "red"
|
|
24
|
-
| "yellow"
|
|
25
|
-
| "lilac"
|
|
26
|
-
| "blue"
|
|
27
22
|
}
|
|
28
23
|
|
|
29
24
|
/**
|
|
@@ -39,16 +34,15 @@ export interface TagProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
|
39
34
|
|
|
40
35
|
export const Tag = ({
|
|
41
36
|
as,
|
|
37
|
+
background = "tint-grey",
|
|
42
38
|
children,
|
|
43
39
|
className = "",
|
|
44
40
|
href,
|
|
45
|
-
tagColor = "grey",
|
|
46
41
|
...props
|
|
47
42
|
}: TagProps): JSX.Element => {
|
|
48
43
|
let element: TagProps["as"] = href ? "a" : "span"
|
|
49
44
|
const componentProps = {
|
|
50
|
-
className:
|
|
51
|
-
"data-tag-color": tagColor,
|
|
45
|
+
className: clsx("coop-tag", bgPropToClass(background, className), className),
|
|
52
46
|
href,
|
|
53
47
|
...props,
|
|
54
48
|
}
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type Darks =
|
|
2
|
+
| "dark-blue"
|
|
3
|
+
| "dark-yellow"
|
|
4
|
+
| "dark-green"
|
|
5
|
+
| "dark-lilac"
|
|
6
|
+
| "dark-orange"
|
|
7
|
+
| "dark-pink"
|
|
8
|
+
| "dark-purple"
|
|
9
|
+
| "dark-red"
|
|
10
|
+
|
|
11
|
+
export type Tints =
|
|
12
|
+
| "tint-blue"
|
|
13
|
+
| "tint-brown"
|
|
14
|
+
| "tint-yellow"
|
|
15
|
+
| "tint-green"
|
|
16
|
+
| "tint-grey"
|
|
17
|
+
| "tint-lilac"
|
|
18
|
+
| "tint-orange"
|
|
19
|
+
| "tint-pink"
|
|
20
|
+
| "tint-purple"
|
|
21
|
+
| "tint-red"
|
|
22
|
+
|
|
23
|
+
export type Lights =
|
|
24
|
+
| "light-blue"
|
|
25
|
+
| "light-yellow"
|
|
26
|
+
| "light-green"
|
|
27
|
+
| "light-lilac"
|
|
28
|
+
| "light-orange"
|
|
29
|
+
| "light-pink"
|
|
30
|
+
| "light-purple"
|
|
31
|
+
| "light-red"
|
|
32
|
+
|
|
33
|
+
export type Greys = "dark-grey" | "mid-dark-grey" | "mid-grey" | "mid-light-grey" | "light-grey"
|
|
34
|
+
|
|
35
|
+
export type White = "white"
|
|
36
|
+
export type Black = "black"
|
|
37
|
+
export type None = "none"
|
|
38
|
+
export type CoopBlue = "coop-blue"
|
|
39
|
+
export type OffersRed = "offers-red"
|
|
40
|
+
export type Green = "green"
|
|
41
|
+
export type Blue = "blue"
|