Skip to content

Commit 3aef78f

Browse files
anandamaryon1frankierobertopaulrobertlloydcolinrotherham
authored
New header with account section (#1058)
* Remove hardcoded Home link from navigation Removes the link to `"/"` labelled `"Home"`, which is currently hardcoded, and only shows up within the navigation menu on mobile screen widths. This link may not be appropriate for all services, which might not have a homepage, or might use a different path for it. It is also unclear whether having a homepage link is always needed in the navigation if the NHS logo also goes to the homepage. * Add 'Home' to examples * Use single path for NHS logo in header * Update CHANGELOG with updated SVG logo * Update SVG in README for header component * Format header styles with Prettier * Simplify template logic for header component * Allow transactional service name in header alongside navigation and search * Update CHANGELOG.md * Ensure logo in header appears for print media * Refactor header styles * Update header README to account for recent markup changes * Update backstop reference images for header component * Remove home link from header navigation * Change primaryLinks to use href and text instead of url and label (#1083) Change the primaryLinks in the Header component to use `href` and `text` param names instead of `url` and `label`. This improves consistency with other components. The previous param names are still supported for backwards-compatibility (but could be dropped in future) * Fix changelog merge * Fix CHANGELOG * Actually fix changelog * Add changelog item * Add current item indicator for header navigation (#1067) * Add current item indicator for header navigation Add support for indicating the current section, using either `current: true` (if the user is currently on this exact page) or `active: true` (if the user is in that section but not necessarily that exact page). When displayed in the regular view within the blue header, the active links have a light-grey border at the bottom. When displayed in the expanded menu view (eg on mobile), they have a blue border to their left. * Remove custom class * Fix focus style on expanded menu item * Changed current item indicator in white nav to blue * Bump mobile current item indicator to 8px * Set current item in example header-org-white variant * Update backstop images * Fix * Bump mobile nav current idem indicator to 6px * Remove duplicate entries from changelog merge issues * Add entry to changelog * Update backstop images * Remove excess whitespace * Fix: focus link in white header should always have black border --------- Co-authored-by: Paul Robert Lloyd <me+git@paulrobertlloyd.com> * Describe the active and current arguments in header (#1098) This adds the new current and active boolean options for primaryLinks in the header added in #1067 to the documentation in the component README. * Update header navigation label (#1073) * Update header navigation label --------- Co-authored-by: Frankie Roberto <frankie@frankieroberto.com> Co-authored-by: anandamaryon1 <anandamaryon@gmail.com> * Show account information and links in the header (#1063) * Add account links to header * Don’t link to header example with custom HTML * Update backstop references for header component after adding account information to this component * Remove unused backstop images for header component * Add backstop images for header component with account links * tidy header examples * run prettier on header README * Update backstop refernece images * update changelog * edit account header rbac example placeholder * Enable inline styles in tests These are used by by the `header-account-custom-html` test, and I can't see a way to turn off the rule for just that one file... * Style fix * Fix Stylelint issues * Approve minor changes to backstop images * Add layout blocks from GOV.UK Frontend * Fix HTML validation moving `<style>` to head * Make justification of items in header navigation opt-in * Wrap header navigation items when JavaScript is not enabled * Add space between header navigation items using padding This prevents items appearing next to each other in browsers that do not support column-gap on flex containers and removes the need to use gap when calculating breakpoint widths in component JS. * Update backstop images to reflect left aligned navigation in header component * Update changelog to reflect left aligned navigation in header component * Support form submission from header account items * Update CHANGELOG to incluce header account features * Header breaking changes - update nunjucks params (#1109) This updates the params for the Header nunjucks component to no longer differentiate between 'transactional' and non-transactional services, and instead use the same Nunjucks params for both. Previously, for the 'non-transactional' service name type, the logo and the service name would be combined as a single link, but for 'transactional' services they would be separate. To preserve both options, some heuristics are used instead. The service name and logo links are combined in either of these 2 scenarios: * `logo.href` exactly matches `service.href` * `service.href` is specified but `logo.href` is unspecified We’d create some separate guidance on when to combine the logo and service names and when not to, although it will likely be context-dependent and up to teams to decide when to do this based on their research. This also removes the default link target of `/` for the service name and NHS logo. This allows you to have an option where neither the logo or service name are linked - although this would likely not be recommended. Finally, there’s also some smaller changes to the nunjucks params to make them more consistent and logical, such as changing `homeHref` to `logo.href`, `service.name` to `service.text` and `organisation.logoURL` to `logo.src`. ## Full list of Nunjucks changes | Before | After | |-----------------------------|-------------- | | `transactionalService.name` | `service.text` | | `transactionalService.href` | `service.href` | | `service.name` | `service.text` | | `organisation.logoURL` | `logo.src` | | `homeHref` | `logo.href` | ## Update HTML and CSS classes The HTML and CSS classes have been updated to more closely follow the Block Element Modifier (BEM) convention. The previous `nhsuk-header__link` and `nhsuk-header__link--service` have been removed and replaced with: | Element | CSS class | |--------------------------------|-------------------------------------| | Logo container | `.nhsuk-header__logo` | | Logo container (if there’s no service name sibling) | `.nhsuk-header__logo--no-service-name` | | Logo link | `.nhsuk-header__logo__link` | | NHS logo itself | `.nhsuk-logo` | | Service name container | `.nhsuk-header__service-name` | | Service name link | `.nhsuk-header__service-name__link` | --------- Co-authored-by: Colin Rotherham <work@colinr.com> * Ensure templating for header service logo and name is more readable Also fixes some layout issues resulting from updating options for logo and service name * Tidy up syntax for header component examples * Update header backstop images * .nhsuk-header__service-logo is always a link, so don’t need to check for href attribute * Remove conditionally added class previously used to left-align navigation items * fixes from merge, inc. swapping layout.njk to example.njk for header examples * update visual test images * Add word-break to account links and buttons to prevent long words from breaking the header * Update CHANGELOG.md Co-authored-by: Colin Rotherham <work@colinr.com> * Update CHANGELOG.md Co-authored-by: Colin Rotherham <work@colinr.com> * Update CHANGELOG.md Co-authored-by: Colin Rotherham <work@colinr.com> * Update CHANGELOG.md Co-authored-by: Colin Rotherham <work@colinr.com> * Update CHANGELOG.md Co-authored-by: Colin Rotherham <work@colinr.com> * remove self-closing / from img in org header * add overflow wrap to account header item, in addition to links and buttons * fix header primaryLinks href (from url) * tweak account header user icon svg, add file * tweak account header user icon svg * Move header-specific icon styles into header css. Add flex-shrink to user icon in header * Update reference images * Update reference images * Rename .nhs-logo to .nhsuk-header__logo * Rename .nhsuk-organisation-* to .nhsuk-header__organisation-* * Rename .nhsuk-header__navigation-item-active-fallback to .nhsuk-header__navigation-item-current-fallback * Rename .nhsuk-navigation-container to .nhsuk-header__navigation * Rename .nhsuk-navigation to .nhsuk-header__navigation-container * Move .nhsuk-header__drop-down and nhsuk-mobile-menu-container classes to .nhsuk-header__menu namespace * Rename .nhsuk-search__input to .nhsuk-header__search-input and nhsuk-search__submit to .nhsuk-header__search-submit * Rename .nhsuk-header--white-nav to nhsuk-header--white-navigation * Nest contain div element with navigation nav element * Align variables in header.js with updated class names * Re-order header styles * Use hidden attributes instead of classes to manage header menu visibility * Remove .nhsuk-header__search-wrap container * Use generic search element for header search container * Tidy up header component template * Update changelog with new header class names * Move header specific .nhsuk-icon__chevron-down styles into _header.scss * Remove JS enhancements from example * Remove `hidden` from toggle button The parent list item does the hiding for us * Append menu list after `hidden` attribute * Review feedback * Fix tests to use `hidden` attribute * Add support for older browsers * Update reference images * Set defaults before early return * Update reference images * Merge header variant SASS into single file (#1247) Co-authored-by: Colin Rotherham <work@colinr.com> * Update packages/components/header/README.md Co-authored-by: Colin Rotherham <work@colinr.com> * Move header changelog entry to unreleased * Update macro options for new header * Add search placeholder * Update base URL description * Update changelog * Change Health-Z to Health A to Z * Remove leading space * update changelog, remove snippets and point to service manual instead * Update reference images * Remove deleted header paths from test * Ensure focused search input in header renders consistently across breakpoints * Update visual regression tests for header search input * Add visual regression tests for focused header search input * Adjust magnifying glass optical alignment * Prefer input defaults where possible * Remove header search cancel button (WebKit, Blink, IE) * Fix non-rounded account outline in older Safari * Use higher contrast top border on white navigation * Update reference images * Update link colours and styles * Prefer "unlinked" * Fix 1px alignment issue * Override z-index only when necessary * Update reference images * Update changelog * Indentation and formatting * Remove duplicate skip links from examples * Fix alignment of toggle button icon * Replace header `primaryLinks` with `navigation.items` * Support classes and attributes on all `<nav>` elements * Consistent active items in examples * Move justified modifier class to navigation * Remove old reference images * Update reference images --------- Co-authored-by: Frankie Roberto <frankie@frankieroberto.com> Co-authored-by: Paul Robert Lloyd <me+git@paulrobertlloyd.com> Co-authored-by: Paul Robert Lloyd <paulrobertlloyd@users.noreply.github.com> Co-authored-by: Frankie Roberto <frankie.roberto1@nhs.net> Co-authored-by: Colin Rotherham <work@colinr.com>
1 parent 75b4cf2 commit 3aef78f

File tree

114 files changed

+1745
-1507
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+1745
-1507
lines changed

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,44 @@
22

33
## Unreleased
44

5+
:new: **New features**
6+
7+
#### New header with account section
8+
9+
We’ve updated the header component to support account information and links. As part of this work we’ve also made some other improvements to the header, detailed below:
10+
11+
- Show account information and links in the header.
12+
- Show currently active section or page in the navigation.
13+
- Remove hardcoded home link from the navigation.
14+
- Align navigation items to the left by default.
15+
- Update navigation label from ’Primary navigation’ to ‘Menu’, and remove superfluous `role` and `id` attributes.
16+
- Update NHS logo in the header to have higher contrast when focused.
17+
- Refactor CSS classes and BEM naming, use hidden attributes instead of modifier classes, use generic search element.
18+
19+
This was added in [pull request #1058: New header with account section](https://github.com/nhsuk/nhsuk-frontend/pull/1058).
20+
521
:boom: **Breaking changes**
622

723
You must make the following changes when you migrate to this release, or your service might break.
824

25+
#### Update header component params
26+
27+
If you’re using the `header` Nunjucks macro in your service, you must:
28+
29+
- Remove the boolean `showNav`, `showSearch`, `transactional` and `transactionalService` options from the header component as respective parts of the header are shown automatically when `primaryLinks` or `search` options are provided.
30+
- Remove the `.nhsuk-header__navigation-list--left-aligned` modifier class, navigation items are now aligned left by default.
31+
- Replace the `searchAction` option with the nested `search.action` option.
32+
- Replace the `searchInputName` option with the nested `search.name` option.
33+
- Replace the `primaryLinks` option with the nested `navigation.items` option, using `text` and `href` instead of `label` and `url`.
34+
35+
To restore the previous justified alignment, where navigation items appeared evenly spaced out, add the new `nhsuk-header__navigation--justified` modifier class to the nested `navigation.classes` option.
36+
37+
#### Update header component HTML markup
38+
39+
You do not need to do anything if you’re using Nunjucks macros.
40+
41+
If you are not using Nunjucks macros, update your HTML markup using the [header examples in the NHS digital service manual](https://service-manual.nhs.uk/design-system/components/header).
42+
943
#### Rename component `HTML` param to `html`
1044

1145
If you're using the `card`, `details`, `insetText` or `warningCallout` Nunjucks macros, you need to rename the `HTML` param to `html`.

app/_templates/example.njk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
{% extends 'layout.njk' %}
2+
23
{% set htmlAttributes = {"style": "background-color: #f0f4f5;"} %}
4+
5+
{# Turn the skip link off #}
6+
{% block skipLink %}{% endblock %}

app/components/all.njk

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,33 @@
33
{% set title = 'Components' %}
44

55
{% block header %}
6-
{{ skipLink({
7-
"URL": "#maincontent",
8-
"heading": "Skip to main content"
9-
}) }}
10-
116
{{ header({
12-
"showNav": "true",
13-
"showSearch": "true",
14-
"primaryLinks": [
7+
search: true,
8+
navigation: {
9+
items: [
1510
{
16-
"url" : "https://www.nhs.uk/conditions",
17-
"label" : "Health A-Z"
11+
href: "https://www.nhs.uk/conditions",
12+
text: "Health A to Z"
1813
},
1914
{
20-
'url' : 'https://www.nhs.uk/live-well/',
21-
'label' : 'Live Well'
15+
href: 'https://www.nhs.uk/live-well/',
16+
text: 'Live Well'
2217
},
2318
{
24-
'url' : 'https://www.nhs.uk/conditions/social-care-and-support/',
25-
'label' : 'Care and support'
19+
href: 'https://www.nhs.uk/conditions/social-care-and-support/',
20+
text: 'Care and support'
2621
},
2722
{
28-
'url' : 'https://www.nhs.uk/news/',
29-
'label' : 'Health news'
23+
href: 'https://www.nhs.uk/news/',
24+
text: 'Health news'
3025
},
3126
{
32-
'url' : 'https://www.nhs.uk/service-search',
33-
'label' : 'Services near you'
27+
href: 'https://www.nhs.uk/service-search',
28+
text: 'Services near you'
3429
}
3530
]
36-
})
37-
}}
31+
}
32+
}) }}
3833
{% endblock %}
3934

4035
{% block beforeContent %}
@@ -45,7 +40,7 @@
4540
href: "#"
4641
},
4742
{
48-
text: "Health A-Z",
43+
text: "Health A to Z",
4944
href: "#"
5045
}
5146
]
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{% set title = "Header with account (logged in)" %}
2+
{% from "components/header/macro.njk" import header %}
3+
{% extends 'example.njk' %}
4+
5+
{% block main %}
6+
7+
{{ header({
8+
service: {
9+
text: "Manage patients"
10+
},
11+
account: {
12+
items: [
13+
{
14+
href: "#",
15+
text: "florence.nightingale@nhs.net",
16+
icon: true
17+
},
18+
{
19+
action: "#",
20+
text: "Log out"
21+
}
22+
]
23+
},
24+
navigation: {
25+
items: [
26+
{
27+
href: "#",
28+
text: "Home"
29+
},
30+
{
31+
href: "#",
32+
text: "Services"
33+
},
34+
{
35+
href: "#",
36+
text: "Your health"
37+
},
38+
{
39+
href: "#",
40+
text: "Messages"
41+
}, {
42+
href: "#",
43+
text: "Help and support"
44+
}
45+
]
46+
}
47+
}) }}
48+
49+
{% endblock %}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{% set title = "Header with account (logged out)" %}
2+
{% from "components/header/macro.njk" import header %}
3+
{% extends 'example.njk' %}
4+
5+
{% block main %}
6+
7+
{{ header({
8+
service: {
9+
text: "Manage patients"
10+
},
11+
account: {
12+
items: [
13+
{
14+
href: "#",
15+
text: "Log in"
16+
}
17+
]
18+
}
19+
}) }}
20+
21+
{% endblock %}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{% set title = "Header with account (logged in, RBAC)" %}
2+
{% from "components/header/macro.njk" import header %}
3+
{% extends 'example.njk' %}
4+
5+
{% block main %}
6+
7+
{{ header({
8+
service: {
9+
text: "Manage patients"
10+
},
11+
search: {
12+
placeholder: "NHS number, date of birth",
13+
visuallyHiddenLabel: "Search for a user"
14+
},
15+
account: {
16+
items: [
17+
{
18+
href: "#",
19+
text: "Florence Nightingale",
20+
icon: true
21+
},
22+
{
23+
text: "RA Manager, Hull and East Yorkshire Hospitals NHS Trust (RWA)"
24+
},
25+
{
26+
href: "#",
27+
text: "Change role"
28+
},
29+
{
30+
action: "#",
31+
text: "Log out"
32+
}
33+
]
34+
},
35+
navigation: {
36+
items: [
37+
{
38+
href: "#",
39+
text: "Home"
40+
},
41+
{
42+
href: "#",
43+
text: "Create user"
44+
},
45+
{
46+
href: "#",
47+
text: "Find user"
48+
}
49+
]
50+
}
51+
}) }}
52+
53+
{% endblock %}

