Skip to content

Commit

Permalink
Merge pull request #4284 from alphagov/org-logo-inverse
Browse files Browse the repository at this point in the history
Add inverse option for organisation logo
  • Loading branch information
JamesCGDS authored Oct 16, 2024
2 parents 4af06cf + e674adb commit f40cfab
Show file tree
Hide file tree
Showing 5 changed files with 43 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 inverse option for organisation logo ([PR #4284](https://github.com/alphagov/govuk_publishing_components/pull/4284))

## 44.3.0

* Add variants required for square blue icon share links ([PR #4292](https://github.com/alphagov/govuk_publishing_components/pull/4292))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@
}
}

.gem-c-organisation-logo--inverse {
.gem-c-organisation-logo__container {
border-color: govuk-colour("white");
@include govuk-link-style-inverse;
}

.gem-c-organisation-logo__crest {
filter: brightness(0) invert(1);

&:focus {
filter: none;
}
}
}

@mixin crest($crest, $xpos:0, $ypos:0) {
background: url("govuk_publishing_components/crests/#{$crest}_18px_x2.png") no-repeat $xpos $ypos;
background-size: auto 32px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
organisation ||= {}
heading_level ||= false
inline ||= false
inverse ||= false

# Check if `heading_level` is an appropriate number:
use_heading = [*1..6].include?(heading_level)
Expand All @@ -16,6 +17,7 @@

wrapper_classes = %w[gem-c-organisation-logo]
wrapper_classes << brand_helper.brand_class
wrapper_classes << "gem-c-organisation-logo--inverse" if inverse

container_classes = [
logo_helper.logo_container_class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ examples:
name: "Prime Minister's Office,<br>10 Downing Street"
url: '/government/organisations/prime-ministers-office-10-downing-street'
brand: 'prime-ministers-office-10-downing-street'
crest: 'no10'
crest: 'eo'
office_of_the_advocate_general_for_scotland:
data:
organisation:
Expand Down Expand Up @@ -182,3 +182,13 @@ examples:
brand: cabinet-office
crest: 'single-identity'
inline: true
on_a_dark_background:
data:
organisation:
name: "Prime Minister's Office,<br>10 Downing Street"
url: '/government/organisations/prime-ministers-office-10-downing-street'
brand: 'prime-ministers-office-10-downing-street'
crest: 'eo'
inverse: true
context:
dark_background: true
11 changes: 11 additions & 0 deletions spec/components/organisation_logo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,15 @@ def component_name
render_component(organisation: { name: "Name", url: "/some-link" }, inline: true)
assert_select "a.gem-c-organisation-logo__container--inline"
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"
end

it "does not add the --inverse modifier when the inverse option is omitted" do
render_component(organisation: { name: "Name", url: "/some-link" })
assert_select ".gem-c-organisation-logo.gem-c-organisation-logo"
assert_select ".gem-c-organisation-logo.gem-c-organisation-logo--inverse", false
end
end

0 comments on commit f40cfab

Please sign in to comment.