Skip to content

Commit

Permalink
Merge pull request #3564 from alphagov/replace_title_components_with_…
Browse files Browse the repository at this point in the history
…heading_components

Replace title components with heading components
  • Loading branch information
JamesCGDS authored Feb 19, 2025
2 parents e381c5f + 6a2ff91 commit 3af25ad
Show file tree
Hide file tree
Showing 61 changed files with 215 additions and 119 deletions.
2 changes: 1 addition & 1 deletion app/presenters/call_for_evidence_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class CallForEvidencePresenter < ContentItemPresenter
include ContentItem::Political
include ContentItem::Shareable
include ContentItem::SinglePageNotificationButton
include ContentItem::TitleAndContext
include ContentItem::HeadingAndContext

def opening_date_time
content_item["details"]["opening_date"]
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/case_study_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class CaseStudyPresenter < ContentItemPresenter
include ContentItem::Body
include ContentItem::Metadata
include ContentItem::TitleAndContext
include ContentItem::HeadingAndContext

def image
content_item["details"]["image"]
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/consultation_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ConsultationPresenter < ContentItemPresenter
include ContentItem::Political
include ContentItem::Shareable
include ContentItem::SinglePageNotificationButton
include ContentItem::TitleAndContext
include ContentItem::HeadingAndContext

def opening_date_time
content_item["details"]["opening_date"]
Expand Down
6 changes: 3 additions & 3 deletions app/presenters/contact_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
class ContactPresenter < ContentItemPresenter
include ContentItem::TitleAndContext
include ContentItem::HeadingAndContext
include ContentItem::ContactDetails

def title_and_context
def heading_and_context
super.tap do |t|
t.delete(:average_title_length)
t[:font_size] = "xl"
t.delete(:context)
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
module ContentItem
module TitleAndContext
def title_and_context
module HeadingAndContext
def heading_and_context
{
title:,
text: title,
context: I18n.t("content_item.schema_name.#{document_type}", count: 1),
context_locale: view_context.t_locale_fallback("content_item.schema_name.#{document_type}", count: 1),
average_title_length: "long",
heading_level: 1,
margin_bottom: 8,
font_size: "l",
}
end
end
Expand Down
4 changes: 4 additions & 0 deletions app/presenters/content_item_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ def show_default_breadcrumbs?
true
end

def exclude_main_wrapper_class?
false
end

private

def voting_is_open?
Expand Down
6 changes: 3 additions & 3 deletions app/presenters/corporate_information_page_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class CorporateInformationPagePresenter < ContentItemPresenter
include ContentItem::Body
include ContentItem::ContentsList
include ContentItem::TitleAndContext
include ContentItem::HeadingAndContext
include ContentItem::OrganisationBranding
include ContentItem::CorporateInformationGroups

Expand All @@ -11,9 +11,9 @@ def page_title
page_title
end

def title_and_context
def heading_and_context
super.tap do |t|
t.delete(:average_title_length)
t[:font_size] = "xl"
t.delete(:context)
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/presenters/detailed_guide_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ class DetailedGuidePresenter < ContentItemPresenter
include ContentItem::Metadata
include ContentItem::NationalApplicability
include ContentItem::Political
include ContentItem::TitleAndContext
include ContentItem::HeadingAndContext
include ContentItem::SinglePageNotificationButton

def title_and_context
def heading_and_context
super.tap do |t|
t[:context] = I18n.t("content_item.schema_name.guidance", count: 1)
end
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/document_collection_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class DocumentCollectionPresenter < ContentItemPresenter
include ContentItem::Body
include ContentItem::Metadata
include ContentItem::Political
include ContentItem::TitleAndContext
include ContentItem::HeadingAndContext
include ContentItem::ContentsList
include ContentItem::SinglePageNotificationButton
include DocumentCollection::SignupLink
Expand Down
4 changes: 2 additions & 2 deletions app/presenters/fatality_notice_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class FatalityNoticePresenter < ContentItemPresenter
include ContentItem::Body
include ContentItem::TitleAndContext
include ContentItem::HeadingAndContext
include ContentItem::Metadata

def field_of_operation
Expand All @@ -23,7 +23,7 @@ def important_metadata
end
end

