@i-dot-ai-npm/component-library-react 0.0.4 → 0.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@i-dot-ai-npm/component-library-react",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "React components for i.AI GOV.UK (auto-generated from HTML specs).",
5
5
  "type": "module",
6
6
  "exports": {
@@ -0,0 +1,28 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ type ContentsPanelProps = {
4
+ heading?: string;
5
+ headingId?: string;
6
+ class?: string;
7
+ children?: ReactNode;
8
+ [key: string]: unknown;
9
+ };
10
+
11
+ export default function ContentsPanel({
12
+ heading = "Pages in this section",
13
+ headingId = "contents-panel-heading",
14
+ class: className,
15
+ children,
16
+ ...rest
17
+ }: ContentsPanelProps) {
18
+ const classes = ["contents-panel", className ?? ""].filter(Boolean).join(" ");
19
+
20
+ return (
21
+ <nav className={classes} aria-labelledby={headingId} {...rest}>
22
+ <h2 className="govuk-visually-hidden" id={headingId}>
23
+ {heading}
24
+ </h2>
25
+ {children}
26
+ </nav>
27
+ );
28
+ }
@@ -0,0 +1,37 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ type ContentsPanelItemProps = {
4
+ href?: string;
5
+ current?: boolean;
6
+ class?: string;
7
+ children?: ReactNode;
8
+ [key: string]: unknown;
9
+ };
10
+
11
+ export default function ContentsPanelItem({
12
+ href,
13
+ current = false,
14
+ class: className,
15
+ children,
16
+ ...rest
17
+ }: ContentsPanelItemProps) {
18
+ const itemClasses = [
19
+ "contents-panel__list-item",
20
+ current ? "contents-panel__list-item--current" : "",
21
+ className ?? "",
22
+ ]
23
+ .filter(Boolean)
24
+ .join(" ");
25
+
26
+ return (
27
+ <li className={itemClasses} {...rest}>
28
+ <a
29
+ className="contents-panel__link govuk-link govuk-link--no-visited-state govuk-link--no-underline"
30
+ href={href}
31
+ aria-current={current ? "page" : undefined}
32
+ >
33
+ {children}
34
+ </a>
35
+ </li>
36
+ );
37
+ }
@@ -0,0 +1,17 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ type ContentsPanelListProps = {
4
+ class?: string;
5
+ children?: ReactNode;
6
+ [key: string]: unknown;
7
+ };
8
+
9
+ export default function ContentsPanelList({ class: className, children, ...rest }: ContentsPanelListProps) {
10
+ const classes = ["contents-panel__list", className ?? ""].filter(Boolean).join(" ");
11
+
12
+ return (
13
+ <ul className={classes} {...rest}>
14
+ {children}
15
+ </ul>
16
+ );
17
+ }
@@ -0,0 +1,17 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ type ContentsPanelListHeadingProps = {
4
+ class?: string;
5
+ children?: ReactNode;
6
+ [key: string]: unknown;
7
+ };
8
+
9
+ export default function ContentsPanelListHeading({ class: className, children, ...rest }: ContentsPanelListHeadingProps) {
10
+ const classes = ["contents-panel__list-heading", className ?? ""].filter(Boolean).join(" ");
11
+
12
+ return (
13
+ <h3 className={classes} {...rest}>
14
+ {children}
15
+ </h3>
16
+ );
17
+ }
package/src/index.ts CHANGED
@@ -23,6 +23,10 @@ export { default as CheckboxInput } from "./checkboxes/CheckboxInput";
23
23
  export { default as CheckboxItem } from "./checkboxes/CheckboxItem";
24
24
  export { default as CheckboxLabel } from "./checkboxes/CheckboxLabel";
25
25
  export { default as Checkboxes } from "./checkboxes/Checkboxes";
26
+ export { default as ContentsPanelListHeading } from "./contents-panel/ContentsPanelListHeading";
27
+ export { default as ContentsPanelList } from "./contents-panel/ContentsPanelList";
28
+ export { default as ContentsPanelItem } from "./contents-panel/ContentsPanelItem";
29
+ export { default as ContentsPanel } from "./contents-panel/ContentsPanel";
26
30
  export { default as CookieBannerActions } from "./cookie-banner/CookieBannerActions";
27
31
  export { default as CookieBannerContent } from "./cookie-banner/CookieBannerContent";
28
32
  export { default as CookieBannerHeading } from "./cookie-banner/CookieBannerHeading";
@@ -6,9 +6,5 @@ type ToggleProps = {
6
6
  export default function Toggle({ class: className, ...rest }: ToggleProps) {
7
7
  const classes = ["iai-toggle__input", className ?? ""].filter(Boolean).join(" ");
8
8
 
9
- return (
10
- <div className="iai-toggle">
11
- <input className={classes} type="checkbox" {...rest} />
12
- </div>
13
- );
9
+ return <input className={classes} type="checkbox" role="switch" {...rest} />;
14
10
  }
@@ -10,7 +10,7 @@ export default function ToggleItem({ class: className, children, ...rest }: Togg
10
10
  const classes = ["iai-toggle__item", className ?? ""].filter(Boolean).join(" ");
11
11
 
12
12
  return (
13
- <div className={classes} data-module="govuk-toggle" {...rest}>
13
+ <div className={classes} {...rest}>
14
14
  {children ?? ""}
15
15
  </div>
16
16
  );