Skip to content

Commit

Permalink
Swap inset text top margin with padding
Browse files Browse the repository at this point in the history
We're trying to standardise the margins at the parent level of components
  • Loading branch information
AshGDS committed Feb 20, 2025
1 parent 2869b4a commit 6ad3f73
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
useful summary for people upgrading their application, not a replication
of the commit log.

## Unreleased

* Swap inset text top margin with padding ([PR #4634](https://github.com/alphagov/govuk_publishing_components/pull/4634))

## 52.0.0

* Make account layout respect `for_static` ([PR #4630](https://github.com/alphagov/govuk_publishing_components/pull/4630))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,15 @@
break-inside: avoid;
}
}

.gem-c-inset-text {
padding-top: govuk-spacing(4);

.govuk-inset-text {
margin-top: 0;
}

@include govuk-media-query($from: tablet) {
padding-top: govuk-spacing(6);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
local_assigns[:margin_bottom] ||= 6

component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_class("gem-c-inset-text govuk-inset-text gem-c-force-print-link-styles-within")
component_helper.add_class("gem-c-inset-text gem-c-force-print-link-styles-within")
component_helper.set_id(id)
%>
<%= tag.div(**component_helper.all_attributes) do %>
<% if defined? text %>
<%= text %>
<% elsif block_given? %>
<%= yield %>
<% end %>
<div class="govuk-inset-text">
<% if defined? text %>
<%= text %>
<% elsif block_given? %>
<%= yield %>
<% end %>
</div>
<% end %>
4 changes: 2 additions & 2 deletions spec/components/inset_text_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def component_name
it "renders inset text" do
render_component(text: "It can take up to 8 weeks to register a lasting power of attorney if there are no mistakes in the application.")

assert_select(".govuk-inset-text.govuk-\\!-margin-bottom-6", text: "It can take up to 8 weeks to register a lasting power of attorney if there are no mistakes in the application.")
assert_select(".gem-c-inset-text.govuk-\\!-margin-bottom-6", text: "It can take up to 8 weeks to register a lasting power of attorney if there are no mistakes in the application.")
end

it "renders a block" do
Expand Down Expand Up @@ -36,6 +36,6 @@ def component_name
margin_bottom: 9,
)

assert_select(".govuk-inset-text.govuk-\\!-margin-bottom-9", text: "margin!")
assert_select(".gem-c-inset-text.govuk-\\!-margin-bottom-9", text: "margin!")
end
end

0 comments on commit 6ad3f73

Please sign in to comment.