def title_and_context
def heading_and_context
super.tap do |t|
if field_of_operation
t[:context] = I18n.t("fatality_notice.operations_in", location: field_of_operation.try(:title))
Expand Down
8 changes: 4 additions & 4 deletions app/presenters/field_of_operation_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class FieldOfOperationPresenter < ContentItemPresenter
include ContentItem::TitleAndContext
include ContentItem::HeadingAndContext

FatalityNotice = Struct.new(:roll_call_introduction, :casualties, :title, :base_path)

def title_and_context
def heading_and_context
super.tap do |t|
t[:context] = I18n.t("field_of_operation.context")
t[:title] = "#{I18n.t('field_of_operation.title')} #{@content_item['title']}"
t.delete(:average_title_length)
t[:text] = "#{I18n.t('field_of_operation.title')} #{@content_item['title']}"
t[:font_size] = "xl"
end
end

Expand Down
6 changes: 3 additions & 3 deletions app/presenters/fields_of_operation_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
class FieldsOfOperationPresenter < ContentItemPresenter
include ContentItem::TitleAndContext
include ContentItem::HeadingAndContext

def fields_of_operation
content_item.dig("links", "fields_of_operation").map { |field| [field["title"], field["base_path"]] }
end

def title_and_context
def heading_and_context
super.tap do |t|
t[:context] = I18n.t("fields_of_operation.context")
t.delete(:average_title_length)
t[:font_size] = "xl"
end
end
end
4 changes: 4 additions & 0 deletions app/presenters/html_publication_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def full_path(request)
request.base_url + request.path
end

def exclude_main_wrapper_class?
true
end

private

def public_timestamp
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/news_article_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class NewsArticlePresenter < ContentItemPresenter
include ContentItem::Linkable
include ContentItem::Updatable
include ContentItem::Shareable
include ContentItem::TitleAndContext
include ContentItem::HeadingAndContext
include ContentItem::Metadata
include ContentItem::NewsImage
end
4 changes: 2 additions & 2 deletions app/presenters/specialist_document_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ class SpecialistDocumentPresenter < ContentItemPresenter
include ContentItem::Body
include ContentItem::Updatable
include ContentItem::Linkable
include ContentItem::TitleAndContext
include ContentItem::HeadingAndContext
include ContentItem::Metadata
include TypographyHelper
include ContentItem::ContentsList

def title_and_context
def heading_and_context
super.tap do |t|
t.delete(:context)
end
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/speech_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class SpeechPresenter < ContentItemPresenter
include ContentItem::Linkable
include ContentItem::Political
include ContentItem::Updatable
include ContentItem::TitleAndContext
include ContentItem::HeadingAndContext
include ContentItem::Metadata
include ContentItem::NewsImage

Expand Down
2 changes: 1 addition & 1 deletion app/presenters/statistical_data_set_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class StatisticalDataSetPresenter < ContentItemPresenter
include ContentItem::Body
include ContentItem::ContentsList
include ContentItem::TitleAndContext
include ContentItem::HeadingAndContext
include ContentItem::Political
include ContentItem::Metadata
end
2 changes: 1 addition & 1 deletion app/presenters/statistics_announcement_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class StatisticsAnnouncementPresenter < ContentItemPresenter
include ContentItem::Metadata
include ContentItem::NationalStatisticsLogo
include ContentItem::TitleAndContext
include ContentItem::HeadingAndContext
include StatisticsAnnouncementHelper

FORTHCOMING_NOTICE = I18n.t("statistics_announcement.forthcoming").freeze
Expand Down
6 changes: 3 additions & 3 deletions app/presenters/topical_event_about_page_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
class TopicalEventAboutPagePresenter < ContentItemPresenter
include ContentItem::Body
include ContentItem::ContentsList
include ContentItem::TitleAndContext
include ContentItem::HeadingAndContext

def title_and_context
def heading_and_context
super.tap do |t|
t.delete(:average_title_length)
t[:font_size] = "xl"
t.delete(:context)
end
end
Expand Down
6 changes: 3 additions & 3 deletions app/presenters/working_group_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class WorkingGroupPresenter < ContentItemPresenter
include ContentItem::Body
include ContentItem::ContentsList
include ContentItem::TitleAndContext
include ContentItem::HeadingAndContext

def email
content_item["details"]["email"]
Expand All @@ -19,9 +19,9 @@ def policies
content_item["links"]["policies"]
end

