Skip to content

Commit

Permalink
Adjustments based on PR review
Browse files Browse the repository at this point in the history
- rename navigation_items_label to navigation_aria_label
- move default value for navigation aria label to the layout_header
  template
  • Loading branch information
danacotoran committed Jan 14, 2021
1 parent 8222e19 commit 1c7a339
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
search ||= false
search_left ||= false
navigation_items ||= []
navigation_items_label ||= false
navigation_aria_label ||= "Top level"
remove_bottom_border ||= false
search_left ||= false
width_class = full_width ? "govuk-header__container--full-width" : "govuk-width-container"
Expand All @@ -29,7 +29,7 @@
<%= render "govuk_publishing_components/components/layout_header/search" %>
</div>
<div class="govuk-header__content gem-c-header__content govuk-grid-column-full">
<%= render "govuk_publishing_components/components/layout_header/navigation_items", navigation_items: navigation_items, navigation_items_label: navigation_items_label %>
<%= render "govuk_publishing_components/components/layout_header/navigation_items", navigation_items: navigation_items, navigation_aria_label: navigation_aria_label %>
</div>
</div>
<% else %>
Expand All @@ -38,7 +38,7 @@
<%= render "govuk_publishing_components/components/layout_header/header_logo", environment: environment, product_name: product_name %>
</div>
<div class="govuk-header__content gem-c-header__content">
<%= render "govuk_publishing_components/components/layout_header/navigation_items", navigation_items: navigation_items, navigation_items_label: navigation_items_label %>
<%= render "govuk_publishing_components/components/layout_header/navigation_items", navigation_items: navigation_items, navigation_aria_label: navigation_aria_label %>
</div>
<% if search %>
<div class="govuk-grid-column-one-third gem-c-layout-header__search">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ examples:
description: The navigation has `aria-label="Top level"` by default. This option is here for when the `aria-label` needs to be more descriptive than that.
data:
search_left: true
navigation_items_label: "Departments and policy"
navigation_aria_label: "Departments and policy"
navigation_items:
- text: Departments
href: "item-1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<% navigation_items_label ||= "Top level" %>
<% if navigation_items.any? %>
<button role="button" class="govuk-header__menu-button gem-c-header__menu-button govuk-js-header-toggle" aria-controls="navigation" aria-label="Show or hide Top Level Navigation">Menu</button>
<nav class="gem-c-header__nav" aria-label="<%= navigation_items_label %>">
<%= tag.nav(class: "gem-c-header__nav", 'aria-label': navigation_aria_label ? navigation_aria_label : nil ) do %>
<ul id="navigation" class="govuk-header__navigation govuk-header__navigation--end">
<% navigation_items.each_with_index do |item, index| %>
<li class="govuk-header__navigation-item <%= "govuk-header__navigation-item--active" if item[:active] %>
<%= "govuk-header__navigation-item--collapsed-menu-only" if item[:show_only_in_collapsed_menu] %>">
<%= link_to(
item[:text],
item[:href],
class: 'govuk-header__link',
) %>
</li>
<li class="govuk-header__navigation-item <%= "govuk-header__navigation-item--active" if item[:active] %>
<%= "govuk-header__navigation-item--collapsed-menu-only" if item[:show_only_in_collapsed_menu] %>">
<%= link_to(
item[:text],
item[:href],
class: 'govuk-header__link',
) %>
</li>
<% end %>
</ul>
</nav>
<% end %>
<% end %>
4 changes: 2 additions & 2 deletions spec/components/layout_header_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ def component_name
assert_select ".gem-c-header__nav[aria-label='Top level']"
end

it "renders the header navigation items with custom aria-label when navigation_items_label is specified" do
it "renders the header navigation items with custom aria-label when navigation_aria_label is specified" do
navigation_items = [
{ text: "Foo", href: "/foo", active: true },
{ text: "Bar", href: "/bar" },
{ text: "Hello", href: "/hello", show_only_in_collapsed_menu: true },
]

render_component(environment: "staging", navigation_items: navigation_items, navigation_items_label: "My fancy label")
render_component(environment: "staging", navigation_items: navigation_items, navigation_aria_label: "My fancy label")

assert_select ".gem-c-header__nav[aria-label='My fancy label']"
end
Expand Down

0 comments on commit 1c7a339

Please sign in to comment.