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

Replace organisation logos with metadata #3310

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
26 changes: 15 additions & 11 deletions app/presenters/html_publication_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class HtmlPublicationPresenter < ContentItemPresenter
include ContentItem::ContentsList
include ContentItem::Political
include ContentItem::NationalApplicability
include ContentItem::Metadata

def isbn
content_item["details"]["isbn"]
Expand All @@ -21,17 +22,6 @@ def format_sub_type
end
end

def last_changed
timestamp = display_date(public_timestamp)

# This assumes that a translation doesn't need the date to come beforehand.
if content_item["details"]["first_published_version"]
"#{I18n.t('content_item.metadata.published')} #{timestamp}"
else
"#{I18n.t('content_item.metadata.updated')} #{timestamp}"
end
end

def organisations
content_item["links"]["organisations"] || []
end
Expand All @@ -44,6 +34,20 @@ def organisation_logo(organisation)
end
end

def publisher_metadata
super.tap do |m|
orgs = organisations.map do |organisation|
view_context.link_to(organisation["title"], organisation["base_path"], class: "govuk-link govuk-link--inverse")
end
m.merge!(from: orgs)

if content_item["details"]["first_published_version"]
m.delete(:see_updates_link)
m.delete(:last_updated)
end
end
end

def full_path(request)
request.base_url + request.path
end
Expand Down
38 changes: 15 additions & 23 deletions app/views/content_items/html_publication.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,23 @@
content_for :simple_header, true
%>

<% if @content_item.organisations %>
<div class="publication-external">
<ul class="organisation-logos">
<% @content_item.organisations.each do |organisation| %>
<% logo_attributes = @content_item.organisation_logo(organisation) %>
<% next unless logo_attributes %>
<li class="organisation-logos__logo">
<%= render 'govuk_publishing_components/components/organisation_logo', logo_attributes %>
</li>
<% end %>
</ul>
</div>
<% end %>

<%= render 'govuk_publishing_components/components/inverse_header', {} do %>
<%= render 'govuk_publishing_components/components/title',
title: @content_item.title,
context: I18n.t("content_item.schema_name.#{@content_item.format_sub_type}", count: 1),
inverse: true,
margin_bottom: 0,
margin_top: 3
%>
<p class="publication-header__last-changed"><%= @content_item.last_changed %></p>
<% end %>
<div class="govuk-!-margin-top-5">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I like the approach of using a utility class from the design system here, avoids adding custom CSS / stylesheet and easy to understand what it does just from looking at the view template 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to provide some further info on this, I noticed a similar issue with spacing when reviewing another PR in government-frontend where we also use utility classes to apply spacing to each view template - #3338

After further investigation I think we can make an improvement in government-frontend by adding a CSS class to the main element as recommend by the page layout section of the design system. I have created a Trello card with further info on this and added it to the backlog - https://trello.com/c/Gawqbmsl/1307-page-layout-in-government-frontend-does-not-follow-the-design-system-guidance

<%= render 'govuk_publishing_components/components/inverse_header', {} do %>
<%= render 'govuk_publishing_components/components/title',
title: @content_item.title,
context: I18n.t("content_item.schema_name.#{@content_item.format_sub_type}", count: 1),
inverse: true,
margin_bottom: 0,
margin_top: 3
%>

<%= render 'govuk_publishing_components/components/metadata', @content_item.publisher_metadata.merge(
inverse: true,
inverse_compress: true
) %>
<% end %>
</div>
<%= render 'shared/history_notice', content_item: @content_item %>
<% if @content_item.withdrawn? %>
<%= render 'govuk_publishing_components/components/notice', @content_item.withdrawal_notice_component %>
Expand Down
Loading