@coopdigital/react 0.5.1 → 0.5.2

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.
@@ -1,22 +1,22 @@
1
1
  import React, { AnchorHTMLAttributes, ForwardRefExoticComponent } from "react";
2
2
  export interface PillProps {
3
- /** Specifies the custom element to override default `a` or `span` */
3
+ /** **(Optional)** Specifies the custom element to override default `a` or `span`. */
4
4
  as?: React.FC<AnchorHTMLAttributes<HTMLElement>> | ForwardRefExoticComponent<any> | string;
5
- /** Specifies a custom aria-label */
5
+ /** **(Optional)** Specifies a custom aria-label. */
6
6
  ariaLabel?: string;
7
- /** Specifies what text Pill should display on the badge. */
7
+ /** **(Optional)** Specifies what text Pill should display on the badge. */
8
8
  badge?: string;
9
- /** Specifies the badge background color from the available options. */
9
+ /** **(Optional)** Specifies the badge background color from the available options. */
10
10
  badgeColor?: "green" | "orange" | "red" | "pink";
11
- /** Represents the content inside the Pill component. It can be any valid JSX or string. */
11
+ /** **(Optional)** Represents the content inside the Pill component. It can be any valid JSX or string. */
12
12
  children?: React.ReactNode;
13
- /** Receives any optional className to be applied to Pill component. */
13
+ /** **(Optional)** Receives any className to be applied to Pill component. */
14
14
  className?: string;
15
- /** Specifies the URL that the Pill component will link to when clicked. */
15
+ /** **(Optional)** Specifies the URL that the Pill component will link to when clicked. */
16
16
  href?: string;
17
- /** Specifies the Pill background color from the available options. */
17
+ /** **(Optional)** Specifies the Pill background color from the available options. */
18
18
  pillColor?: "blue" | "pink";
19
- /** Specifies what should be the Pill size. */
19
+ /** **(Optional)** Specifies what should be the Pill size. */
20
20
  size?: "sm" | "md" | "lg" | "xl";
21
21
  }
22
22
  export declare const Pill: ({ ariaLabel, as, badge, badgeColor, children, className, href, pillColor, size, }: PillProps) => React.ReactElement<React.AnchorHTMLAttributes<HTMLElement>, string | React.JSXElementConstructor<any>>;
@@ -0,0 +1,36 @@
1
+ interface SkipNavLink {
2
+ href: string;
3
+ title: string;
4
+ }
5
+ export interface SkipNavProps {
6
+ /** **(Optional)** Specifies a custom aria-label. */
7
+ ariaLabel?: string;
8
+ /** **(Optional)** Receives any className to be applied to Skip Nav component. */
9
+ className?: string;
10
+ /** **(Optional)** Specifies if the component is visible straight away or only when pressing 'Tab'. */
11
+ isVisible?: boolean;
12
+ /** **(Optional)** Specifies the links that are going to be shown on the Skip Nav.
13
+ * It is an `array` of items and each item should have `href` and `title` information.
14
+ *
15
+ * Defaults to a single link anchored to `#main` */
16
+ links?: SkipNavLink[];
17
+ }
18
+ /**
19
+ * The Skip Nav component allows screen reader and keyboard users to go directly to the main content.
20
+ *
21
+ * ### Links
22
+ * Links within the skip navigation component should take the user directly to the main areas of the page. These are usually the:
23
+ * - navigation
24
+ * - main content
25
+ * - footer
26
+ * - search (if applicable)
27
+ *
28
+ *
29
+ * ### Using skip navigation on a page
30
+ * - The skip navigation function should be the first thing that appears on a page when it has loaded and a user presses the tab key.
31
+ * - Pressing the tab key again should then cycle through 'skip to main content', 'skip to navigation' and 'skip to footer' links.
32
+ * - Pressing enter will take the user to the correct part of the page and apply the focus ring to the first interactive element in that section.
33
+ * - If the user tabs through the skip navigation without selecting an option the Co‑op logo should be the next element that has the focus ring applied.
34
+ */
35
+ export declare const SkipNav: ({ ariaLabel, className, isVisible, links, }: SkipNavProps) => import("react/jsx-runtime").JSX.Element;
36
+ export default SkipNav;
@@ -0,0 +1,4 @@
1
+ import SkipNav from "./SkipNav";
2
+ export default SkipNav;
3
+ export { SkipNav };
4
+ export * from "./SkipNav";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coopdigital/react",
3
3
  "type": "module",
