@coopdigital/react 0.19.0 → 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/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/Pill/Pill.d.ts +5 -4
- package/dist/components/Pill/Pill.js +7 -3
- 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/Card/Card.tsx +16 -16
- package/src/components/Expandable/Expandable.tsx +9 -17
- package/src/components/Pill/Pill.tsx +20 -10
- package/src/components/Squircle/Squircle.tsx +41 -0
- package/src/components/Squircle/index.ts +5 -0
- package/src/components/Tag/Tag.tsx +9 -16
- 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
|
@@ -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 };
|
|
@@ -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 };
|
|
@@ -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" | "purple" | "pink" | "green" | "orange" | "red" | "yellow" | "lilac" | "blue" | "brown" | "grey";
|
|
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.19.
|
|
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.16.
|
|
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
|
}
|
|
@@ -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,17 +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?:
|
|
14
|
-
| "purple"
|
|
15
|
-
| "pink"
|
|
16
|
-
| "green"
|
|
17
|
-
| "orange"
|
|
18
|
-
| "red"
|
|
19
|
-
| "yellow"
|
|
20
|
-
| "lilac"
|
|
21
|
-
| "blue"
|
|
22
|
-
| "brown"
|
|
23
|
-
| "grey"
|
|
16
|
+
background?: Tints
|
|
24
17
|
/** **(Optional)** Represents the content inside the badge. */
|
|
25
18
|
badge?: React.ReactNode
|
|
26
19
|
/** **(Optional)** Specify badge position relative to top right corner. */
|
|
@@ -44,7 +37,7 @@ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
44
37
|
/** **(Optional)** Specifies the label of the Card */
|
|
45
38
|
label?: string
|
|
46
39
|
/** **(Optional)** Specifies the label background of the Card */
|
|
47
|
-
labelBackground?:
|
|
40
|
+
labelBackground?: Lights
|
|
48
41
|
/** **(Optional)** Specifies the layout of the Card */
|
|
49
42
|
layout?: "vertical" | "horizontal"
|
|
50
43
|
}
|
|
@@ -94,11 +87,9 @@ export const Card = ({
|
|
|
94
87
|
}
|
|
95
88
|
|
|
96
89
|
const componentProps = {
|
|
97
|
-
className:
|
|
90
|
+
className: clsx("coop-card", background && bgPropToClass(background, className), className),
|
|
98
91
|
"data-badge-pos": badgePosition,
|
|
99
|
-
"data-bg": background,
|
|
100
92
|
"data-image-pos": imagePosition,
|
|
101
|
-
"data-label-bg": labelBackground,
|
|
102
93
|
"data-layout": layout !== "vertical" ? layout : undefined,
|
|
103
94
|
...props,
|
|
104
95
|
}
|
|
@@ -109,7 +100,16 @@ export const Card = ({
|
|
|
109
100
|
{badge && <div className="coop-card--badge">{badge}</div>}
|
|
110
101
|
<div className="coop-card--inner">
|
|
111
102
|
<div className="coop-card--content">
|
|
112
|
-
{label &&
|
|
103
|
+
{label && (
|
|
104
|
+
<span
|
|
105
|
+
className={clsx(
|
|
106
|
+
"coop-card--label",
|
|
107
|
+
labelBackground && bgPropToClass(labelBackground, className)
|
|
108
|
+
)}
|
|
109
|
+
>
|
|
110
|
+
{label}
|
|
111
|
+
</span>
|
|
112
|
+
)}
|
|
113
113
|
{React.createElement(
|
|
114
114
|
linkElement.element,
|
|
115
115
|
linkElement.props,
|
|
@@ -1,20 +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
|
-
| "purple"
|
|
7
|
-
| "pink"
|
|
8
|
-
| "green"
|
|
9
|
-
| "orange"
|
|
10
|
-
| "red"
|
|
11
|
-
| "yellow"
|
|
12
|
-
| "lilac"
|
|
13
|
-
| "blue"
|
|
14
|
-
| "white"
|
|
15
|
-
| "transparent"
|
|
16
|
-
| "brown"
|
|
17
|
-
| "grey"
|
|
10
|
+
background?: Tints | White | None
|
|
18
11
|
/** Represents the content inside the Expandable component, only visible when expanded. It can be any valid JSX or string. */
|
|
19
12
|
children: React.ReactNode
|
|
20
13
|
/** **(Optional)** Receives any className to be applied to Expandable component. */
|
|
@@ -29,19 +22,18 @@ export interface ExpandableProps extends DetailsHTMLAttributes<HTMLDetailsElemen
|
|
|
29
22
|
*/
|
|
30
23
|
|
|
31
24
|
export const Expandable = ({
|
|
32
|
-
background = "grey",
|
|
25
|
+
background = "tint-grey",
|
|
33
26
|
children,
|
|
34
27
|
className = "",
|
|
35
28
|
summary,
|
|
36
29
|
...props
|
|
37
30
|
}: ExpandableProps): JSX.Element => {
|
|
38
31
|
const componentProps = {
|
|
39
|
-
className:
|
|
40
|
-
"data-bg": background,
|
|
32
|
+
className: clsx("coop-expandable", bgPropToClass(background, className), className),
|
|
41
33
|
...props,
|
|
42
34
|
}
|
|
43
35
|
return (
|
|
44
|
-
<details {...componentProps}>
|
|
36
|
+
<details {...componentProps} style={{ "--background-color": `var(--color-${background})` }}>
|
|
45
37
|
<summary>
|
|
46
38
|
{summary}
|
|
47
39
|
<svg fill="none" height="24" width="24" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -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
|
|
@@ -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,30 +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
|
-
| "purple"
|
|
19
|
-
| "pink"
|
|
20
|
-
| "green"
|
|
21
|
-
| "orange"
|
|
22
|
-
| "red"
|
|
23
|
-
| "yellow"
|
|
24
|
-
| "lilac"
|
|
25
|
-
| "blue"
|
|
26
|
-
| "brown"
|
|
27
|
-
| "grey"
|
|
28
22
|
}
|
|
29
23
|
|
|
30
24
|
/**
|
|
@@ -40,16 +34,15 @@ export interface TagProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
|
40
34
|
|
|
41
35
|
export const Tag = ({
|
|
42
36
|
as,
|
|
37
|
+
background = "tint-grey",
|
|
43
38
|
children,
|
|
44
39
|
className = "",
|
|
45
40
|
href,
|
|
46
|
-
tagColor = "grey",
|
|
47
41
|
...props
|
|
48
42
|
}: TagProps): JSX.Element => {
|
|
49
43
|
let element: TagProps["as"] = href ? "a" : "span"
|
|
50
44
|
const componentProps = {
|
|
51
|
-
className:
|
|
52
|
-
"data-tag-color": tagColor,
|
|
45
|
+
className: clsx("coop-tag", bgPropToClass(background, className), className),
|
|
53
46
|
href,
|
|
54
47
|
...props,
|
|
55
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"
|