Skip to content

Commit

Permalink
Merge pull request #894 from alphagov/custom-org-logos
Browse files Browse the repository at this point in the history
Add support for custom organisation logos
  • Loading branch information
fofr authored Feb 16, 2017
2 parents 07c2bcf + 5dd0717 commit 1b6a884
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
10 changes: 6 additions & 4 deletions app/assets/stylesheets/govuk-component/_organisation-logo.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Default logo corresponds with the "medium stacked" Whitehall equivalent
.govuk-organisation-logo {
// Variable defined in frontend toolkit
// scss-lint:disable NameFormat
font-family: $Helvetica-Regular;
// scss-lint:enable NameFormat
font-family: $helvetica-regular;
font-size: 13px;
line-height: (15 / 13);
font-weight: 400;
Expand All @@ -25,6 +22,11 @@
direction: ltr;
}

// Scale images on smaller viewports
.logo-image {
max-width: 100%;
}

.logo-with-crest {
// Default brand colour
border-left: 2px solid $black;
Expand Down
19 changes: 19 additions & 0 deletions app/views/govuk_component/docs/organisation_logo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ description: "Organisation text with crest and branded border colour"
body: |
Organisation name must be provided with pre-formatted line breaks.
These cannot be inferred from the name alone.
Alternatively a custom organisation logo can be provided as an image.
fixtures:
default:
organisation:
Expand Down Expand Up @@ -91,3 +93,20 @@ fixtures:
url: '/government/organisations/treasury-solicitor-s-department'
brand: 'attorney-generals-office'
crest: 'org'
land_registry:
organisation:
name: 'Land Registry'
url: '/government/organisations/land-registry'
brand: 'department-for-business-innovation-skills'
crest: null
image:
url: 'https://assets.publishing.service.gov.uk/government/uploads/system/uploads/organisation/logo/69/LR_logo_265.png'
alt_text: 'Land Registry'
hm_prison_service:
organisation:
name: 'HM Prison Service'
url: '/government/organisations/hm-prison-service'
brand: 'ministry-of-justice'
image:
url: 'https://assets.publishing.service.gov.uk/government/uploads/system/uploads/organisation/logo/321/HMPS.jpg'
alt_text: 'HM Prison Service'
10 changes: 9 additions & 1 deletion app/views/govuk_component/organisation_logo.raw.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@
<div class="<%= logo_container_class %>">
<% end %>

<span><%= raw organisation[:name] %></span>
<% if organisation[:image] %>
<img
class="logo-image"
src="<%= organisation[:image][:url] %>"
<% if organisation[:image][:alt_text] %>alt="<%= organisation[:image][:alt_text] %>"<% end %>
/>
<% else %>
<span><%= raw organisation[:name] %></span>
<% end %>

<% if organisation[:url] %>
</a>
Expand Down
5 changes: 5 additions & 0 deletions test/govuk_component/organisation_logo_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ def component_name
render_component(organisation: { name: "Crested", crest: "single-identity" })
assert_select ".logo-container.logo-with-crest.crest-single-identity"
end

test "an image is rendered when specified" do
render_component(organisation: { name: "Custom image", image: { url: "url", "alt_text": "alt" } })
assert_select ".logo-container img[src='url'][alt='alt']"
end
end

0 comments on commit 1b6a884

Please sign in to comment.