Skip to content

Commit

Permalink
Add component wrapper helper to the metadata component
Browse files Browse the repository at this point in the history
  • Loading branch information
AshGDS committed Dec 2, 2024
1 parent 018060e commit 5770e12
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@
direction_class = " direction-#{direction}" if local_assigns.include?(:direction)

shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
classes = %w(gem-c-metadata)
classes << "direction-#{direction}" if local_assigns.include?(:direction)

if inverse && inverse_compress
classes << "gem-c-metadata--inverse"
elsif inverse
classes << "gem-c-metadata--inverse gem-c-metadata--inverse-padded"
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_class("gem-c-metadata")
component_helper.add_class("direction-#{direction}") if local_assigns.include?(:direction)

if inverse
component_helper.add_class("gem-c-metadata--inverse")
component_helper.add_class("gem-c-metadata--inverse-padded") unless inverse_compress
end

classes << shared_helper.get_margin_bottom if local_assigns[:margin_bottom]
component_helper.add_class(shared_helper.get_margin_bottom) if local_assigns[:margin_bottom]
component_helper.add_data_attribute({ module: "metadata" })

disable_ga4 ||= false
ga4_object = {
Expand All @@ -35,7 +37,7 @@
section: "Top",
}.to_json unless disable_ga4
%>
<%= content_tag :div, class: classes, data: { module: "metadata" } do %>
<%= tag.div(**component_helper.all_attributes) do %>
<% if title.present? %>
<%= content_tag :div, class: "gem-c-metadata__title" do %>
<%= render "govuk_publishing_components/components/heading", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ accessibility_criteria: |
- indicate the initial state of expandable content
- indicate where the state of expandable content has changed
uses_component_wrapper_helper: true
shared_accessibility_criteria:
- link
accessibility_excluded_rules:
Expand Down

0 comments on commit 5770e12

Please sign in to comment.