@nice-digital/nds-page-header 4.0.7-alpha.0 → 4.0.7

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 CHANGED
@@ -33,7 +33,7 @@ import { PageHeader } from "@nice-digital/nds-page-header";
33
33
 
34
34
  ##### heading
35
35
 
36
- - Type: `React.node` (required)
36
+ - Type: `React.ReactNode` (required)
37
37
 
38
38
  The main title that is rendered into a H1 with H1 styling.
39
39
 
@@ -53,7 +53,7 @@ Whether to use the `h1-alt` alternative (smaller) heading 1 style.
53
53
 
54
54
  ##### preheading
55
55
 
56
- - Type: `React.node`
56
+ - Type: `React.ReactNode`
57
57
 
58
58
  For occasions when the main title might be too long, a smaller H3 styled `span` that is rendered just above the main title.
59
59
 
@@ -63,7 +63,7 @@ For occasions when the main title might be too long, a smaller H3 styled `span`
63
63
 
64
64
  ##### lead
65
65
 
66
- - Type: `React.node`
66
+ - Type: `React.ReactNode`
67
67
 
68
68
  Lead text serves as a short introduction to the page, rendered as a paragraph.
69
69
 
@@ -76,7 +76,7 @@ Lead text serves as a short introduction to the page, rendered as a paragraph.
76
76
 
77
77
  ##### metadata
78
78
 
79
- - Type: `Array<React.node>`
79
+ - Type: `Array<React.ReactNode>`
80
80
 
81
81
  ```jsx
82
82
  <PageHeader
@@ -92,7 +92,7 @@ Lead text serves as a short introduction to the page, rendered as a paragraph.
92
92
 
93
93
  ##### cta
94
94
 
95
- - Type: `React.node`
95
+ - Type: `React.ReactNode`
96
96
 
97
97
  Room for a button or other call-to-action.
98
98
 
@@ -104,6 +104,62 @@ const CtaButton = <button onclick={()=>false}>
104
104
  <PageHeader heading="Products" cta={CtaButton} />
105
105
  ```
106
106
 