4
- "version": "0.5.1",
4
+ "version": "0.5.2",
5
5
  "main": "dist/index.js",
6
6
  "private": false,
7
7
  "publishConfig": {
@@ -38,7 +38,7 @@
38
38
  "description": "",
39
39
  "devDependencies": {
40
40
  "@axe-core/playwright": "^4.10.1",
41
- "@coopdigital/styles": "^0.5.4",
41
+ "@coopdigital/styles": "^0.5.5",
42
42
  "@playwright/test": "^1.50.1",
43
43
  "@rollup/plugin-node-resolve": "^16.0.0",
44
44
  "@rollup/plugin-typescript": "^12.1.2",
@@ -64,5 +64,5 @@
64
64
  "react": "^19.0.0",
65
65
  "react-dom": "^19.0.0"
66
66
  },
67
- "gitHead": "634e2f73ada33fd85e9adef7b6ef8d84ae506afd"
67
+ "gitHead": "f292a4bba122b73db52ff17fa53eb90e7420c651"
68
68
  }
@@ -1,24 +1,24 @@
1
1
  import React, { AnchorHTMLAttributes, ForwardRefExoticComponent } from "react"
2
2
 
3
3
  export interface PillProps {
4
- /** Specifies the custom element to override default `a` or `span` */
4
+ /** **(Optional)** Specifies the custom element to override default `a` or `span`. */
5
5
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
6
  as?: React.FC<AnchorHTMLAttributes<HTMLElement>> | ForwardRefExoticComponent<any> | string
7
- /** Specifies a custom aria-label */
7
+ /** **(Optional)** Specifies a custom aria-label. */
8
8
  ariaLabel?: string
9
- /** Specifies what text Pill should display on the badge. */
9
+ /** **(Optional)** Specifies what text Pill should display on the badge. */
10
10
  badge?: string
11
- /** Specifies the badge background color from the available options. */
11
+ /** **(Optional)** Specifies the badge background color from the available options. */
12
12
  badgeColor?: "green" | "orange" | "red" | "pink"
13
- /** Represents the content inside the Pill component. It can be any valid JSX or string. */
13
+ /** **(Optional)** Represents the content inside the Pill component. It can be any valid JSX or string. */
14
14
  children?: React.ReactNode
15
- /** Receives any optional className to be applied to Pill component. */
15
+ /** **(Optional)** Receives any className to be applied to Pill component. */
16
16
  className?: string
17
- /** Specifies the URL that the Pill component will link to when clicked. */
17
+ /** **(Optional)** Specifies the URL that the Pill component will link to when clicked. */
18
18
  href?: string
19
- /** Specifies the Pill background color from the available options. */
19
+ /** **(Optional)** Specifies the Pill background color from the available options. */
20
20
  pillColor?: "blue" | "pink"
21
- /** Specifies what should be the Pill size. */
21
+ /** **(Optional)** Specifies what should be the Pill size. */
22
22
  size?: "sm" | "md" | "lg" | "xl"
23
23
  }
24
24
 
