Skip to content

Commit

Permalink
Merge pull request #4660 from alphagov/add-inverse-to-helper
Browse files Browse the repository at this point in the history
Add inverse flag to govuk_styled_links_list helper
  • Loading branch information
leenagupte authored Feb 25, 2025
2 parents d17760e + 877407f commit 27000f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/helpers/link_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def govuk_styled_link(text, path: nil, inverse: false)
"<a href='#{path}' class='#{classes}'>".html_safe + text + "</a>".html_safe
end

def govuk_styled_links_list(links)
links.map { |link| govuk_styled_link(link["title"], path: link["base_path"]) }
def govuk_styled_links_list(links, inverse: false)
links.map { |link| govuk_styled_link(link["title"], path: link["base_path"], inverse:) }
end
end
12 changes: 12 additions & 0 deletions spec/helpers/link_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,17 @@

expect(govuk_styled_links_list(links)).to eq(expected)
end

context "when inverse is true" do
it "returns an array of styled links with the inverse class applied" do
expected = [
"<a href='/' class='govuk-link govuk-link--inverse'>Home</a>",
"<a href='/uk-trade-investment' class='govuk-link govuk-link--inverse'>UK Trade &amp; Investment</a>",
"<a href='/foreign-commonwealth-office' class='govuk-link govuk-link--inverse'>Foreign &amp; Commonwealth Office</a>",
]

expect(govuk_styled_links_list(links, inverse: true)).to eq(expected)
end
end
end
end

0 comments on commit 27000f3

Please sign in to comment.