Skip to content

Commit 89076c8

Browse files
committed
Add inverse styles to the navigation on homepage
1 parent ba93947 commit 89076c8

File tree

6 files changed

+39
-8
lines changed

6 files changed

+39
-8
lines changed

lib/nunjucks/globals.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,20 @@ exports.getMacroOptions = getMacroOptions
167167
* @property {string} href - The URL of the ancestor page
168168
* @property {string} text - The title of the ancestor page
169169
*/
170+
171+
/**
172+
* Helper function that returns true if the current page is the homepage, useful
173+
* for outputting things conditionally.
174+
*
175+
* @returns {boolean} If this is the homepage or not
176+
*/
177+
178+
exports.isHomepage = function () {
179+
const permalink = this.lookup('permalink')
180+
181+
// The homepage always has an empty string as a permalink
182+
if (typeof permalink === 'string' && permalink === '') {
183+
return true
184+
}
185+
return false
186+
}

package-lock.json

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"dependencies": {
3737
"accessible-autocomplete": "^3.0.1",
3838
"clipboard": "^2.0.11",
39-
"govuk-frontend": "^5.10.2",
39+
"govuk-frontend": "github:alphagov/govuk-frontend#718bbb72f",
4040
"iframe-resizer": "^4.4.5",
4141
"lunr": "^2.3.9"
4242
},

src/stylesheets/main.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,21 @@ $app-code-color: #d13118;
8686
@include govuk-width-container(1100px);
8787
}
8888

89+
// Invert the colours of the navigation on the homepage
90+
.govuk-template--rebranded .govuk-service-navigation--inverse {
91+
// Override mobile menu toggles colour
92+
.app-mobile-navigation-section__toggle {
93+
color: govuk-colour("white");
94+
border-top-color: $_govuk-rebrand-border-colour-on-blue-tint-95;
95+
}
96+
97+
// Override link styles in sub menus
98+
.app-mobile-navigation-section__item .govuk-service-navigation__link {
99+
@include govuk-link-style-no-visited-state;
100+
@include govuk-link-style-no-underline;
101+
}
102+
}
103+
89104
.app-main-wrapper {
90105
padding-top: govuk-spacing(3);
91106
padding-bottom: govuk-spacing(4);

views/layouts/layout.njk

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{% extends "_generic.njk" %}
22

33
{% block body %}
4-
{# Only render breadcrumbs on pages that aren't the homepage. This is a bit
5-
hacky, but works as the homepage has an empty string for a permalink. #}
6-
{% if permalink %}
4+
{# Only render breadcrumbs on pages that aren't the homepage. #}
5+
{% if not isHomepage() %}
76
{{ govukBreadcrumbs({
87
classes: "app-width-container",
98
items: getAncestorPages(permalink)

views/partials/_navigation.njk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ service navigation component. #}
3333
{%- endfor %}
3434

3535
{{ govukServiceNavigation({
36+
classes: 'govuk-service-navigation--inverse' if isHomepage(),
3637
navigation: navLinks,
3738
navigationClasses: 'app-service-navigation__wrapper'
3839
}) }}

0 commit comments

Comments
 (0)