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

Header: Allow custom (unlinked) content in a navigation item #142

Closed
paulrobertlloyd opened this issue Apr 12, 2021 · 0 comments
Closed

Comments

@paulrobertlloyd
Copy link
Contributor

paulrobertlloyd commented Apr 12, 2021

It’s currently not possible to pass in anything into a navigation item other than a link. With the following params:

<% component.slot(:item, title: 'Navigation item') %>

the following HTML is returned:

<li class="govuk-header__navigation-item">
  <a class="govuk-header__link" href>Navigation item</a>
</li>

A link with an empty href is not the desired – or possibly expected – outcome. What’s needed is a means of providing text only content (which is unlinked without the presence of href). For example:

<% component.slot(:item, title: 'I like apples') %>

would generate the following markup:

<li class="govuk-header__navigation-item">
  I like apples
</li>

Additionally, it would be good if block content could be provided. For example:

<%= component.slot(:item) do %>
  I <em>really</em> like apples
<% end %>

the following markup would be generated:

<li class="govuk-header__navigation-item">
  I <em>really</em> like apples
</li>

For reference, the GDS Nunjucks macro provides the following options for navigation items:

Name Type Description
text string Required. Text for the navigation item. If html is provided, the text argument will be ignored.
html string Required. HTML for the navigation item. If html is provided, the text argument will be ignored.
href string Url of the navigation item anchor.
active boolean Flag to mark the navigation item as active or not.
attributes object HTML attributes (for example data attributes) to add to the navigation item anchor.

Sidenote: The title value ought to be called text. This would not only align it with the GDS Nunjucks macros, but also other components in this gem (where a text param can be overwritten by block content).

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

No branches or pull requests

1 participant