Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update header styles so that .nhsuk-header__search-no-nav class is no longer needed #1046

Merged
merged 4 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# NHS.UK frontend Changelog

## Unreleased

:wrench: **Fixes**

- Update header styles so that `.nhsuk-header__search-no-nav` class is no longer needed when header contains a search field but no navigation ([PR 1046](https://github.com/nhsuk/nhsuk-frontend/pull/1046))

## 9.0.1 - 9 October 2024

:wrench: **Fixes**
Expand Down
7 changes: 2 additions & 5 deletions packages/components/header/_header-transactional.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
*/

.nhsuk-header__transactional-service-name {
margin-bottom: -(nhsuk-spacing(1));
padding-left: nhsuk-spacing(3);
padding-top: 3px;

@include mq($until: tablet) {
padding-bottom: nhsuk-spacing(3);
}
padding-top: 2px;

@include mq($until: tablet) {
padding-left: 0;
Expand Down
7 changes: 7 additions & 0 deletions packages/components/header/_header-white.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
background-color: $color_nhsuk-blue;
}

.nhsuk-navigation {
.nhsuk-header__navigation-list {
border-top: none;
}
}

.nhsuk-logo {
.nhsuk-logo__background {
fill: $color_nhsuk-blue;
Expand Down Expand Up @@ -100,6 +106,7 @@
.nhsuk-navigation-container {
background-color: $color_nhsuk-white;
}

.nhsuk-navigation {
background-color: $color_nhsuk-white;

Expand Down
22 changes: 10 additions & 12 deletions packages/components/header/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@
@include govuk-width-container;
padding: 20px 0;

@include mq($until: tablet) {
padding-bottom: 0;
}

@include mq($from: tablet) {
border-bottom: 1px solid $color_transparent_nhsuk-white-20;
display: flex;
justify-content: space-between;
}
Expand Down Expand Up @@ -113,9 +108,6 @@
.nhsuk-header__logo--only {
max-width: 100%;

@include mq($until: tablet) {
padding-bottom: nhsuk-spacing(3);
}
@include mq($from: tablet) {
.nhsuk-header__link--service {
align-items: center;
Expand Down Expand Up @@ -155,10 +147,6 @@
}
}

.nhsuk-header__search-no-nav {
padding-bottom: nhsuk-spacing(3);
}

.nhsuk-header__search-form {
height: 100%;
overflow: visible;
Expand Down Expand Up @@ -487,6 +475,10 @@
.nhsuk-navigation-container {
@include print-hide();
position: relative;

@include mq($until: tablet) {
margin-top: -20px;
}
}

// ul of hidden nav
Expand Down Expand Up @@ -537,6 +529,12 @@
}
}

.nhsuk-header__navigation-list {
@include mq($from: tablet) {
border-top: 1px solid $color_transparent_nhsuk-white-20;
}
}

.nhsuk-header__navigation-list--left-aligned {
@include mq($from: desktop) {
justify-content: initial;
Expand Down
178 changes: 56 additions & 122 deletions packages/components/header/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
{%- if params.organisation and params.organisation.name %} nhsuk-header--organisation{% endif %}
{%- if params.classes %} {{ params.classes }}{% endif %}" role="banner"
{{- nhsukAttributes(params.attributes) }}>

<div class="nhsuk-header__container">
<div class="nhsuk-header__logo
<div class="nhsuk-header__logo
{%- if showNav == "false" and showSearch == "false" and params.transactionalService %} nhsuk-header__transactional--logo{% endif %}
{%- if showNav == "false" and showSearch == "false" and not params.transactionalService %} nhsuk-header__logo--only{% endif %}">
{%- if params.organisation %}
Expand All @@ -42,128 +42,62 @@
</a>
{%- endif %}
</div>


{%- if showNav == "false" and showSearch == "false"%}

{%- if params.transactionalService%}
<div class="nhsuk-header__transactional-service-name">
<a class="nhsuk-header__transactional-service-name--link" href="{% if params.transactionalService.href %}{{ params.transactionalService.href }}{% else %}/{% endif %}">{{ params.transactionalService.name }}</a>
</div>

{%- endif %}

</div>{# close nhsuk-header__container #}


{% endif -%}

{% if showNav == "true" and params.primaryLinks and showSearch == "true" %}

<div class="nhsuk-header__content" id="content-header">
<div class="nhsuk-header__search">
<div class="nhsuk-header__search-wrap" id="wrap-search">
<form class="nhsuk-header__search-form" id="search" action="{{ params.searchAction if params.searchAction else 'https://www.nhs.uk/search/' }}" method="get" role="search">
<label class="nhsuk-u-visually-hidden" for="search-field">Search the NHS website</label>
<input class="nhsuk-search__input" id="search-field" name="{{ params.searchInputName if params.searchInputName else "search-field" }}" type="search" placeholder="Search" autocomplete="off" >
<button class="nhsuk-search__submit" type="submit">
<svg class="nhsuk-icon nhsuk-icon__search" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M19.71 18.29l-4.11-4.1a7 7 0 1 0-1.41 1.41l4.1 4.11a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zM5 10a5 5 0 1 1 5 5 5 5 0 0 1-5-5z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Search</span>
</button>
</form>
</div>
</div>
</div>

</div>{# close nhsuk-header__container #}
<div class="nhsuk-navigation-container">
<nav class="nhsuk-navigation" id="header-navigation" role="navigation" aria-label="Primary navigation">
<ul class="nhsuk-header__navigation-list {%- if params.primaryLinks.length < 4 %} nhsuk-header__navigation-list--left-aligned{% endif %}">
{%- for item in params.primaryLinks %}
<li class="nhsuk-header__navigation-item {%- if item.classes %} {{ item.classes }}{% endif %}" {{- nhsukAttributes(item.attributes) }}>
<a class="nhsuk-header__navigation-link" href="{{item.url}}">
{{item.label}}
</a>
</li>
{%- endfor %}
<li class="nhsuk-header__navigation-item nhsuk-header__navigation-item--home">
<a class="nhsuk-header__navigation-link" href="/">
Home
</a>
</li>
<li class="nhsuk-mobile-menu-container">
<button class="nhsuk-header__menu-toggle nhsuk-header__navigation-link" id="toggle-menu" aria-expanded="false">
<span class="nhsuk-u-visually-hidden">Browse</span>
More
<svg class="nhsuk-icon nhsuk-icon__chevron-down" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</button>
</li>
</ul>
</nav>
{%- if showNav == "false" and showSearch == "false"%}
{%- if params.transactionalService%}
<div class="nhsuk-header__transactional-service-name">
<a class="nhsuk-header__transactional-service-name--link" href="{% if params.transactionalService.href %}{{ params.transactionalService.href }}{% else %}/{% endif %}">{{ params.transactionalService.name }}</a>
</div>


{% endif -%}

{% if showSearch == "true" and showNav == "false" %}

<div class="nhsuk-header__content" id="content-header">
<div class="nhsuk-header__search nhsuk-header__search-no-nav">
<div class="nhsuk-header__search-wrap js-show" id="wrap-search">
<form class="nhsuk-header__search-form" id="search" action="{{ params.searchAction if params.searchAction else 'https://www.nhs.uk/search/' }}" method="get" role="search">
<label class="nhsuk-u-visually-hidden" for="search-field">Search the NHS website</label>
<input class="nhsuk-search__input" id="search-field" name="{{ params.searchInputName if params.searchInputName else "search-field" }}" type="search" placeholder="Search" autocomplete="off" >
<button class="nhsuk-search__submit" type="submit">
<svg class="nhsuk-icon nhsuk-icon__search" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M19.71 18.29l-4.11-4.1a7 7 0 1 0-1.41 1.41l4.1 4.11a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zM5 10a5 5 0 1 1 5 5 5 5 0 0 1-5-5z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Search</span>
</button>
</form>
</div>
{%- endif %}
{% endif -%}

{% if showSearch == "true" %}
<div class="nhsuk-header__content" id="content-header">
<div class="nhsuk-header__search">
<div class="nhsuk-header__search-wrap" id="wrap-search">
<form class="nhsuk-header__search-form" id="search" action="{{ params.searchAction if params.searchAction else 'https://www.nhs.uk/search/' }}" method="get" role="search">
<label class="nhsuk-u-visually-hidden" for="search-field">Search the NHS website</label>
<input class="nhsuk-search__input" id="search-field" name="{{ params.searchInputName if params.searchInputName else "search-field" }}" type="search" placeholder="Search" autocomplete="off" >
<button class="nhsuk-search__submit" type="submit">
<svg class="nhsuk-icon nhsuk-icon__search" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M19.71 18.29l-4.11-4.1a7 7 0 1 0-1.41 1.41l4.1 4.11a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zM5 10a5 5 0 1 1 5 5 5 5 0 0 1-5-5z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Search</span>
</button>
</form>
</div>
</div>

</div>{# close nhsuk-header__container #}

{% endif -%}

{% if showNav == "true" and params.primaryLinks and showSearch == "false" %}

</div>{# close nhsuk-header__container #}

<div class="nhsuk-navigation-container">
<nav class="nhsuk-navigation" id="header-navigation" role="navigation" aria-label="Primary navigation">
<ul class="nhsuk-header__navigation-list {%- if params.primaryLinks.length < 4 %} nhsuk-header__navigation-list--left-aligned{% endif %}">
{%- for item in params.primaryLinks %}
<li class="nhsuk-header__navigation-item {%- if item.classes %} {{ item.classes }}{% endif %}" {{- nhsukAttributes(item.attributes) }}>
<a class="nhsuk-header__navigation-link" href="{{item.url}}">
{{item.label}}
</a>
</li>
{%- endfor %}
<li class="nhsuk-header__navigation-item nhsuk-header__navigation-item--home">
<a class="nhsuk-header__navigation-link" href="/">
Home
</a>
</li>
<li class="nhsuk-mobile-menu-container">
<button class="nhsuk-header__menu-toggle nhsuk-header__navigation-link" id="toggle-menu" aria-expanded="false">
<span class="nhsuk-u-visually-hidden">Browse</span>
More
<svg class="nhsuk-icon nhsuk-icon__chevron-down" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</button>
</li>
</ul>
</nav>
</div>
</div>

{% endif -%}

{% endif -%}
</div>{# close nhsuk-header__container #}

{% if showNav == "true" and params.primaryLinks %}
<div class="nhsuk-navigation-container">
<nav class="nhsuk-navigation" id="header-navigation" role="navigation" aria-label="Primary navigation">
<ul class="nhsuk-header__navigation-list {%- if params.primaryLinks.length < 4 %} nhsuk-header__navigation-list--left-aligned{% endif %}">
{%- for item in params.primaryLinks %}
<li class="nhsuk-header__navigation-item {%- if item.classes %} {{ item.classes }}{% endif %}" {{- nhsukAttributes(item.attributes) }}>
<a class="nhsuk-header__navigation-link" href="{{item.url}}">
{{item.label}}
</a>
</li>
{%- endfor %}
<li class="nhsuk-header__navigation-item nhsuk-header__navigation-item--home">
<a class="nhsuk-header__navigation-link" href="/">
Home
</a>
</li>
<li class="nhsuk-mobile-menu-container">
<button class="nhsuk-header__menu-toggle nhsuk-header__navigation-link" id="toggle-menu" aria-expanded="false">
<span class="nhsuk-u-visually-hidden">Browse</span>
More
<svg class="nhsuk-icon nhsuk-icon__chevron-down" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</button>
</li>
</ul>
</nav>
</div>
{% endif -%}
</header>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading