Skip to content

Commit

Permalink
Merge pull request #239 from DFE-Digital/move-navigation-link-generat…
Browse files Browse the repository at this point in the history
…ion-to-call

Move navigation entry generation to call method
  • Loading branch information
peteryates authored Aug 19, 2021
2 parents 3815d63 + a8d1b3d commit 9a43ea7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 1 addition & 5 deletions app/components/govuk_component/header_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@
<%= tag.ul(class: navigation_classes, id: "navigation", aria: { label: navigation_label }) do %>
<% navigation_items.each do |item| %>
<%= tag.li(class: item.classes.append(item.active_class), **item.html_attributes) do %>
<% if item.link? %>
<%= link_to(item.text, item.href, class: "govuk-header__link") %>
<% else %>
<%= item.text %>
<% end %>
<%= item %>
<% end %>
<% end %>
<% end %>
Expand Down
8 changes: 8 additions & 0 deletions app/components/govuk_component/header_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ def link?
href.present?
end

def call
if link?
link_to(text, href, class: "govuk-header__link")
else
text
end
end

private

def default_classes
Expand Down

0 comments on commit 9a43ea7

Please sign in to comment.