@nice-digital/nds-page-header 4.0.6 → 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 +61 -5
- package/es/PageHeader.d.ts +5 -1
- package/es/PageHeader.js +19 -2
- package/package.json +3 -3
- package/scss/page-header.scss +34 -0
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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:
|
package/es/PageHeader.d.ts
CHANGED
|
@@ -4,9 +4,13 @@ export interface PageHeaderProps {
|
|
|
4
4
|
[prop: string]: unknown;
|
|
5
5
|
useAltHeading?: boolean;
|
|
6
6
|
preheading?: React.ReactNode;
|
|
7
|
+
breadcrumbs?: React.ReactNode;
|
|
7
8
|
heading: React.ReactNode;
|
|
8
|
-
lead?: React.ReactNode;
|
|
9
9
|
metadata?: React.ReactNode[];
|
|
10
|
+
lead?: React.ReactNode;
|
|
11
|
+
description?: React.ReactNode;
|
|
10
12
|
cta?: React.ReactNode;
|
|
13
|
+
secondSection?: React.ReactNode;
|
|
14
|
+
variant?: "normal" | "fullWidthDark" | "fullWidthLight";
|
|
11
15
|
}
|
|
12
16
|
export declare const PageHeader: React.FC<PageHeaderProps>;
|
package/es/PageHeader.js
CHANGED
|
@@ -13,9 +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 {
|
|
19
|
-
|
|
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;
|
|
33
|
+
// TODO: Refactor this into some sort of conditional component
|
|
34
|
+
// e.g. https://dev.to/dailydevtips1/conditional-wrapping-in-react-46o5
|
|
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, {})) })));
|
|
20
37
|
};
|
|
21
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.
|
|
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.
|
|
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": "
|
|
52
|
+
"gitHead": "a7286ee7a795e1b01dc9356fd858bbae2dc5b2b9"
|
|
53
53
|
}
|
package/scss/page-header.scss
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
@use '@nice-digital/nds-core/scss/colours';
|
|
6
6
|
@use '@nice-digital/nds-core/scss/glyphs';
|
|
7
|
+
@use '@nice-digital/nds-core/scss/layout';
|
|
7
8
|
@use '@nice-digital/nds-core/scss/media-queries';
|
|
8
9
|
@use '@nice-digital/nds-core/scss/spacing';
|
|
9
10
|
@use '@nice-digital/nds-core/scss/typography';
|
|
@@ -30,6 +31,32 @@
|
|
|
30
31
|
/// @since 0.4.0
|
|
31
32
|
.page-header {
|
|
32
33
|
margin: utils.rem(0 0 spacing.$x-large 0);
|
|
34
|
+
padding: utils.rem(spacing.$large) 0 utils.rem(spacing.$x-large);
|
|
35
|
+
|
|
36
|
+
&--full-width-light {
|
|
37
|
+
@include layout.fullWidth();
|
|
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
|
+
}
|
|
59
|
+
}
|
|
33
60
|
|
|
34
61
|
&__pre-heading {
|
|
35
62
|
@include typography.font-size(h5);
|
|
@@ -88,4 +115,11 @@
|
|
|
88
115
|
display: block;
|
|
89
116
|
margin: 0;
|
|
90
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
|
+
}
|
|
91
125
|
}
|