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

Document list: Add option for equal item spacing #4293

Merged
merged 1 commit into from
Oct 9, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* Update attachment link accessibility guidance ([PR #4278](https://github.com/alphagov/govuk_publishing_components/pull/4278))
* Global print link class ([PR #4275](https://github.com/alphagov/govuk_publishing_components/pull/4275))
* Add component wrapper to devolved nations component ([PR #4281](https://github.com/alphagov/govuk_publishing_components/pull/4281))
* Document list: Add option for equal item spacing ([PR #4293](https://github.com/alphagov/govuk_publishing_components/pull/4293))

## 43.5.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
}
}

.gem-c-document-list--equal-item-spacing {
.gem-c-document-list__item {
margin-top: govuk-spacing(3);
padding-top: govuk-spacing(3);
}
}

.gem-c-document-list__item-title--context {
margin-right: govuk-spacing(2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
component_helper.add_class("gem-c-document-list")
component_helper.add_class("gem-c-document-list--no-top-border") if local_assigns[:remove_top_border]
component_helper.add_class("gem-c-document-list--no-top-border-first-child") if local_assigns[:remove_top_border_from_first_child]
component_helper.add_class("gem-c-document-list--equal-item-spacing") if local_assigns[:equal_item_spacing]
component_helper.add_class(shared_helper.get_margin_bottom)

extra_link_classes = "govuk-link--no-underline" if local_assigns[:remove_underline]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,28 @@ examples:
metadata:
public_updated_at: 2017-07-19 15:01:48
document_type: 'Statistical data set'
with_equal_item_spacing:
description: |
The new search UI has consistently equal spacing between items in the document list, instead
of the original larger bottom padding.
data:
equal_item_spacing: true
items:
- link:
text: 'Become an apprentice'
path: '/become-an-apprentice'
description: 'Becoming an apprentice - what to expect, apprenticeship levels, pay and training, making an application, complaining about an apprenticeship.'
full_size_description: true
- link:
text: 'Become a journeyman'
path: '/become-a-journeyman'
description: 'Becoming a journeyman - what to expect, what to take, pay and training, making an application, complaining about being a journeyman.'
full_size_description: true
- link:
text: 'Become enlightened'
path: '/become-enlightened'
description: 'Becoming enlightened - what to expect, what to take, pay and training, making an application, complaining about being enlightened.'
full_size_description: true
highlighted_result:
description: Highlight one or more of the items in the list. This is used on finders to provide a 'top result' for a search. The `highlight_text` parameter is optional.
data:
Expand Down
16 changes: 16 additions & 0 deletions spec/components/document_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,22 @@ def component_name
assert_select ".gem-c-document-list.gem-c-document-list--no-top-border-first-child"
end

it "renders items with equal spacing" do
render_component(
equal_item_spacing: true,
items: [
{
link: {
text: "Link Title",
path: "/link/path",
},
},
],
)

assert_select ".gem-c-document-list.gem-c-document-list--equal-item-spacing"
end

it "highlights items" do
render_component(
items: [
Expand Down
Loading