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 34e28e8 commit f040713
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Expand Up @@ -5,11 +5,14 @@
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]
margin_bottom = shared_helper.get_margin_bottom
component_helper.add_class(margin_bottom) if margin_bottom


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

Expand All @@ -19,18 +22,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
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 f040713

Please sign in to comment.