@@ -0,0 +1,66 @@
1
+ interface SkipNavLink {
2
+ href: string
3
+ title: string
4
+ }
5
+ export interface SkipNavProps {
6
+ /** **(Optional)** Specifies a custom aria-label. */
7
+ ariaLabel?: string
8
+ /** **(Optional)** Receives any className to be applied to Skip Nav component. */
9
+ className?: string
10
+ /** **(Optional)** Specifies if the component is visible straight away or only when pressing 'Tab'. */
11
+ isVisible?: boolean
12
+ /** **(Optional)** Specifies the links that are going to be shown on the Skip Nav.
13
+ * It is an `array` of items and each item should have `href` and `title` information.
14
+ *
15
+ * Defaults to a single link anchored to `#main` */
16
+ links?: SkipNavLink[]
17
+ }
18
+
19
+ const defaultLinks = [{ href: "#main", title: "Skip to main content" }]
20
+
21
+ /**
22
+ * The Skip Nav component allows screen reader and keyboard users to go directly to the main content.
23
+ *
24
+ * ### Links
25
+ * Links within the skip navigation component should take the user directly to the main areas of the page. These are usually the:
26
+ * - navigation
27
+ * - main content
28
+ * - footer
29
+ * - search (if applicable)
30
+ *
31
+ *
32
+ * ### Using skip navigation on a page
33
+ * - The skip navigation function should be the first thing that appears on a page when it has loaded and a user presses the tab key.
34
+ * - Pressing the tab key again should then cycle through 'skip to main content', 'skip to navigation' and 'skip to footer' links.
35
+ * - Pressing enter will take the user to the correct part of the page and apply the focus ring to the first interactive element in that section.
36
+ * - If the user tabs through the skip navigation without selecting an option the Co‑op logo should be the next element that has the focus ring applied.
37
+ */
38
+ export const SkipNav = ({
39
+ ariaLabel = "",
40
+ className = "",
41
+ isVisible = false,
42
+ links = defaultLinks,
43
+ }: SkipNavProps) => {
44
+ const navLinks = links.length > 0 ? links : defaultLinks
45
+
46
+ return (
47
+ <nav className="coop-skip-nav" aria-label={ariaLabel}>
48
+ <ul className="coop-skip-nav__list">
49
+ {navLinks.map((link) => (
50
+ <li key={link.href}>
51
+ <a
52
+ href={link.href}
53
+ title={link.title}
54
+ className={`coop-skip-nav__link ${className}`}
55
+ data-visible={isVisible}
56
+ >
57
+ {link.title}
58
+ </a>
59
+ </li>
60
+ ))}
61
+ </ul>
62
+ </nav>
63
+ )
64
+ }
65
+
66
+ export default SkipNav
@@ -0,0 +1,5 @@
1
+ import SkipNav from "./SkipNav"
2
+
3
+ export default SkipNav
4
+ export { SkipNav }
5
+ export * from "./SkipNav"
@@ -21,6 +21,15 @@ export const SampleText = "Lorem ipsum dolor..."
21
21
  > <h5 className="coop-t-headline coop-t-headline-upper coop-t-headline-blue">h5: {SampleText}</h5>
22
22
  > <h6 className="coop-t-headline coop-t-headline-upper coop-t-headline-blue">h6: {SampleText}</h6>
23
23
 
24
+ > ```jsx
25
+ > <h1 className="coop-t-headline coop-t-headline-upper">h1: {SampleText}</h1>
26
+ > <h2 className="coop-t-headline coop-t-headline-upper coop-t-headline-blue">h2: {SampleText}</h2>
27
+ > <h3 className="coop-t-headline coop-t-headline-upper coop-t-headline-blue">h3: {SampleText}</h3>
28
+ > <h4 className="coop-t-headline coop-t-headline-upper coop-t-headline-blue">h4: {SampleText}</h4>
29
+ > <h5 className="coop-t-headline coop-t-headline-upper coop-t-headline-blue">h5: {SampleText}</h5>
30
+ > <h6 className="coop-t-headline coop-t-headline-upper coop-t-headline-blue">h6: {SampleText}</h6>
31
+ > ```
32
+
24
33
  <br />
25
34
 
26
35
  > <h1 className="coop-t-headline coop-t-headline-blue">h1: {SampleText}</h1>
@@ -30,6 +39,15 @@ export const SampleText = "Lorem ipsum dolor..."
30
39
  > <h5 className="coop-t-headline coop-t-headline-blue">h5: {SampleText}</h5>
31
40
  > <h6 className="coop-t-headline coop-t-headline-blue">h6: {SampleText}</h6>
32
41
 
