From 5770e1239c69bc4a211b5c8fb4b8b8a2a51d2bea Mon Sep 17 00:00:00 2001 From: AshGDS <8880610+AshGDS@users.noreply.github.com> Date: Tue, 26 Nov 2024 15:43:12 +0000 Subject: [PATCH] Add component wrapper helper to the metadata component --- .../components/_metadata.html.erb | 18 ++++++++++-------- .../components/docs/metadata.yml | 1 + 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/views/govuk_publishing_components/components/_metadata.html.erb b/app/views/govuk_publishing_components/components/_metadata.html.erb index 1493e3d270..f95d8c0183 100644 --- a/app/views/govuk_publishing_components/components/_metadata.html.erb +++ b/app/views/govuk_publishing_components/components/_metadata.html.erb @@ -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 = { @@ -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", { diff --git a/app/views/govuk_publishing_components/components/docs/metadata.yml b/app/views/govuk_publishing_components/components/docs/metadata.yml index 22c24c8cd7..951c1b4ecb 100644 --- a/app/views/govuk_publishing_components/components/docs/metadata.yml +++ b/app/views/govuk_publishing_components/components/docs/metadata.yml @@ -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: