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

Simplify template logic for header component #996

Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

:wrench: **Fixes**

- Remove the boolean `showNav`, `showSearch` and `transactional` options from the header component. Respective parts of the header are now shown if values for `primaryLinks`, `search` or `transactionalService` options are provided. Additionally, the `searchAction` option is renamed `search.action` and the `searchInputName` option is renamed `search.name`. Finally, the label, button and placeholder text for the search input can be updated using the new `search.visuallyHiddenLabel`, `search.visuallyHiddenButton` and `search.placeholder` options. ([PR 996](https://github.com/nhsuk/nhsuk-frontend/pull/996))
- 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))
- Update navigation list item padding to vertically align navigation items with width container ([PR 1033](https://github.com/nhsuk/nhsuk-frontend/pull/1033))

Expand Down
5 changes: 1 addition & 4 deletions app/_templates/page.njk
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,8 @@
}) }}

{{ header({
"showNav": "false",
"showSearch": "false",
"homeHref": baseUrl
})
}}
}) }}
{% endblock %}


Expand Down
3 changes: 1 addition & 2 deletions app/components/all.njk
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
}) }}

{{ header({
"showNav": "true",
"showSearch": "true",
"search": true,
"primaryLinks": [
{
"url" : "https://www.nhs.uk/conditions",
Expand Down
6 changes: 1 addition & 5 deletions app/components/header/header-logo.njk
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@

{% block body %}

{{ header({
"showNav": "false",
"showSearch": "false"
})
}}
{{ header() }}

{% endblock %}
2 changes: 0 additions & 2 deletions app/components/header/header-navigation.njk
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
{% block body %}

{{ header({
"showNav": "true",
"showSearch": "false",
"primaryLinks": [
{
"url" : "https://www.nhs.uk/conditions",
Expand Down
7 changes: 4 additions & 3 deletions app/components/header/header-org-white-nav.njk
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
{% block body %}

{{ header({
"showNav": "true",
"showSearch": "true",
"classes": "nhsuk-header--white nhsuk-header--white-nav",
"organisation": {
"name": "Anytown Anyplace",
Expand Down Expand Up @@ -35,7 +33,10 @@
'url' : '#',
'label' : 'Our research'
}
]
],
"search": {
"visuallyHiddenLabel": "Search the Anytown Anyplace Anywhere website"
}
})
}}

Expand Down
7 changes: 4 additions & 3 deletions app/components/header/header-org-white.njk
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
{% block body %}

{{ header({
"showNav": "true",
"showSearch": "true",
"classes": "nhsuk-header--white",
"organisation": {
"name": "Anytown Anyplace",
Expand Down Expand Up @@ -35,7 +33,10 @@
'url' : '#',
'label' : 'Our research'
}
]
],
"search": {
"visuallyHiddenLabel": "Search the Anytown Anyplace Anywhere website"
}
})
}}

Expand Down
7 changes: 4 additions & 3 deletions app/components/header/header-org.njk
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
{% block body %}

{{ header({
"showNav": "true",
"showSearch": "true",
"organisation": {
"name": "Anytown Anyplace",
"split": "Anywhere",
Expand All @@ -34,7 +32,10 @@
'url' : '#',
'label' : 'Our research'
}
]
],
"search": {
"visuallyHiddenLabel": "Search the Anytown Anyplace Anywhere website"
}
})
}}

Expand Down
32 changes: 2 additions & 30 deletions app/components/header/header-search.njk
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,7 @@
{% block body %}

{{ header({
"showNav": "false",
"showSearch": "true",
"primaryLinks": [
{
"url" : "https://www.nhs.uk/conditions",
"label" : "Health A-Z"
},
{
'url' : 'https://www.nhs.uk/live-well/',
'label' : 'Live Well'
},
{
'url' : 'https://www.nhs.uk/mental-health/',
'label' : 'Mental health'
},
{
'url' : 'https://www.nhs.uk/conditions/social-care-and-support/',
'label' : 'Care and support'
},
{
'url' : 'https://www.nhs.uk/pregnancy/',
'label' : 'Pregnancy'
},
{
'url' : 'https://www.nhs.uk/nhs-services/',
'label' : 'NHS services'
}
]
})
}}
"search": true
}) }}

{% endblock %}
5 changes: 3 additions & 2 deletions app/components/header/header-service-name-with-nav.njk
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"service": {
"name": "Digital service manual"
},
"showNav": "true",
"showSearch": "true",
"search": {
"visuallyHiddenLabel": "Search the NHS digital service manual"
},
"primaryLinks": [
{
"url" : "#",
Expand Down
9 changes: 4 additions & 5 deletions app/components/header/header-service-name.njk
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
{% block body %}

{{ header({
"service": {
"name": "Prototype kit"
}
})
}}
"service": {
"name": "Prototype kit"
}
}) }}

{% endblock %}
11 changes: 4 additions & 7 deletions app/components/header/header-transactional-service-name.njk
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
{% block body %}

{{ header({
"transactionalService": {
"name": "Find your NHS number"
},
"showNav": "false",
"showSearch": "false"
})
}}
"transactionalService": {
"name": "Find your NHS number"
}
}) }}

{% endblock %}
58 changes: 28 additions & 30 deletions app/components/header/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,33 @@
{% block body %}

{{ header({
"showNav": "true",
"showSearch": "true",
"primaryLinks": [
{
"url" : "https://www.nhs.uk/conditions",
"label" : "Health A-Z"
},
{
'url' : 'https://www.nhs.uk/live-well/',
'label' : 'Live Well'
},
{
'url' : 'https://www.nhs.uk/mental-health/',
'label' : 'Mental health'
},
{
'url' : 'https://www.nhs.uk/conditions/social-care-and-support/',
'label' : 'Care and support'
},
{
'url' : 'https://www.nhs.uk/pregnancy/',
'label' : 'Pregnancy'
},
{
'url' : 'https://www.nhs.uk/nhs-services/',
'label' : 'NHS services'
}
]
})
}}
"search": true,
"primaryLinks": [
{
"url" : "https://www.nhs.uk/conditions",
"label" : "Health A-Z"
},
{
'url' : 'https://www.nhs.uk/live-well/',
'label' : 'Live Well'
},
{
'url' : 'https://www.nhs.uk/mental-health/',
'label' : 'Mental health'
},
{
'url' : 'https://www.nhs.uk/conditions/social-care-and-support/',
'label' : 'Care and support'
},
{
'url' : 'https://www.nhs.uk/pregnancy/',
'label' : 'Pregnancy'
},
{
'url' : 'https://www.nhs.uk/nhs-services/',
'label' : 'NHS services'
}
]
}) }}

{% endblock %}
Loading