def title_and_context
def heading_and_context
super.tap do |t|
t.delete(:average_title_length)
t[:font_size] = "xl"
t.delete(:context)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def sponsoring_organisations
worldwide_organisation&.sponsoring_organisations
end

def exclude_main_wrapper_class?
true
end

private

def show_contents_list?
Expand Down
4 changes: 4 additions & 0 deletions app/presenters/worldwide_office_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def sponsoring_organisations
worldwide_organisation&.sponsoring_organisations
end

def exclude_main_wrapper_class?
true
end

private

def show_contents_list?
Expand Down
4 changes: 4 additions & 0 deletions app/presenters/worldwide_organisation_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ def sponsoring_organisations
content_item.dig("links", "sponsoring_organisations") || []
end

def exclude_main_wrapper_class?
true
end

private

def office(office, contact)
Expand Down
8 changes: 6 additions & 2 deletions app/views/content_items/_body_with_related_links.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render 'govuk_publishing_components/components/title',
title: @content_item.title %>
<%= render 'govuk_publishing_components/components/heading',
text: @content_item.title,
heading_level: 1,
font_size: "xl",
margin_bottom: 8
%>
</div>
</div>
<div class="govuk-grid-row">
Expand Down
4 changes: 2 additions & 2 deletions app/views/content_items/call_for_evidence.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
) %>
<% end %>

<%= render 'shared/email_subscribe_unsubscribe_flash', { title: @content_item.title_and_context[:title] } %>
<%= render 'shared/email_subscribe_unsubscribe_flash', { title: @content_item.heading_and_context[:text] } %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render 'govuk_publishing_components/components/title', @content_item.title_and_context %>
<%= render 'govuk_publishing_components/components/heading', @content_item.heading_and_context %>
</div>
<%= render 'shared/translations' %>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/content_items/case_study.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<% end %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds responsive-top-margin">
<%= render 'govuk_publishing_components/components/title', @content_item.title_and_context %>
<div class="govuk-grid-column-two-thirds">
<%= render 'govuk_publishing_components/components/heading', @content_item.heading_and_context %>
</div>
<%= render 'shared/translations' %>
<div class="govuk-grid-column-two-thirds">
Expand Down
5 changes: 3 additions & 2 deletions app/views/content_items/consultation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
) %>
<% end %>

<%= render 'shared/email_subscribe_unsubscribe_flash', { title: @content_item.title_and_context[:title] } %>
<%= render 'shared/email_subscribe_unsubscribe_flash', { title: @content_item.heading_and_context[:text] } %>


<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render 'govuk_publishing_components/components/title', @content_item.title_and_context %>
<%= render 'govuk_publishing_components/components/heading', @content_item.heading_and_context %>
</div>
<%= render 'shared/translations' %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/contact.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render 'govuk_publishing_components/components/title', @content_item.title_and_context %>
<%= render 'govuk_publishing_components/components/heading', @content_item.heading_and_context %>
</div>
</div>

Expand Down
7 changes: 6 additions & 1 deletion app/views/content_items/corporate_information_page.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
<div class="<%= @content_item.organisation_brand_class %>">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render 'govuk_publishing_components/components/title', title: @content_item.title %>
<%= render 'govuk_publishing_components/components/heading',
text: @content_item.title,
heading_level: 1,
font_size: "xl",
margin_bottom: 8
%>
</div>
<%= render 'shared/translations' %>
<div class="govuk-grid-column-two-thirds">
Expand Down
4 changes: 2 additions & 2 deletions app/views/content_items/detailed_guide.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
) %>
<% end %>

<%= render 'shared/email_subscribe_unsubscribe_flash', { title: @content_item.title_and_context[:title] } %>
<%= render 'shared/email_subscribe_unsubscribe_flash', { title: @content_item.heading_and_context[:text] } %>

<div class="govuk-grid-row gem-print-columns-none">
<div class="govuk-grid-column-two-thirds">
<%= render 'govuk_publishing_components/components/title', @content_item.title_and_context %>
<%= render 'govuk_publishing_components/components/heading', @content_item.heading_and_context %>
</div>
<%= render 'shared/translations' %>
<div class="govuk-grid-column-two-thirds">
Expand Down
Loading

0 comments on commit 3af25ad

Please sign in to comment.