107
+ #### breadcrumbs
108
+
109
+ - Type: `React.ReactNode`
110
+
111
+ Add breadcrumbs here, using the NDS breadcrumb component.
112
+
113
+ ```jsx
114
+ <PageHeader
115
+ heading="Header with breadcrumbs"
116
+ breadcrumbs={
117
+ <Breadcrumbs>
118
+ <Breadcrumb to="https://www.nice.org.uk/">Home</Breadcrumb>
119
+ <Breadcrumb to="https://www.nice.org.uk/guidance">
120
+ NICE guidance
121
+ </Breadcrumb>
122
+ <Breadcrumb>Published</Breadcrumb>
123
+ </Breadcrumbs>
124
+ }
125
+ />
126
+ ```
127
+
128
+ #### description
129
+
130
+ - Type: `React.ReactNode`
131
+
132
+ Add an optional description, which will be displayed below the lead text.
133
+
134
+ ```jsx
135
+ <PageHeader
136
+ heading="Header with description"
137
+ description="I am a description"
138
+ />
139
+ ```
140
+
141
+
142
+ #### variant
143
+
144
+ - Type: "normal" | "fullWidthDark" | "fullWidthLight";
145
+
146
+ The normal variant is the default and can be omitted.
147
+
148
+ The two full width variants span the full width of the page, breaking out of any containers. There is a light and a dark version.
149
+
150
+ ```jsx
151
+ <PageHeader
152
+ heading="I am a full width light header!"
153
+ variant="fullWidthLight"
154
+ />
155
+ ```
156
+
157
+ ```jsx
158
+ <PageHeader
159
+ heading="I am a full width dark header!"
160
+ variant="fullWidthDark"
161
+ />
162
+
107
163
  ### SCSS
108
164
 
109
165
  If you're not using [React](#react), then import the SCSS directly into your application by:
@@ -3,7 +3,6 @@ import "../scss/page-header.scss";
3
3
  export interface PageHeaderProps {
4
4
  [prop: string]: unknown;
5
5
  useAltHeading?: boolean;
6
- isFullWidth?: boolean;
7
6
  preheading?: React.ReactNode;
8
7
  breadcrumbs?: React.ReactNode;
9
8
  heading: React.ReactNode;
@@ -11,5 +10,7 @@ export interface PageHeaderProps {
11
10
  lead?: React.ReactNode;
12
11
  description?: React.ReactNode;
13
12
  cta?: React.ReactNode;
13
+ secondSection?: React.ReactNode;
14
+ variant?: "normal" | "fullWidthDark" | "fullWidthLight";
14
15
  }
15
16
  export declare const PageHeader: React.FC<PageHeaderProps>;
package/es/PageHeader.js CHANGED
@@ -13,12 +13,26 @@ var __rest = (this && this.__rest) || function (s, e) {
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.PageHeader = void 0;
15
15
  const jsx_runtime_1 = require("react/jsx-runtime");
16
+ const nds_grid_1 = require("@nice-digital/nds-grid");
16
17
  require("../scss/page-header.scss");
17
18
  const PageHeader = (props) => {
18
- const { useAltHeading = false, isFullWidth = false, preheading, breadcrumbs, heading, metadata, lead, description, cta } = props, rest = __rest(props, ["useAltHeading", "isFullWidth", "preheading", "breadcrumbs", "heading", "metadata", "lead", "description", "cta"]);
19
+ const { useAltHeading = false, preheading, breadcrumbs, heading, metadata, lead, description, cta, secondSection, variant = "normal" } = props, rest = __rest(props, ["useAltHeading", "preheading", "breadcrumbs", "heading", "metadata", "lead", "description", "cta", "secondSection", "variant"]);
20
+ // Figure out variant
21
+ const isFullWidth = variant === "fullWidthDark" || variant === "fullWidthLight";
22
+ let variantClassname = "";
23
+ switch (variant) {
24
+ case "fullWidthDark":
25
+ variantClassname = "page-header--full-width-dark";
26
+ break;
27
+ case "fullWidthLight":
28
+ variantClassname = "page-header--full-width-light";
29
+ break;
30
+ }
31
+ // Figure out grid
32
+ const mainSectionColumns = secondSection ? 9 : 12;
19
33
  // TODO: Refactor this into some sort of conditional component
20
34
  // e.g. https://dev.to/dailydevtips1/conditional-wrapping-in-react-46o5
21
- const PageHeaderContent = () => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [breadcrumbs && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "page-header__breadcrumbs" }, { children: breadcrumbs }))), (0, jsx_runtime_1.jsxs)("h1", Object.assign({ className: `page-header__heading ${useAltHeading ? "page-header__heading--alt" : ""}` }, { children: [preheading && ((0, jsx_runtime_1.jsx)("span", Object.assign({ className: "page-header__pre-heading" }, { children: preheading }))), heading] })), lead && (0, jsx_runtime_1.jsx)("p", Object.assign({ className: "page-header__lead" }, { children: lead })), description && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "page-header__description" }, { children: description }))), metadata && ((0, jsx_runtime_1.jsx)("ul", Object.assign({ className: "page-header__metadata" }, { children: metadata.map((metadatum, i) => ((0, jsx_runtime_1.jsx)("li", { children: metadatum }, i))) }))), cta && (0, jsx_runtime_1.jsx)("p", Object.assign({ className: "page-header__cta" }, { children: cta }))] }));
22
- return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: `page-header ${isFullWidth ? "page-header--full-width" : ""}`, "data-component": "page-header" }, rest, { children: isFullWidth ? ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "container" }, { children: (0, jsx_runtime_1.jsx)(PageHeaderContent, {}) }))) : ((0, jsx_runtime_1.jsx)(PageHeaderContent, {})) })));
35
+ const PageHeaderContent = () => ((0, jsx_runtime_1.jsxs)(nds_grid_1.Grid, { children: [(0, jsx_runtime_1.jsxs)(nds_grid_1.GridItem, Object.assign({ md: { cols: mainSectionColumns } }, { children: [breadcrumbs && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "page-header__breadcrumbs" }, { children: breadcrumbs }))), (0, jsx_runtime_1.jsxs)("h1", Object.assign({ className: `page-header__heading ${useAltHeading ? "page-header__heading--alt" : ""}` }, { children: [preheading && ((0, jsx_runtime_1.jsx)("span", Object.assign({ className: "page-header__pre-heading" }, { children: preheading }))), heading] })), lead && (0, jsx_runtime_1.jsx)("p", Object.assign({ className: "page-header__lead" }, { children: lead })), description && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "page-header__description" }, { children: description }))), metadata && ((0, jsx_runtime_1.jsx)("ul", Object.assign({ className: "page-header__metadata" }, { children: metadata.map((metadatum, i) => ((0, jsx_runtime_1.jsx)("li", { children: metadatum }, i))) }))), cta && (0, jsx_runtime_1.jsx)("p", Object.assign({ className: "page-header__cta" }, { children: cta }))] })), secondSection ? ((0, jsx_runtime_1.jsx)(nds_grid_1.GridItem, Object.assign({ md: { cols: 3 }, className: "page-header__second-section" }, { children: secondSection }))) : null] }));
36
+ return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: `page-header ${variantClassname}`, "data-component": "page-header" }, rest, { children: isFullWidth ? ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "container" }, { children: (0, jsx_runtime_1.jsx)(PageHeaderContent, {}) }))) : ((0, jsx_runtime_1.jsx)(PageHeaderContent, {})) })));
23
37
  };
24
38
  exports.PageHeader = PageHeader;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-digital/nds-page-header",
3
- "version": "4.0.7-alpha.0",
3
+ "version": "4.0.7",
4
4
  "description": "Page header component for the NICE Design System",
5
5
  "keywords": [
6
6
  "header"
@@ -35,7 +35,7 @@
35
35
  "url": "https://github.com/nice-digital/nice-design-system/issues"
36
36
  },
37
37
  "dependencies": {
38
- "@nice-digital/nds-core": "^4.0.7-alpha.0"
38
+ "@nice-digital/nds-core": "^4.0.7"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "react": "^16 || ^17 || ^18",
@@ -49,5 +49,5 @@
49
49
  "@types/node": "^18.11.9",
50
50
  "typescript": "^4.8.4"
51
51
  },
52
- "gitHead": "8b33a79ecc8fa224223615ebe8647378e97936ad"
52
+ "gitHead": "a7286ee7a795e1b01dc9356fd858bbae2dc5b2b9"
53
53
  }
@@ -31,10 +31,31 @@
31
31
  /// @since 0.4.0
32
32
  .page-header {
33
33
  margin: utils.rem(0 0 spacing.$x-large 0);
34
+ padding: utils.rem(spacing.$large) 0 utils.rem(spacing.$x-large);
34
35
 
35
- &--full-width {
36
+ &--full-width-light {
36
37
  @include layout.fullWidth();
37
- background: colours.$page-header-full-width-background;
38
+ background: colours.$page-header-full-width-light-background;
39
+ }
40
+
41
+ &--full-width-dark {
42
+ @include layout.fullWidth();
43
+ background: colours.$page-header-full-width-dark-background;
44
+
45
+ & * {
46
+ color: colours.$page-header-full-width-dark-background-text-colour;
47
+ }
48
+
49
+ & .breadcrumbs a {
50
+ &:link,
51
+ &:visited,
52
+ &:hover,
53
+ &:active,
54
+ &:focus {
55
+ color: colours.$page-header-full-width-dark-background-text-colour;
56
+ outline-color: colours.$page-header-full-width-dark-background-text-colour;
57
+ }
58
+ }
38
59
  }
39
60
 
40
61
  &__pre-heading {
@@ -94,4 +115,11 @@
94
115
  display: block;
95
116
  margin: 0;
96
117
  }
118
+
119
+ &__second-section {
120
+ @include media-queries.mq($from: md) {
121
+ border-left: 2px solid colours.$page-header-second-section-border-colour;
122
+ padding-left: utils.rem(spacing.$medium);
123
+ }
124
+ }
97
125
  }