@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.
@@ -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 };
@@ -0,0 +1,4 @@
1
+ import Tag from "./Tag";
2
+ export default Tag;
3
+ export { Tag };
4
+ export * from "./Tag";
package/dist/index.d.ts CHANGED
@@ -7,3 +7,4 @@ export * from "./components/Pill";
7
7
  export * from "./components/RootSVG";
8
8
  export * from "./components/Signpost";
9
9
  export * from "./components/SkipNav";
10
+ export * from "./components/Tag";
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.12.1",
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.11.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": "c4995d875a4e9d54ef3c23c8652902fe6f1068cc"
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
@@ -0,0 +1,5 @@
1
+ import Tag from "./Tag"
2
+
3
+ export default Tag
4
+ export { Tag }
5
+ export * from "./Tag"
package/src/index.ts CHANGED
@@ -7,3 +7,4 @@ export * from "./components/Pill"
7
7
  export * from "./components/RootSVG"
8
8
  export * from "./components/Signpost"
9
9
  export * from "./components/SkipNav"
10
+ export * from "./components/Tag"