42
+ > ```jsx
43
+ > <h1 className="coop-t-headline coop-t-headline-blue">h1: {SampleText}</h1>
44
+ > <h2 className="coop-t-headline coop-t-headline-blue">h2: {SampleText}</h2>
45
+ > <h3 className="coop-t-headline coop-t-headline-blue">h3: {SampleText}</h3>
46
+ > <h4 className="coop-t-headline coop-t-headline-blue">h4: {SampleText}</h4>
47
+ > <h5 className="coop-t-headline coop-t-headline-blue">h5: {SampleText}</h5>
48
+ > <h6 className="coop-t-headline coop-t-headline-blue">h6: {SampleText}</h6>
49
+ > ```
50
+
33
51
  <br />
34
52
  <br />
35
53
  <br />
@@ -42,15 +60,39 @@ export const SampleText = "Lorem ipsum dolor..."
42
60
  > <h4>h4: {SampleText}</h4>
43
61
  > <h5>h5: {SampleText}</h5>
44
62
  > <h6>h6: {SampleText}</h6>
45
- >
63
+
64
+ > ```jsx
65
+ > <h1>h1: {SampleText}</h1>
66
+ > <h2>h2: {SampleText}</h2>
67
+ > <h3>h3: {SampleText}</h3>
68
+ > <h4>h4: {SampleText}</h4>
69
+ > <h5>h5: {SampleText}</h5>
70
+ > <h6>h6: {SampleText}</h6>
71
+ > ```
72
+
73
+ > <p class="coop-t-lead-p">Lead paragraph</p>
46
74
  > <hr />
47
- >
75
+ > <p>Paragraph text: {SampleText}</p>
76
+ > <a href="">Link</a>
77
+
78
+ > ```jsx
48
79
  > <p class="coop-t-lead-p">Lead paragraph</p>
49
- >
80
+ > <hr />
50
81
  > <p>Paragraph text: {SampleText}</p>
51
82
  > <a href="">Link</a>
52
- > <br />
53
- > <br />
83
+ > ```
84
+
85
+ > <p>Lists:</p>
86
+ > <ul>
87
+ > <li>Option 1</li>
88
+ > <li>Option 1</li>
89
+ > </ul>
90
+ > <ol>
91
+ > <li>Option 1</li>
92
+ > <li>Option 1</li>
93
+ > </ol>
94
+
95
+ > ```jsx
54
96
  > <p>Lists:</p>
55
97
  > <ul>
56
98
  > <li>Option 1</li>
@@ -60,6 +102,7 @@ export const SampleText = "Lorem ipsum dolor..."
60
102
  > <li>Option 1</li>
61
103
  > <li>Option 1</li>
62
104
  > </ol>
105
+ > ```
63
106
 
64
107
  </Unstyled>
65
108
 
@@ -70,3 +113,7 @@ export const SampleText = "Lorem ipsum dolor..."
70
113
  }
71
114
  `}
72
115
  </style>
116
+
117
+ ```
118
+
119
+ ```
@@ -22,7 +22,7 @@ export const SampleTextUppercase = SampleText.toUpperCase()
22
22
 
23
23
  # Typography
24
24
 
25
- **Font:** Avenir Next<br />
25
+ **Font:** Avenir Next ( as `--font-family`)<br />
26
26
  **Weights:** 400 (regular), 500 (medium), 600 (demi)
27
27
 
28
28
  <Typeset
@@ -32,7 +32,7 @@ export const SampleTextUppercase = SampleText.toUpperCase()
32
32
  fontFamily={typography.type.primary}
33
33
  />
34
34
 
35
- **Font:** Co-op Headline <br />
35
+ **Font:** Co-op Headline ( as `--font-family-headline`)<br />
36
36
  **Weights:** 700 (bold)
37
37
 
38
38
  <Typeset
@@ -41,3 +41,9 @@ export const SampleTextUppercase = SampleText.toUpperCase()
41
41
  sampleText={SampleTextUppercase}
42
42
  fontFamily={typography.type.headline}
43
43
  />
44
+
45
+ <p>
46
+ <b>Note:</b>
47
+ The type sizes shown above have been chosen as our standard type sizes.
48
+ <br /> They are available as CSS variables, e.g. `--type-size-10`, `--type-size-12`, etc.
49
+ </p>