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 14, 2025
1 parent 49b731c commit c75ce19
Show file tree
Hide file tree
Showing 4 changed files with 25 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))

## 51.2.1

* Fix spacing between govspeak headings and attachment ([PR #4618](https://github.com/alphagov/govuk_publishing_components/pull/4618))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,14 @@
break-inside: avoid;
}
}

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

.gem-c-inset-text {
padding-top: govuk-spacing(4);
@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 c75ce19

Please sign in to comment.