app/components/header/header-logo.njk

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,5 @@
33
{% extends 'example.njk' %}
44

55
{% block main %}
6-
7-
{{ header({
8-
"showNav": "false",
9-
"showSearch": "false"
10-
})
11-
}}
12-
6+
{{ header() }}
137
{% endblock %}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{% set title = 'Header with navigation' %}
2+
{% from 'components/header/macro.njk' import header %}
3+
{% extends 'example.njk' %}
4+
5+
{% block main %}
6+
7+
{{ header({
8+
navigation: {
9+
classes: "nhsuk-header__navigation--justified",
10+
items: [
11+
{
12+
href: "#",
13+
text: "Health A to Z"
14+
},
15+
{
16+
href: "#",
17+
text: "Live Well"
18+
},
19+
{
20+
href: "#",
21+
text: "Mental health"
22+
},
23+
{
24+
href: "#",
25+
text: "Care and support"
26+
},
27+
{
28+
href: "#",
29+
text: "Pregnancy",
30+
active: true
31+
},
32+
{
33+
href: "#",
34+
text: "NHS services"
35+
}
36+
]
37+
}
38+
}) }}
39+
40+
{% endblock %}

app/components/header/header-navigation.njk

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,35 @@
55
{% block main %}
66

77
{{ header({
8-
"showNav": "true",
9-
"showSearch": "false",
10-
"primaryLinks": [
8+
navigation: {
9+
items: [
1110
{
12-
"url" : "https://www.nhs.uk/conditions",
13-
"label" : "Health A-Z",
14-
"classes": "app-header__navigation-item--current",
15-
"attributes": {
16-
"aria-current": "true"
17-
}
11+
href: "#",
12+
text: "Health A to Z"
1813
},
1914
{
20-
'url' : 'https://www.nhs.uk/live-well/',
21-
'label' : 'Live Well'
15+
href: "#",
16+
text: "Live Well"
2217
},
2318
{
24-
'url' : 'https://www.nhs.uk/mental-health/',
25-
'label' : 'Mental health'
19+
href: "#",
20+
text: "Mental health"
2621
},
2722
{
28-
'url' : 'https://www.nhs.uk/conditions/social-care-and-support/',
29-
'label' : 'Care and support'
23+
href: "#",
24+
text: "Care and support"
3025
},
3126
{
32-
'url' : 'https://www.nhs.uk/pregnancy/',
33-
'label' : 'Pregnancy'
27+
href: "#",
28+
text: "Pregnancy",
29+
active: true
3430
},
3531
{
36-
'url' : 'https://www.nhs.uk/nhs-services/',
37-
'label' : 'NHS services'
32+
href: "#",
33+
text: "NHS services"
3834
}
3935
]
40-
})
41-
}}
36+
}
37+
}) }}
4238

4339
{% endblock %}

0 commit comments

Comments
 (0)