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

Stop using mobile_top_margin with heading component #3489

Merged
merged 4 commits into from
Jan 7, 2025
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
1 change: 0 additions & 1 deletion app/assets/stylesheets/components/_banner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
color: govuk-colour("white");
padding: govuk-spacing(3);
clear: both;
@include responsive-bottom-margin;
@include govuk-font(19);

@include govuk-media-query($from: tablet) {
Expand Down
23 changes: 14 additions & 9 deletions app/views/components/_banner.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
<% add_app_component_stylesheet("banner") %>
<%
add_app_component_stylesheet("banner")

title ||= false
aside ||= false
large_text = !title && !aside
local_assigns[:margin_bottom] ||= 7

component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_class("app-c-banner")
component_helper.add_class("app-c-banner--aside") if aside
component_helper.add_aria_attribute({ label: "Notice" })
component_helper.set_lang("en")
component_helper.add_data_attribute({ module: "ga4-link-tracker" })
component_helper.add_data_attribute({ ga4_track_links_only: "" })
component_helper.add_data_attribute({ ga4_link: { event_name: "navigation", type: "callout" } })
%>
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: is it worth combining the data attribute statements? No worries if you think it's more readable separated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair question, but yeah, I think it's probably more readable like this.

<% content_block = capture do %>
<% if title %>
Expand All @@ -12,15 +23,9 @@
<%= text %>
</p>
<% end %>
<section
class="app-c-banner<% if aside %> app-c-banner--aside<% end %>"
aria-label="Notice"
lang="en"
data-module="ga4-link-tracker"
data-ga4-track-links-only
data-ga4-link="<%= { event_name: "navigation", type: "callout" }.to_json %>">
<%= tag.section(**component_helper.all_attributes) do %>
<%= content_block %>
<% if aside %>
<p class="app-c-banner__desc"><%= aside %></p>
<% end %>
</section>
<% end %>
1 change: 1 addition & 0 deletions app/views/components/docs/banner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ accessibility_criteria: |
- be visually distinct from other content on the page
- have an accessible name that describes the banner as a notice
- have a text contrast ratio higher than 4.5:1 against the background colour to meet [WCAG AA](https://www.w3.org/TR/WCAG20/#visual-audio-contrast-contrast)
uses_component_wrapper_helper: true
examples:
default:
data:
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/_attachments_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<section id="<%= title.parameterize %>">
<%= render 'govuk_publishing_components/components/heading',
text: title,
mobile_top_margin: true
margin_bottom: 4
%>
<% add_gem_component_stylesheet("details") %>
<% attachments_for_components.each do |details| %>
Expand Down
19 changes: 13 additions & 6 deletions app/views/content_items/call_for_evidence.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
attachments_for_components: @content_item.outcome_documents
%>

<%= render 'govuk_publishing_components/components/heading', text: t("call_for_evidence.detail_of_outcome"), mobile_top_margin: true %>
<%= render 'govuk_publishing_components/components/heading', {
text: t("call_for_evidence.detail_of_outcome"),
margin_bottom: 4,
} %>
<div class="call-for-evidence-outcome-detail">
<%= render 'govuk_publishing_components/components/govspeak', {
direction: page_text_direction,
Expand All @@ -61,7 +64,7 @@
<header>
<%= render 'govuk_publishing_components/components/heading', {
heading_level: 2,
mobile_top_margin: true,
margin_bottom: 4,
text: t("call_for_evidence.original_call_for_evidence"),
} %>
</header>
Expand Down Expand Up @@ -108,11 +111,13 @@

<div class="call-for-evidence-description">
<%= render 'govuk_publishing_components/components/heading', {
mobile_top_margin: true,
margin_bottom: 4,
text: t("call_for_evidence.description"),
} %>

<%= render 'govuk_publishing_components/components/govspeak', {} do %>
<%= render 'govuk_publishing_components/components/govspeak', {
margin_bottom: 8,
} do %>
<%= raw(@content_item.govspeak_body[:content]) %>
<% end %>

Expand All @@ -124,8 +129,10 @@

<% if @content_item.ways_to_respond? %>
<div id="ways-to-respond" class="call-for-evidence-ways-to-respond">
<%= render 'govuk_publishing_components/components/heading', text: t("call_for_evidence.ways_to_respond"), mobile_top_margin: true %>

<%= render 'govuk_publishing_components/components/heading', {
text: t("call_for_evidence.ways_to_respond"),
margin_bottom: 4,
} %>
<%= render 'govuk_publishing_components/components/govspeak', {
direction: page_text_direction,
} do %>
Expand Down
17 changes: 11 additions & 6 deletions app/views/content_items/consultation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
title: t("consultation.download_outcome"),
attachments_for_components: @content_item.final_outcome_attachments_for_components
%>
<%= render 'govuk_publishing_components/components/heading', text: t("consultation.detail_of_outcome"), mobile_top_margin: true %>
<%= render 'govuk_publishing_components/components/heading', {
text: t("consultation.detail_of_outcome"),
margin_bottom: 4,
} %>
<div class="consultation-outcome-detail">
<%= render 'govuk_publishing_components/components/govspeak', {
direction: page_text_direction,
Expand All @@ -73,7 +76,7 @@
%>
<% if @content_item.public_feedback_detail %>
<%= render 'govuk_publishing_components/components/heading', {
mobile_top_margin: true,
margin_bottom: 4,
text: t("consultation.detail_of_feedback_received"),
} %>
<div class="consultation-feedback">
Expand All @@ -92,7 +95,7 @@
<%= render 'govuk_publishing_components/components/heading', {
heading_level: 2,
id: "original-consultation-title",
mobile_top_margin: true,
margin_bottom: 4,
text: t("consultation.original_consultation"),
} %>
</header>
Expand Down Expand Up @@ -136,7 +139,7 @@

<div class="consultation-description">
<%= render 'govuk_publishing_components/components/heading', {
mobile_top_margin: true,
margin_bottom: 4,
text: t("consultation.description"),
} %>

Expand All @@ -152,8 +155,10 @@

<% if @content_item.ways_to_respond? %>
<div id="ways-to-respond" class="consultation-ways-to-respond">
<%= render 'govuk_publishing_components/components/heading', text: t("consultation.ways_to_respond"), mobile_top_margin: true %>

<%= render 'govuk_publishing_components/components/heading', {
text: t("consultation.ways_to_respond"),
margin_bottom: 4
} %>
<%= render 'govuk_publishing_components/components/govspeak', {
direction: page_text_direction,
} do %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/publication.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<section id="details">
<%= render "govuk_publishing_components/components/heading", {
text: t("publication.details"),
mobile_top_margin: true,
margin_bottom: 4
} %>

<%= render "govuk_publishing_components/components/govspeak", {
Expand Down
Loading