@uktrade/react-component-library 0.18.0 → 0.18.1

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.
@@ -5,7 +5,8 @@ type Props = {
5
5
  children: ReactNode;
6
6
  variant?: "success";
7
7
  className?: string;
8
+ onClose?: () => void;
8
9
  };
9
- export declare const NotificationBanner: ({ title, heading, children, variant, className, }: Props) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const NotificationBanner: ({ title, heading, children, variant, className, onClose, }: Props) => import("react/jsx-runtime").JSX.Element;
10
11
  export {};
11
12
  //# sourceMappingURL=NotificationBanner.d.ts.map
@@ -1 +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"}
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;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,4DAOhC,KAAK,4CA0CP,CAAC"}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import clsx from "clsx";
4
- export const NotificationBanner = ({ title, heading, children, variant, className, }) => {
4
+ export const NotificationBanner = ({ title, heading, children, variant, className, onClose, }) => {
5
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 })] })] }));
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 }), onClose && (_jsx("button", { className: "govuk-link govuk-body-s govuk-!-margin-0", style: { background: "none", border: "none", padding: 0, cursor: "pointer", color: "#1d70b8" }, onClick: onClose, "aria-label": "Close notification", children: "Close" }))] })] }));
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uktrade/react-component-library",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
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",
@@ -9,6 +9,7 @@ type Props = {
9
9
  children: ReactNode;
10
10
  variant?: "success"; // only supported variant
11
11
  className?: string;
12
+ onClose?: () => void;
12
13
  };
13
14
 
14
15
  export const NotificationBanner = ({
@@ -17,6 +18,7 @@ export const NotificationBanner = ({
17
18
  children,
18
19
  variant,
19
20
  className,
21
+ onClose,
20
22
  }: Props) => {
21
23
  const bannerClass = clsx(
22
24
  "govuk-notification-banner",
@@ -46,6 +48,16 @@ export const NotificationBanner = ({
46
48
  </h3>
47
49
  )}
48
50
  <p className="govuk-body">{children}</p>
51
+ {onClose && (
52
+ <button
53
+ className="govuk-link govuk-body-s govuk-!-margin-0"
54
+ style={{ background: "none", border: "none", padding: 0, cursor: "pointer", color: "#1d70b8" }}
55
+ onClick={onClose}
56
+ aria-label="Close notification"
57
+ >
58
+ Close
59
+ </button>
60
+ )}
49
61
  </div>
50
62
  </div>
51
63
  );