@coopdigital/react 0.12.0 → 0.13.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/AlertBanner/AlertBanner.d.ts +3 -3
- package/dist/components/AlertBanner/AlertBanner.js +2 -2
- package/dist/components/Card/Card.d.ts +5 -5
- package/dist/components/Card/Card.js +3 -3
- package/dist/components/Pill/Pill.d.ts +1 -1
- package/dist/components/Pill/Pill.js +1 -1
- package/dist/components/Signpost/Signpost.d.ts +2 -2
- package/dist/components/SkipNav/SkipNav.d.ts +2 -2
- package/dist/components/SkipNav/SkipNav.js +3 -3
- package/dist/components/Tag/Tag.d.ts +26 -0
- package/dist/components/Tag/Tag.js +24 -0
- package/dist/components/Tag/index.d.ts +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +3 -3
- package/src/components/AlertBanner/AlertBanner.tsx +4 -4
- package/src/components/Card/Card.tsx +6 -6
- package/src/components/Pill/Pill.tsx +1 -1
- package/src/components/Signpost/Signpost.tsx +2 -2
- package/src/components/SkipNav/SkipNav.tsx +5 -5
- package/src/components/Tag/Tag.tsx +61 -0
- package/src/components/Tag/index.ts +5 -0
- package/src/index.ts +1 -0
|
@@ -6,8 +6,8 @@ export interface AlertBannerProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
6
6
|
children?: string | ReactNode;
|
|
7
7
|
/** **(Optional)** Receives any className to be applied to AlertBanner component. */
|
|
8
8
|
className?: string;
|
|
9
|
-
/** Specifies the AlertBanner
|
|
10
|
-
|
|
9
|
+
/** Specifies the AlertBanner heading. */
|
|
10
|
+
heading: string;
|
|
11
11
|
/** **(Optional)** Specifies the AlertBanner variant. */
|
|
12
12
|
variant?: "black" | "default";
|
|
13
13
|
}
|
|
@@ -21,5 +21,5 @@ export interface AlertBannerProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
21
21
|
* <p>Only use alert notifications when absolutely necessary. Using them too often could make the problem worse.<p/>
|
|
22
22
|
*
|
|
23
23
|
*/
|
|
24
|
-
export declare const AlertBanner: ({ ariaLabel, children, className,
|
|
24
|
+
export declare const AlertBanner: ({ ariaLabel, children, className, heading, variant, ...props }: AlertBannerProps) => JSX.Element;
|
|
25
25
|
export default AlertBanner;
|
|
@@ -12,9 +12,9 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
12
12
|
*
|
|
13
13
|
*/
|
|
14
14
|
const AlertBanner = (_a) => {
|
|
15
|
-
var { ariaLabel, children, className = "",
|
|
15
|
+
var { ariaLabel, children, className = "", heading, variant = "default" } = _a, props = __rest(_a, ["ariaLabel", "children", "className", "heading", "variant"]);
|
|
16
16
|
const componentProps = Object.assign({ "aria-label": ariaLabel, className: `coop-alert-banner ${className}`, "data-variant": variant }, props);
|
|
17
|
-
return (jsx("aside", Object.assign({}, componentProps, { children: jsxs("div", { className: "coop-alert-banner--inner", children: [jsx("h2", { id: "coop-alert-banner--headline", children:
|
|
17
|
+
return (jsx("aside", Object.assign({}, componentProps, { children: jsxs("div", { className: "coop-alert-banner--inner", children: [jsx("h2", { id: "coop-alert-banner--headline", children: heading }), children] }) })));
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export { AlertBanner, AlertBanner as default };
|
|
@@ -14,7 +14,9 @@ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
14
14
|
chevron?: boolean;
|
|
15
15
|
/** **(Optional)** Represents the content inside the Card component. It can be any valid JSX or string. */
|
|
16
16
|
children?: React.ReactNode;
|
|
17
|
-
/**
|
|
17
|
+
/** Specifies the heading of the Card */
|
|
18
|
+
heading: string;
|
|
19
|
+
/** **(Optional)** Specifies the heading level of the card's heading. */
|
|
18
20
|
headingLevel?: "h2" | "h3" | "h4" | "h5" | "h6";
|
|
19
21
|
/** **(Optional)** Specifies the URL that the Card component will link to when clicked. */
|
|
20
22
|
href?: string;
|
|
@@ -28,11 +30,9 @@ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
28
30
|
labelBackground?: "yellow" | "green" | "pink" | "purple" | "orange" | "red" | "lilac" | "blue";
|
|
29
31
|
/** **(Optional)** Specifies the layout of the Card */
|
|
30
32
|
layout?: "vertical" | "horizontal";
|
|
31
|
-
/** Specifies the title of the Card */
|
|
32
|
-
title: string;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
* A Card lets you highlight and link to more in-depth content on another page. The component typically includes a
|
|
35
|
+
* A Card lets you highlight and link to more in-depth content on another page. The component typically includes a heading, image, and an optional description.
|
|
36
36
|
*/
|
|
37
|
-
export declare const Card: ({ as, background, badge, badgePosition, chevron, children, headingLevel, href, image, imagePosition, label, labelBackground, layout,
|
|
37
|
+
export declare const Card: ({ as, background, badge, badgePosition, chevron, children, heading, headingLevel, href, image, imagePosition, label, labelBackground, layout, ...props }: CardProps) => JSX.Element;
|
|
38
38
|
export default Card;
|
|
@@ -16,14 +16,14 @@ function getCardLinkElement(as, href) {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* A Card lets you highlight and link to more in-depth content on another page. The component typically includes a
|
|
19
|
+
* A Card lets you highlight and link to more in-depth content on another page. The component typically includes a heading, image, and an optional description.
|
|
20
20
|
*/
|
|
21
21
|
const Card = (_a) => {
|
|
22
|
-
var { as, background, badge, badgePosition = "inset", chevron = false, children, headingLevel = "h3", href, image, imagePosition = "left", label = "", labelBackground, layout = "vertical"
|
|
22
|
+
var { as, background, badge, badgePosition = "inset", chevron = false, children, heading, headingLevel = "h3", href, image, imagePosition = "left", label = "", labelBackground, layout = "vertical" } = _a, props = __rest(_a, ["as", "background", "badge", "badgePosition", "chevron", "children", "heading", "headingLevel", "href", "image", "imagePosition", "label", "labelBackground", "layout"]);
|
|
23
23
|
const linkElement = getCardLinkElement(as, href);
|
|
24
24
|
const imageProps = Object.assign({ crop: "wide" }, image);
|
|
25
25
|
const componentProps = Object.assign({ className: "coop-card", "data-badge-pos": badgePosition, "data-bg": background, "data-image-pos": imagePosition, "data-label-bg": labelBackground, "data-layout": layout }, props);
|
|
26
|
-
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" },
|
|
26
|
+
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" }) }) }))] })] })));
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
export { Card, Card as default };
|
|
@@ -21,7 +21,7 @@ export interface PillProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
|
21
21
|
size?: "sm" | "md" | "lg" | "xl";
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* The Pill component is a small, 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.
|
|
24
|
+
* 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.
|
|
25
25
|
*/
|
|
26
26
|
export declare const Pill: ({ ariaLabel, as, badge, badgeColor, children, className, href, pillColor, size, ...props }: PillProps) => JSX.Element;
|
|
27
27
|
export default Pill;
|
|
@@ -2,7 +2,7 @@ import { __rest } from '../../node_modules/tslib/tslib.es6.js';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* The Pill component is a small, 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.
|
|
5
|
+
* 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
6
|
*/
|
|
7
7
|
const Pill = (_a) => {
|
|
8
8
|
var { ariaLabel, as, badge, badgeColor = "red", children, className = "", href, pillColor = "blue", size = "md" } = _a, props = __rest(_a, ["ariaLabel", "as", "badge", "badgeColor", "children", "className", "href", "pillColor", "size"]);
|
|
@@ -4,9 +4,9 @@ import { ImageProps } from "../Image";
|
|
|
4
4
|
export interface SignpostProps {
|
|
5
5
|
/** **(Optional)** Specifies the custom element to override default `a` */
|
|
6
6
|
as?: React.FC<AnchorHTMLAttributes<HTMLElement>> | ForwardRefExoticComponent<any> | string;
|
|
7
|
-
/** Represents the
|
|
7
|
+
/** Represents the heading inside the Signpost component. It can be any valid JSX or string. */
|
|
8
8
|
children: React.ReactNode;
|
|
9
|
-
/** **(Optional)** Specifies the heading level of the signpost's
|
|
9
|
+
/** **(Optional)** Specifies the heading level of the signpost's heading. */
|
|
10
10
|
headingLevel?: "h2" | "h3" | "h4" | "h5" | "h6";
|
|
11
11
|
/** Specifies the URL that the Signpost component will link to when clicked. */
|
|
12
12
|
href: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AnchorHTMLAttributes, JSX } from "react";
|
|
2
2
|
interface SkipNavLink {
|
|
3
3
|
href: string;
|
|
4
|
-
|
|
4
|
+
label: string;
|
|
5
5
|
}
|
|
6
6
|
export interface SkipNavProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
7
7
|
/** **(Optional)** Specifies a custom aria-label. */
|
|
@@ -11,7 +11,7 @@ export interface SkipNavProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
|
11
11
|
/** **(Optional)** Specifies if the component is visible straight away or only when pressing 'Tab'. */
|
|
12
12
|
isVisible?: boolean;
|
|
13
13
|
/** **(Optional)** Specifies the links that are going to be shown on the Skip Nav.
|
|
14
|
-
* It is an `array` of items and each item should have `href` and `
|
|
14
|
+
* It is an `array` of items and each item should have `href` and `label` information.
|
|
15
15
|
*
|
|
16
16
|
* Defaults to a single link anchored to `#main` */
|
|
17
17
|
links?: SkipNavLink[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __rest } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
|
-
const defaultLinks = [{ href: "#main",
|
|
4
|
+
const defaultLinks = [{ href: "#main", label: "Skip to main content" }];
|
|
5
5
|
/**
|
|
6
6
|
* The Skip Nav component allows screen reader and keyboard users to go directly to the main content.
|
|
7
7
|
*
|
|
@@ -27,9 +27,9 @@ const SkipNav = (_a) => {
|
|
|
27
27
|
className: `${className}`,
|
|
28
28
|
"data-visible": isVisible,
|
|
29
29
|
href: link.href,
|
|
30
|
-
|
|
30
|
+
label: link.label,
|
|
31
31
|
};
|
|
32
|
-
return (jsx("li", { children: jsx("a", Object.assign({}, linkProps, { children: link.
|
|
32
|
+
return (jsx("li", { children: jsx("a", Object.assign({}, linkProps, { children: link.label })) }, link.href));
|
|
33
33
|
}) }) })));
|
|
34
34
|
};
|
|
35
35
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AnchorHTMLAttributes, ForwardRefExoticComponent, HTMLAttributes, JSX } from "react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export interface TagProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
4
|
+
/** **(Optional)** Specifies the custom element to override default `a` or `span`. */
|
|
5
|
+
as?: React.FC<AnchorHTMLAttributes<HTMLElement>> | ForwardRefExoticComponent<any> | string;
|
|
6
|
+
/** **(Optional)** Represents the content inside the Tag component. It can be any valid JSX or string. */
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/** **(Optional)** Receives any className to be applied to Tag component. */
|
|
9
|
+
className?: string;
|
|
10
|
+
/** **(Optional)** Specifies the URL that the Tag component will link to when clicked. */
|
|
11
|
+
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
|
+
/**
|
|
16
|
+
* Tag is a simple component that is meant to communicate a brief message such as categories.
|
|
17
|
+
*
|
|
18
|
+
* It has similarities with Pill component but also has differences such as:
|
|
19
|
+
* - Tag doesn't accept a badge option
|
|
20
|
+
* - Tags have more rounded corners compared to Pill
|
|
21
|
+
* - Tags are more compact compared to Pill
|
|
22
|
+
* - Tag components should be used as tags to communicate brief message while Pill component is more versatile and has more styling options
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
export declare const Tag: ({ as, children, className, href, tagColor, ...props }: TagProps) => JSX.Element;
|
|
26
|
+
export default Tag;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { __rest } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Tag is a simple component that is meant to communicate a brief message such as categories.
|
|
6
|
+
*
|
|
7
|
+
* It has similarities with Pill component but also has differences such as:
|
|
8
|
+
* - Tag doesn't accept a badge option
|
|
9
|
+
* - Tags have more rounded corners compared to Pill
|
|
10
|
+
* - Tags are more compact compared to Pill
|
|
11
|
+
* - Tag components should be used as tags to communicate brief message while Pill component is more versatile and has more styling options
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
const Tag = (_a) => {
|
|
15
|
+
var { as, children, className = "", href, tagColor = "grey" } = _a, props = __rest(_a, ["as", "children", "className", "href", "tagColor"]);
|
|
16
|
+
let element = href ? "a" : "span";
|
|
17
|
+
const componentProps = Object.assign({ className: `coop-tag ${className}`, "data-tag-color": tagColor, href }, props);
|
|
18
|
+
if (as) {
|
|
19
|
+
element = as;
|
|
20
|
+
}
|
|
21
|
+
return React.createElement(element, Object.assign({}, componentProps), children);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { Tag, Tag as default };
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -7,3 +7,4 @@ export { Pill } from './components/Pill/Pill.js';
|
|
|
7
7
|
export { default as RootSVG } from './components/RootSVG/RootSVG.js';
|
|
8
8
|
export { Signpost } from './components/Signpost/Signpost.js';
|
|
9
9
|
export { SkipNav } from './components/SkipNav/SkipNav.js';
|
|
10
|
+
export { Tag } from './components/Tag/Tag.js';
|
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.13.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"description": "",
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@axe-core/playwright": "^4.10.1",
|
|
47
|
-
"@coopdigital/styles": "^0.
|
|
47
|
+
"@coopdigital/styles": "^0.12.0",
|
|
48
48
|
"@playwright/test": "^1.51.1",
|
|
49
49
|
"@storybook/addon-a11y": "^8.6.12",
|
|
50
50
|
"@storybook/addon-essentials": "^8.6.12",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"react": "^19.0.0",
|
|
67
67
|
"react-dom": "^19.0.0"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "81b0f15eb07450a777497068be1422ebf01dc2fa"
|
|
70
70
|
}
|
|
@@ -7,8 +7,8 @@ export interface AlertBannerProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
7
7
|
children?: string | ReactNode
|
|
8
8
|
/** **(Optional)** Receives any className to be applied to AlertBanner component. */
|
|
9
9
|
className?: string
|
|
10
|
-
/** Specifies the AlertBanner
|
|
11
|
-
|
|
10
|
+
/** Specifies the AlertBanner heading. */
|
|
11
|
+
heading: string
|
|
12
12
|
/** **(Optional)** Specifies the AlertBanner variant. */
|
|
13
13
|
variant?: "black" | "default"
|
|
14
14
|
}
|
|
@@ -27,7 +27,7 @@ export const AlertBanner = ({
|
|
|
27
27
|
ariaLabel,
|
|
28
28
|
children,
|
|
29
29
|
className = "",
|
|
30
|
-
|
|
30
|
+
heading,
|
|
31
31
|
variant = "default",
|
|
32
32
|
...props
|
|
33
33
|
}: AlertBannerProps): JSX.Element => {
|
|
@@ -40,7 +40,7 @@ export const AlertBanner = ({
|
|
|
40
40
|
return (
|
|
41
41
|
<aside {...componentProps}>
|
|
42
42
|
<div className="coop-alert-banner--inner">
|
|
43
|
-
<h2 id="coop-alert-banner--headline">{
|
|
43
|
+
<h2 id="coop-alert-banner--headline">{heading}</h2>
|
|
44
44
|
{children}
|
|
45
45
|
</div>
|
|
46
46
|
</aside>
|
|
@@ -19,7 +19,9 @@ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
19
19
|
chevron?: boolean
|
|
20
20
|
/** **(Optional)** Represents the content inside the Card component. It can be any valid JSX or string. */
|
|
21
21
|
children?: React.ReactNode
|
|
22
|
-
/**
|
|
22
|
+
/** Specifies the heading of the Card */
|
|
23
|
+
heading: string
|
|
24
|
+
/** **(Optional)** Specifies the heading level of the card's heading. */
|
|
23
25
|
headingLevel?: "h2" | "h3" | "h4" | "h5" | "h6"
|
|
24
26
|
/** **(Optional)** Specifies the URL that the Card component will link to when clicked. */
|
|
25
27
|
href?: string
|
|
@@ -33,8 +35,6 @@ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
33
35
|
labelBackground?: "yellow" | "green" | "pink" | "purple" | "orange" | "red" | "lilac" | "blue"
|
|
34
36
|
/** **(Optional)** Specifies the layout of the Card */
|
|
35
37
|
layout?: "vertical" | "horizontal"
|
|
36
|
-
/** Specifies the title of the Card */
|
|
37
|
-
title: string
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
function getCardLinkElement(as: CardProps["as"], href?: string) {
|
|
@@ -53,7 +53,7 @@ function getCardLinkElement(as: CardProps["as"], href?: string) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
* A Card lets you highlight and link to more in-depth content on another page. The component typically includes a
|
|
56
|
+
* A Card lets you highlight and link to more in-depth content on another page. The component typically includes a heading, image, and an optional description.
|
|
57
57
|
*/
|
|
58
58
|
export const Card = ({
|
|
59
59
|
as,
|
|
@@ -62,6 +62,7 @@ export const Card = ({
|
|
|
62
62
|
badgePosition = "inset",
|
|
63
63
|
chevron = false,
|
|
64
64
|
children,
|
|
65
|
+
heading,
|
|
65
66
|
headingLevel = "h3",
|
|
66
67
|
href,
|
|
67
68
|
image,
|
|
@@ -69,7 +70,6 @@ export const Card = ({
|
|
|
69
70
|
label = "",
|
|
70
71
|
labelBackground,
|
|
71
72
|
layout = "vertical",
|
|
72
|
-
title,
|
|
73
73
|
...props
|
|
74
74
|
}: CardProps): JSX.Element => {
|
|
75
75
|
const linkElement = getCardLinkElement(as, href)
|
|
@@ -99,7 +99,7 @@ export const Card = ({
|
|
|
99
99
|
{React.createElement(
|
|
100
100
|
linkElement.element,
|
|
101
101
|
linkElement.props,
|
|
102
|
-
React.createElement(headingLevel, { className: "coop-card--heading" },
|
|
102
|
+
React.createElement(headingLevel, { className: "coop-card--heading" }, heading)
|
|
103
103
|
)}
|
|
104
104
|
{children}
|
|
105
105
|
</div>
|
|
@@ -25,7 +25,7 @@ export interface PillProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* The Pill component is a small, 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.
|
|
28
|
+
* 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.
|
|
29
29
|
*/
|
|
30
30
|
export const Pill = ({
|
|
31
31
|
ariaLabel,
|
|
@@ -8,9 +8,9 @@ export interface SignpostProps {
|
|
|
8
8
|
/** **(Optional)** Specifies the custom element to override default `a` */
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
10
|
as?: React.FC<AnchorHTMLAttributes<HTMLElement>> | ForwardRefExoticComponent<any> | string
|
|
11
|
-
/** Represents the
|
|
11
|
+
/** Represents the heading inside the Signpost component. It can be any valid JSX or string. */
|
|
12
12
|
children: React.ReactNode
|
|
13
|
-
/** **(Optional)** Specifies the heading level of the signpost's
|
|
13
|
+
/** **(Optional)** Specifies the heading level of the signpost's heading. */
|
|
14
14
|
headingLevel?: "h2" | "h3" | "h4" | "h5" | "h6"
|
|
15
15
|
/** Specifies the URL that the Signpost component will link to when clicked. */
|
|
16
16
|
href: string
|
|
@@ -2,7 +2,7 @@ import type { AnchorHTMLAttributes, JSX } from "react"
|
|
|
2
2
|
|
|
3
3
|
interface SkipNavLink {
|
|
4
4
|
href: string
|
|
5
|
-
|
|
5
|
+
label: string
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export interface SkipNavProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
@@ -13,13 +13,13 @@ export interface SkipNavProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
|
13
13
|
/** **(Optional)** Specifies if the component is visible straight away or only when pressing 'Tab'. */
|
|
14
14
|
isVisible?: boolean
|
|
15
15
|
/** **(Optional)** Specifies the links that are going to be shown on the Skip Nav.
|
|
16
|
-
* It is an `array` of items and each item should have `href` and `
|
|
16
|
+
* It is an `array` of items and each item should have `href` and `label` information.
|
|
17
17
|
*
|
|
18
18
|
* Defaults to a single link anchored to `#main` */
|
|
19
19
|
links?: SkipNavLink[]
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const defaultLinks = [{ href: "#main",
|
|
22
|
+
const defaultLinks = [{ href: "#main", label: "Skip to main content" }]
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* The Skip Nav component allows screen reader and keyboard users to go directly to the main content.
|
|
@@ -54,11 +54,11 @@ export const SkipNav = ({
|
|
|
54
54
|
className: `${className}`,
|
|
55
55
|
"data-visible": isVisible,
|
|
56
56
|
href: link.href,
|
|
57
|
-
|
|
57
|
+
label: link.label,
|
|
58
58
|
}
|
|
59
59
|
return (
|
|
60
60
|
<li key={link.href}>
|
|
61
|
-
<a {...linkProps}>{link.
|
|
61
|
+
<a {...linkProps}>{link.label}</a>
|
|
62
62
|
</li>
|
|
63
63
|
)
|
|
64
64
|
})}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { AnchorHTMLAttributes, ForwardRefExoticComponent, HTMLAttributes, JSX } from "react"
|
|
2
|
+
|
|
3
|
+
import React from "react"
|
|
4
|
+
|
|
5
|
+
export interface TagProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
6
|
+
/** **(Optional)** Specifies the custom element to override default `a` or `span`. */
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
as?: React.FC<AnchorHTMLAttributes<HTMLElement>> | ForwardRefExoticComponent<any> | string
|
|
9
|
+
/** **(Optional)** Represents the content inside the Tag component. It can be any valid JSX or string. */
|
|
10
|
+
children?: React.ReactNode
|
|
11
|
+
/** **(Optional)** Receives any className to be applied to Tag component. */
|
|
12
|
+
className?: string
|
|
13
|
+
/** **(Optional)** Specifies the URL that the Tag component will link to when clicked. */
|
|
14
|
+
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
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Tag is a simple component that is meant to communicate a brief message such as categories.
|
|
31
|
+
*
|
|
32
|
+
* It has similarities with Pill component but also has differences such as:
|
|
33
|
+
* - Tag doesn't accept a badge option
|
|
34
|
+
* - Tags have more rounded corners compared to Pill
|
|
35
|
+
* - Tags are more compact compared to Pill
|
|
36
|
+
* - Tag components should be used as tags to communicate brief message while Pill component is more versatile and has more styling options
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
export const Tag = ({
|
|
41
|
+
as,
|
|
42
|
+
children,
|
|
43
|
+
className = "",
|
|
44
|
+
href,
|
|
45
|
+
tagColor = "grey",
|
|
46
|
+
...props
|
|
47
|
+
}: TagProps): JSX.Element => {
|
|
48
|
+
let element: TagProps["as"] = href ? "a" : "span"
|
|
49
|
+
const componentProps = {
|
|
50
|
+
className: `coop-tag ${className}`,
|
|
51
|
+
"data-tag-color": tagColor,
|
|
52
|
+
href,
|
|
53
|
+
...props,
|
|
54
|
+
}
|
|
55
|
+
if (as) {
|
|
56
|
+
element = as
|
|
57
|
+
}
|
|
58
|
+
return React.createElement(element, { ...componentProps }, children)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default Tag
|
package/src/index.ts
CHANGED