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

Options for adding extra vertical spacing between blocks #4296

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
20 changes: 20 additions & 0 deletions app/assets/stylesheets/views/_landing_page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,23 @@
text-decoration: none;
}
}

// Consistent lower margins for top-level blocks
// Self-chaining the class name gives higher
// specificty and avoids the use of !important.
//
// Note the desktop size is hardcoded here as the
// govuk-spacing(x) helper does not include large
// enough sizes.

.app-margin-bottom-responsive.app-margin-bottom-responsive {
margin-bottom: govuk-spacing(6);

@include govuk-media-query($from: tablet) {
margin-bottom: govuk-spacing(8);
}

@include govuk-media-query($from: desktop) {
margin-bottom: 80px;
}
}
2 changes: 1 addition & 1 deletion app/views/landing_page/blocks/_featured.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%
add_view_stylesheet("landing_page/featured")
%>
<div class="featured">
<div class="featured app-margin-bottom-responsive">
<div class="featured__child featured__child--content">
<% block.featured_content.each do |subblock| %>
<%= render_block(subblock) %>
Expand Down
15 changes: 15 additions & 0 deletions app/views/landing_page/blocks/_govspeak.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
<%-
margin_top = block.data["margin_top"]
margin_bot = block.data["margin_bottom"]

classes = ""
classes << "govuk-!-margin-top-#{margin_top} " if margin_top
classes << "govuk-!-margin-bottom-#{margin_bot} " if margin_bot
%>
<% if classes.present? %>
<div class="<%= classes %>">
<% end %>
<%= render "govuk_publishing_components/components/govspeak", { inverse: block.data["inverse"] } do %>
<%= block.data["content"].html_safe %>
<% end %>
<% if classes.present? %>
</div>
<% end %>
1 change: 1 addition & 0 deletions app/views/landing_page/blocks/_hero.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
add_view_stylesheet("landing_page/hero")

hero_classes = %w[app-b-hero]
hero_classes << "app-margin-bottom-responsive"
hero_classes << "app-b-hero--mid-page" if block.data["theme"] == "middle_left"

grid_class = "govuk-grid-column-two-thirds-from-desktop"
Expand Down
2 changes: 2 additions & 0 deletions lib/data/landing_page_content_items/landing_page.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ blocks:
content: <p>Right content!</p>
- type: govspeak
content: <h2>Statistics</h2>
margin_top: 5
margin_bottom: 5
- type: hero
theme: middle_left
image:
Expand Down