From 142395a19b4bd9cc93dcc387255e32c4303fc021 Mon Sep 17 00:00:00 2001 From: Hanna Laakso Date: Tue, 18 Aug 2020 18:20:11 +0100 Subject: [PATCH 01/22] Make it possible to exclude link from header nav Currently if you don't pass a `href` the navigation item link won't render when using the header macro. This PR changes the navigation link to render without the link wrapper if `item.text` or `item.html` is set but `href` isn't. We would expect this to be mainly useful for rendering a form for instance for adding a log out button. The team will need to style any enclosed form elements or buttons correctly. --- src/govuk/components/header/header.yaml | 21 +++++++++++++++++++- src/govuk/components/header/template.njk | 10 +++++++--- src/govuk/components/header/template.test.js | 14 +++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/govuk/components/header/header.yaml b/src/govuk/components/header/header.yaml index 4cb7c2c87e..1e30bf4dfd 100644 --- a/src/govuk/components/header/header.yaml +++ b/src/govuk/components/header/header.yaml @@ -35,7 +35,7 @@ params: - name: href type: string required: false - description: Url of the navigation item anchor. Both `href` and `text` attributes for navigation items need to be provided to create an item. + description: Url of the navigation item anchor. - name: active type: boolean required: false @@ -233,6 +233,15 @@ examples: - href: '#3' html: Navigation item 3 +- name: navigation item with text without link + data: + serviceName: Service Name + serviceUrl: '/components/header' + navigation: + - text: Navigation item 1 + - text: Navigation item 2 + - text: Navigation item 3 + # Hidden examples are not shown in the review app, but are used for tests and HTML fixtures - name: attributes hidden: true @@ -257,3 +266,13 @@ examples: attributes: data-attribute: my-attribute data-attribute-2: my-attribute-2 +- name: navigation item with html without link + hidden: true + data: + serviceName: Service Name + serviceUrl: '/components/header' + navigation: + - html: Navigation item 1 + active: true + - html: Navigation item 2 + - html: Navigation item 3 diff --git a/src/govuk/components/header/template.njk b/src/govuk/components/header/template.njk index 0b31f33948..f8494664f2 100644 --- a/src/govuk/components/header/template.njk +++ b/src/govuk/components/header/template.njk @@ -64,11 +64,15 @@