Skip to content

Commit

Permalink
Use component wrapper in document list component
Browse files Browse the repository at this point in the history
  • Loading branch information
AshGDS committed Mar 20, 2024
1 parent 6ede426 commit 66a0c3e
Show file tree
Hide file tree
Showing 3 changed files with 15 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

* Use component wrapper in document list component ([PR #3933](https://github.com/alphagov/govuk_publishing_components/pull/3933))

## 37.9.0

* Add a new GA4 'focus loss' tracker ([PR #3920](https://github.com/alphagov/govuk_publishing_components/pull/3920))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
items ||= []

classes = %w[gem-c-document-list]
classes << "gem-c-document-list--no-underline" if local_assigns[:remove_underline]
classes << "gem-c-document-list--no-top-border" if local_assigns[:remove_top_border]
classes << "gem-c-document-list--no-top-border-first-child" if local_assigns[:remove_top_border_from_first_child]
classes << shared_helper.get_margin_bottom
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_class("gem-c-document-list")
component_helper.add_class("gem-c-document-list--no-underline") if local_assigns[:remove_underline]
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(shared_helper.get_margin_bottom)


title_with_context_class = " gem-c-document-list__item-title--context"

Expand All @@ -19,18 +21,18 @@
disable_ga4 ||= false
unless disable_ga4
ga4_extra_data ||= {}
ga4_ul_attributes = {
component_helper.add_data_attribute({
module: "ga4-link-tracker",
ga4_track_links_only: "",
ga4_link: {
"event_name": "navigation",
"type": "document list",
}.merge(ga4_extra_data)
}
})
end
%>
<% if items.any? %>
<%= tag.ul(class: classes.join(" "), data: ga4_ul_attributes) do %>
<%= tag.ul(**component_helper.all_attributes) do %>
<% items.each do |item| %>
<% highlight_class = " gem-c-document-list__item--highlight" if item[:highlight] %>
<li class="gem-c-document-list__item <%= brand_helper.brand_class %> <%= highlight_class %>">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ accessibility_criteria: |
* inform the user how many items are in the list
shared_accessibility_criteria:
- link
uses_component_wrapper_helper: true
examples:
default:
data:
Expand Down

0 comments on commit 66a0c3e

Please sign in to comment.