@uktrade/react-component-library 0.14.1 → 0.16.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/Readme.md +10 -0
- package/dist/components/NotificationBanner/NotificationBanner.d.ts +11 -0
- package/dist/components/NotificationBanner/NotificationBanner.d.ts.map +1 -0
- package/dist/components/NotificationBanner/NotificationBanner.js +7 -0
- package/dist/components/SummaryList/SummaryList.d.ts +3 -1
- package/dist/components/SummaryList/SummaryList.d.ts.map +1 -1
- package/dist/components/SummaryList/SummaryList.js +1 -1
- package/dist/components/SummaryList/SummaryList.module.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +2 -2
- package/src/components/NotificationBanner/NotificationBanner.tsx +52 -0
- package/src/components/SummaryList/SummaryList.module.css +1 -1
- package/src/components/SummaryList/SummaryList.tsx +21 -2
- package/src/index.ts +1 -0
package/Readme.md
CHANGED
|
@@ -54,3 +54,13 @@ npm run docs:start
|
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
This opens a Vite dev server with the playground for testing components.
|
|
57
|
+
|
|
58
|
+
### Publishing a new version
|
|
59
|
+
|
|
60
|
+
To publish a new version to NPM [@uktrade/react-component-library](https://www.npmjs.com/package/@uktrade/react-component-library):
|
|
61
|
+
|
|
62
|
+
1. **Update the version** in `package.json` following semantic versioning (don’t forget to sync the lockfile as well).
|
|
63
|
+
2. **Commit your changes** on a feature or working branch.
|
|
64
|
+
3. **Open a pull request** and **merge it into `main`**.
|
|
65
|
+
4. **Create a new GitHub Release** from the `main` branch and tag it with the same version (for example, `v0.10.1`).
|
|
66
|
+
5. Once the release is published, the [GitHub Actions workflow](./.github/workflows/release.yml) will automatically build and publish the package to NPM.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
type Props = {
|
|
3
|
+
title: string;
|
|
4
|
+
heading?: string;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
variant?: "success";
|
|
7
|
+
className?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const NotificationBanner: ({ title, heading, children, variant, className, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=NotificationBanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationBanner.d.ts","sourceRoot":"","sources":["../../../src/components/NotificationBanner/NotificationBanner.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,mDAMhC,KAAK,4CAgCP,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
export const NotificationBanner = ({ title, heading, children, variant, className, }) => {
|
|
5
|
+
const bannerClass = clsx("govuk-notification-banner", variant === "success" && "govuk-notification-banner--success", className);
|
|
6
|
+
return (_jsxs("div", { className: bannerClass, role: "alert", "aria-labelledby": "govuk-notification-banner-title", "data-module": "govuk-notification-banner", children: [_jsx("div", { className: "govuk-notification-banner__header", children: _jsx("h2", { className: "govuk-notification-banner__title", id: "govuk-notification-banner-title", children: title }) }), _jsxs("div", { className: "govuk-notification-banner__content", children: [heading && (_jsx("h3", { className: "govuk-notification-banner__heading", children: heading })), _jsx("p", { className: "govuk-body", children: children })] })] }));
|
|
7
|
+
};
|
|
@@ -12,6 +12,8 @@ export interface SummaryCardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
12
12
|
children?: React.ReactNode;
|
|
13
13
|
actions?: SummaryListAction[];
|
|
14
14
|
className?: string;
|
|
15
|
+
titleBackground?: string;
|
|
16
|
+
subSectionNode?: React.ReactNode;
|
|
15
17
|
}
|
|
16
|
-
export declare const SummaryCard: ({ title, children, actions, className, ...props }: SummaryCardProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare const SummaryCard: ({ title, children, actions, className, titleBackground, subSectionNode, ...props }: SummaryCardProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
19
|
//# sourceMappingURL=SummaryList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SummaryList.d.ts","sourceRoot":"","sources":["../../../src/components/SummaryList/SummaryList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D,MAAM,WAAW,gBAAiB,SAAQ,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC;IAC9E,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,WAAW,GAAI,0CAA0C,gBAAgB,4CAOrF,CAAC;AAEF,MAAM,WAAW,gBAAiB,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"SummaryList.d.ts","sourceRoot":"","sources":["../../../src/components/SummaryList/SummaryList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D,MAAM,WAAW,gBAAiB,SAAQ,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC;IAC9E,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,WAAW,GAAI,0CAA0C,gBAAgB,4CAOrF,CAAC;AAEF,MAAM,WAAW,gBAAiB,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAClC;AAED,eAAO,MAAM,WAAW,GAAI,oFAQzB,gBAAgB,4CAyClB,CAAC"}
|
|
@@ -4,4 +4,4 @@ import clsx from "clsx";
|
|
|
4
4
|
import { SummaryListAction } from "../SummaryItem/SummaryItem";
|
|
5
5
|
import styles from "./SummaryList.module.css";
|
|
6
6
|
export const SummaryList = ({ title, children, className, ...props }) => (_jsxs(_Fragment, { children: [title && _jsx("h2", { className: "govuk-heading-l", children: title }), _jsx("dl", { className: clsx("govuk-summary-list", className), ...props, children: children })] }));
|
|
7
|
-
export const SummaryCard = ({ title, children, actions, className, ...props }) => (_jsx("div", { className: clsx(styles.root, className), children: _jsxs("div", { className: "govuk-summary-card govuk-body", ...props, children: [_jsxs("div", { className: "govuk-summary-card__title-wrapper", children: [_jsx("h2", { className: "govuk-summary-card__title", children: title }), actions && (_jsx("ul", { className: clsx("govuk-summary-card__actions", styles.summaryCardTitleActions), children: actions.map((action) => (_jsx("li", { className: "govuk-summary-card__action", children: _jsx(SummaryListAction, { action: action }) }, action.text))) }))] }), _jsx("div", { className: clsx("govuk-summary-card__content", styles.govukSummaryCardContent), children: children })] }) }));
|
|
7
|
+
export const SummaryCard = ({ title, children, actions, className, titleBackground, subSectionNode, ...props }) => (_jsx("div", { className: clsx(styles.root, className), children: _jsxs("div", { className: "govuk-summary-card govuk-body", ...props, children: [_jsxs("div", { className: "govuk-summary-card__title-wrapper", style: titleBackground ? { background: titleBackground } : undefined, children: [_jsx("h2", { className: "govuk-summary-card__title", children: title }), actions && (_jsx("ul", { className: clsx("govuk-summary-card__actions", styles.summaryCardTitleActions), children: actions.map((action) => (_jsx("li", { className: "govuk-summary-card__action", children: _jsx(SummaryListAction, { action: action }) }, action.text))) }))] }), subSectionNode && (_jsx("div", { children: subSectionNode })), _jsx("div", { className: clsx("govuk-summary-card__content", styles.govukSummaryCardContent), children: children })] }) }));
|
package/dist/index.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ export * from "./components/LoadingSpinner/LoadingSpinner";
|
|
|
12
12
|
export * from "./components/ApiBoundary/ApiBoundary";
|
|
13
13
|
export * from "./components/ApiQuery";
|
|
14
14
|
export * from "./components/Inputs";
|
|
15
|
+
export * from "./components/NotificationBanner/NotificationBanner";
|
|
15
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wCAAwC,CAAC;AACvD,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4CAA4C,CAAC;AAC3D,cAAc,sCAAsC,CAAC;AACrD,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wCAAwC,CAAC;AACvD,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4CAA4C,CAAC;AAC3D,cAAc,sCAAsC,CAAC;AACrD,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oDAAoD,CAAC"}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uktrade/react-component-library",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "A collection of reusable React components following GOV.UK design patterns.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"build": "tsc -p tsconfig.build.json && npm run copy:css",
|
|
13
13
|
"copy:css": "rsync -av --include='*/' --include='*.css' --exclude='*' src/ dist/",
|
|
14
14
|
"docs:build": "tsc -p docs/playground/tsconfig.docs.json",
|
|
15
|
-
"docs:start": "npx vite@latest docs/playground open",
|
|
15
|
+
"docs:start": "npx vite@latest docs/playground --open",
|
|
16
16
|
"docs:vulnerability": "npx vite@latest --version && npm audit --audit-level=high",
|
|
17
17
|
"lint": "eslint .",
|
|
18
18
|
"lint:fix": "eslint . --fix",
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import type { ReactNode } from "react";
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
title: string;
|
|
8
|
+
heading?: string;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
variant?: "success"; // only supported variant
|
|
11
|
+
className?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const NotificationBanner = ({
|
|
15
|
+
title,
|
|
16
|
+
heading,
|
|
17
|
+
children,
|
|
18
|
+
variant,
|
|
19
|
+
className,
|
|
20
|
+
}: Props) => {
|
|
21
|
+
const bannerClass = clsx(
|
|
22
|
+
"govuk-notification-banner",
|
|
23
|
+
variant === "success" && "govuk-notification-banner--success",
|
|
24
|
+
className
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div
|
|
29
|
+
className={bannerClass}
|
|
30
|
+
role="alert"
|
|
31
|
+
aria-labelledby="govuk-notification-banner-title"
|
|
32
|
+
data-module="govuk-notification-banner"
|
|
33
|
+
>
|
|
34
|
+
<div className="govuk-notification-banner__header">
|
|
35
|
+
<h2
|
|
36
|
+
className="govuk-notification-banner__title"
|
|
37
|
+
id="govuk-notification-banner-title"
|
|
38
|
+
>
|
|
39
|
+
{title}
|
|
40
|
+
</h2>
|
|
41
|
+
</div>
|
|
42
|
+
<div className="govuk-notification-banner__content">
|
|
43
|
+
{heading && (
|
|
44
|
+
<h3 className="govuk-notification-banner__heading">
|
|
45
|
+
{heading}
|
|
46
|
+
</h3>
|
|
47
|
+
)}
|
|
48
|
+
<p className="govuk-body">{children}</p>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
@@ -27,12 +27,25 @@ export interface SummaryCardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
27
27
|
children?: React.ReactNode;
|
|
28
28
|
actions?: SummaryListAction[];
|
|
29
29
|
className?: string;
|
|
30
|
+
titleBackground?: string;
|
|
31
|
+
subSectionNode?: React.ReactNode;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
export const SummaryCard = ({
|
|
34
|
+
export const SummaryCard = ({
|
|
35
|
+
title,
|
|
36
|
+
children,
|
|
37
|
+
actions,
|
|
38
|
+
className,
|
|
39
|
+
titleBackground,
|
|
40
|
+
subSectionNode,
|
|
41
|
+
...props
|
|
42
|
+
}: SummaryCardProps) => (
|
|
33
43
|
<div className={clsx(styles.root, className)}>
|
|
34
44
|
<div className="govuk-summary-card govuk-body" {...props}>
|
|
35
|
-
<div
|
|
45
|
+
<div
|
|
46
|
+
className="govuk-summary-card__title-wrapper"
|
|
47
|
+
style={titleBackground ? { background: titleBackground } : undefined}
|
|
48
|
+
>
|
|
36
49
|
<h2 className="govuk-summary-card__title">{title}</h2>
|
|
37
50
|
|
|
38
51
|
{actions && (
|
|
@@ -51,6 +64,12 @@ export const SummaryCard = ({ title, children, actions, className, ...props }: S
|
|
|
51
64
|
)}
|
|
52
65
|
</div>
|
|
53
66
|
|
|
67
|
+
{subSectionNode && (
|
|
68
|
+
<div>
|
|
69
|
+
{subSectionNode}
|
|
70
|
+
</div>
|
|
71
|
+
)}
|
|
72
|
+
|
|
54
73
|
<div
|
|
55
74
|
className={clsx(
|
|
56
75
|
"govuk-summary-card__content",
|
package/src/index.ts
CHANGED