@coopdigital/react 0.9.0 → 0.10.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.
@@ -31,5 +31,8 @@ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
31
31
  /** Specifies the title of the Card */
32
32
  title: string;
33
33
  }
34
+ /**
35
+ * A Card lets you highlight and link to more in-depth content on another page. The component typically includes a title, image, and an optional description.
36
+ */
34
37
  export declare const Card: ({ as, background, badge, badgePosition, chevron, children, headingLevel, href, image, imagePosition, label, labelBackground, layout, title, ...props }: CardProps) => JSX.Element;
35
38
  export default Card;
@@ -15,12 +15,15 @@ function getCardLinkElement(as, href) {
15
15
  },
16
16
  };
17
17
  }
18
+ /**
19
+ * A Card lets you highlight and link to more in-depth content on another page. The component typically includes a title, image, and an optional description.
20
+ */
18
21
  const Card = (_a) => {
19
22
  var { as, background, badge, badgePosition = "inset", chevron = false, children, headingLevel = "h3", href, image, imagePosition = "left", label = "", labelBackground, layout = "vertical", title } = _a, props = __rest(_a, ["as", "background", "badge", "badgePosition", "chevron", "children", "headingLevel", "href", "image", "imagePosition", "label", "labelBackground", "layout", "title"]);
20
23
  const linkElement = getCardLinkElement(as, href);
21
24
  const imageProps = Object.assign({ crop: "wide" }, image);
22
- const componentProps = Object.assign({ className: "coop-card", "data-background": background, "data-badge-pos": badgePosition, "data-image-pos": imagePosition, "data-label-background": labelBackground, "data-layout": layout }, props);
23
- 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("p", { className: "coop-card--label", children: jsx("span", { children: label }) })), React.createElement(linkElement.element, linkElement.props, React.createElement(headingLevel, {}, title)), 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" }) }) }))] })] })));
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, {}, title)), 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" }) }) }))] })] })));
24
27
  };
25
28
 
26
29
  export { Card, Card as default };
@@ -11,5 +11,8 @@ export interface ImageProps {
11
11
  /** **(Optional)** Specifies width of the Image */
12
12
  width?: string;
13
13
  }
14
+ /**
15
+ * A wrapper around the image HTML tag, to help implement best practices like lazy loading, and assist with cropping and sizing images.
16
+ */
14
17
  export declare const Image: ({ alt, crop, height, src, width }: ImageProps) => JSX.Element;
15
18
  export default Image;
@@ -20,6 +20,9 @@ const getContentfulParams = (src, width, height) => {
20
20
  width: (_b = url.searchParams.get("w")) !== null && _b !== void 0 ? _b : width,
21
21
  };
22
22
  };
23
+ /**
24
+ * A wrapper around the image HTML tag, to help implement best practices like lazy loading, and assist with cropping and sizing images.
25
+ */
23
26
  const Image = ({ alt, crop, height, src, width = "640" }) => {
24
27
  let params = { height, src, width };
25
28
  if (src.includes("images.ctfassets.net")) {
@@ -20,5 +20,8 @@ export interface PillProps {
20
20
  /** **(Optional)** Specifies what should be the Pill size. */
21
21
  size?: "sm" | "md" | "lg" | "xl";
22
22
  }
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.
25
+ */
23
26
  export declare const Pill: ({ ariaLabel, as, badge, badgeColor, children, className, href, pillColor, size, }: PillProps) => JSX.Element;
24
27
  export default Pill;
@@ -1,5 +1,8 @@
1
1
  import React from 'react';
2
2
 
3
+ /**
4
+ * 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
+ */
3
6
  const Pill = ({ ariaLabel, as, badge, badgeColor = "red", children, className = "", href, pillColor = "blue", size = "md", }) => {
4
7
  let element = href ? "a" : "span";
5
8
  if (as) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coopdigital/react",
3
3
  "type": "module",
4
- "version": "0.9.0",
4
+ "version": "0.10.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.9.0",
47
+ "@coopdigital/styles": "^0.10.0",
48
48
  "@playwright/test": "^1.51.1",
49
49
  "@storybook/addon-a11y": "^8.6.11",
50
50
  "@storybook/addon-essentials": "^8.6.11",
@@ -67,5 +67,5 @@
67
67
  "react": "^19.0.0",
68
68
  "react-dom": "^19.0.0"
69
69
  },
70
- "gitHead": "1c68d0c54618e299a4e5d7a89bf43ff17841a3e0"
70
+ "gitHead": "a5c63ef95571bbc32cf93d44b561f7050866dbce"
71
71
  }
@@ -33,7 +33,6 @@ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
33
33
  labelBackground?: "yellow" | "green" | "pink" | "purple" | "orange" | "red" | "lilac" | "blue"
34
34
  /** **(Optional)** Specifies the layout of the Card */
35
35
  layout?: "vertical" | "horizontal"
36
-
37
36
  /** Specifies the title of the Card */
38
37
  title: string
39
38
  }
@@ -53,6 +52,9 @@ function getCardLinkElement(as: CardProps["as"], href?: string) {
53
52
  }
54
53
  }
55
54
 
55
+ /**
56
+ * A Card lets you highlight and link to more in-depth content on another page. The component typically includes a title, image, and an optional description.
57
+ */
56
58
  export const Card = ({
57
59
  as,
58
60
  background,
@@ -79,10 +81,10 @@ export const Card = ({
79
81
 
80
82
  const componentProps = {
81
83
  className: "coop-card",
82
- "data-background": background,
83
84
  "data-badge-pos": badgePosition,
85
+ "data-bg": background,
84
86
  "data-image-pos": imagePosition,
85
- "data-label-background": labelBackground,
87
+ "data-label-bg": labelBackground,
86
88
  "data-layout": layout,
87
89
  ...props,
88
90
  }
@@ -93,11 +95,7 @@ export const Card = ({
93
95
  {badge && <div className="coop-card--badge">{badge}</div>}
94
96
  <div className="coop-card--inner">
95
97
  <div className="coop-card--content">
96
- {label && (
97
- <p className="coop-card--label">
98
- <span>{label}</span>
99
- </p>
100
- )}
98
+ {label && <span className="coop-card--label">{label}</span>}
101
99
  {React.createElement(
102
100
  linkElement.element,
103
101
  linkElement.props,
@@ -34,6 +34,9 @@ const getContentfulParams = (src: string, width: string, height: string | undefi
34
34
  }
35
35
  }
36
36
 
37
+ /**
38
+ * A wrapper around the image HTML tag, to help implement best practices like lazy loading, and assist with cropping and sizing images.
39
+ */
37
40
  export const Image = ({ alt, crop, height, src, width = "640" }: ImageProps): JSX.Element => {
38
41
  let params = { height, src, width }
39
42
 
@@ -24,6 +24,9 @@ export interface PillProps {
24
24
  size?: "sm" | "md" | "lg" | "xl"
25
25
  }
26
26
 
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.
29
+ */
27
30
  export const Pill = ({
28
31
  ariaLabel,
29
32
  as,