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

Make it possible to exclude link from header navigation item #1921

Merged
merged 3 commits into from
Sep 3, 2020

Conversation

hannalaakso
Copy link
Member

@hannalaakso hannalaakso commented Aug 18, 2020

This PR:

  • makes rendering the link in the header navigation item conditional on item.href being set
  • adds tests to check that item.text and item.html can render a navigation item without a link

We would expect this to be mainly useful for rendering a form for instance for adding a log out button. The team would need to manually style any enclosed form elements or buttons.

I considered not allowing this behaviour for item.text as it seems unlikely you'd want to omit the link when passing through simple text content. However I decided against in order to keep the API simpler, the fork in logic would require documentation under navigation.item.href eg.

Both href and text attributes for navigation items need to be provided to create an item. Using html attribute does not require href to create an item.

But happy to re-consider this.

Fixes #1573

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1921 August 18, 2020 18:40 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1921 August 18, 2020 18:42 Inactive
src/govuk/components/header/template.test.js Outdated Show resolved Hide resolved
src/govuk/components/header/template.test.js Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
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.
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1921 September 2, 2020 17:53 Inactive
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Header Component - Custom HTML option for links
4 participants