Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inverse option for organisation logo #4284

Merged
merged 3 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
}
JamesCGDS marked this conversation as resolved.
Show resolved Hide resolved

@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
JamesCGDS marked this conversation as resolved.
Show resolved Hide resolved

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
Loading