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

Add documentation and test for govspeak margin #4327

Merged
merged 1 commit into from
Oct 23, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,16 @@ examples:
inverse: true
block: |
<h2>This is a title</h2>
<p>This is some body text with <a href="https://example.com">a link</a>.</p>
<p>This is some body text with <a href="https://example.com">a link</a>.</p>
context:
dark_background: true
with_margin_bottom:
description: The component accepts a number for margin bottom from `0` to `9` (`0px` to `60px`) using the [GOV.UK Frontend spacing scale](https://design-system.service.gov.uk/styles/spacing/#the-responsive-spacing-scale). It defaults to no margin bottom, as spacing below is normally provided by elements within the component.
data:
margin_bottom: 9
block: |
<h2>This is a title</h2>
<p>This is some body text with <a href="https://example.com">a link</a>.</p>
heading_levels:
data:
block: |
Expand Down
15 changes: 15 additions & 0 deletions spec/components/govspeak_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ def component_name
assert_select ".gem-c-govspeak.gem-c-govspeak--inverse h2", text: "inverse"
end

it "applies default margin to the component" do
render_component(
content: "<h2>content</h2>".html_safe,
)
assert_select '.gem-c-govspeak.govuk-\!-margin-bottom-0'
end

it "applies margin to the component" do
render_component(
content: "<h2>content</h2>".html_safe,
margin_bottom: 6,
)
assert_select '.gem-c-govspeak.govuk-\!-margin-bottom-6'
end

it "renders right to left content correctly" do
render_component(
direction: "rtl",
Expand Down
Loading