Skip to content

Commit

Permalink
Add variant to hide the link underline until it's hovered
Browse files Browse the repository at this point in the history
  • Loading branch information
matthillco committed Dec 20, 2024
1 parent 074e6ab commit 8781639
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
useful summary for people upgrading their application, not a replication
of the commit log.

## Unreleased

* Add option for organisation logos to hide the link underline until it's hovered ([PR #4509](https://github.com/alphagov/govuk_publishing_components/pull/4509))

## 46.4.0

* Add canonical_url value to GA4 page view tracking ([PR #4500](https://github.com/alphagov/govuk_publishing_components/pull/4500))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
}
}

.gem-c-organisation-logo__link-hide-underline:link:not(:hover) {
text-decoration: none;
}

.gem-c-organisation-logo--inverse {
.gem-c-organisation-logo__container {
border-color: govuk-colour("white");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,15 @@ examples:
brand: cabinet-office
crest: 'single-identity'
inline: true
no_underline_until_hover:
description: Remove the underline text-decoration unless hovered. Useful when combined with the `inverse` option.
data:
organisation:
name: Cabinet Office
url: '/government/organisations/cabinet-office'
brand: cabinet-office
crest: 'single-identity'
hide_underline: true
on_a_dark_background:
data:
organisation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class OrganisationLogoHelper
include ActionView::Helpers
include ActionView::Context

attr_reader :name, :url, :crest, :image, :logo_image_src, :logo_image_alt
attr_reader :name, :url, :crest, :image, :logo_image_src, :logo_image_alt, :hide_underline

def initialize(local_assigns)
@name = local_assigns[:organisation][:name]
Expand All @@ -15,6 +15,7 @@ def initialize(local_assigns)
@logo_image_src = local_assigns[:organisation][:image][:url] || false
@logo_image_alt = local_assigns[:organisation][:image][:alt_text] || false
end
@hide_underline = local_assigns[:hide_underline] || false
end

def logo_content
Expand All @@ -28,6 +29,7 @@ def logo_content
def logo_container_class
logo_class = "gem-c-organisation-logo__container"
logo_class = "#{logo_class} gem-c-organisation-logo__link" if url
logo_class = "#{logo_class} gem-c-organisation-logo__link-hide-underline" if hide_underline
logo_class = "#{logo_class} gem-c-organisation-logo__crest gem-c-organisation-logo__crest--#{crest}" if crest
logo_class
end
Expand Down
5 changes: 5 additions & 0 deletions spec/components/organisation_logo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ def component_name
assert_select "a.gem-c-organisation-logo__container--inline"
end

it "renders without a text underline when set" do
render_component(organisation: { name: "Name", url: "/some-link" }, hide_underline: true)
assert_select "a.gem-c-organisation-logo__link-hide-underline"
end

it "renders on a dark background" do
render_component(organisation: { name: "Name", url: "/some-link" }, inverse: true)
assert_select ".gem-c-organisation-logo.gem-c-organisation-logo--inverse"
Expand Down

0 comments on commit 8781639

Please sign in to comment.