@coopdigital/react 0.12.1 → 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/Pill/Pill.d.ts +1 -1
- package/dist/components/Pill/Pill.js +1 -1
- 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/Pill/Pill.tsx +1 -1
- package/src/components/Tag/Tag.tsx +61 -0
- package/src/components/Tag/index.ts +5 -0
- package/src/index.ts +1 -0
|
@@ -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"]);
|
|
@@ -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
|
}
|
|
@@ -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,
|
|
@@ -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