From 14e010e226e52cfa7f8311177f1f5f4516a1aa20 Mon Sep 17 00:00:00 2001 From: AshGDS <8880610+AshGDS@users.noreply.github.com> Date: Fri, 8 Nov 2024 14:25:07 +0000 Subject: [PATCH] [WIP] Add component wrapper helper to intervention --- .../components/_intervention.html.erb | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/app/views/govuk_publishing_components/components/_intervention.html.erb b/app/views/govuk_publishing_components/components/_intervention.html.erb index bee37664b5..a31fd3d68e 100644 --- a/app/views/govuk_publishing_components/components/_intervention.html.erb +++ b/app/views/govuk_publishing_components/components/_intervention.html.erb @@ -9,15 +9,10 @@ hide ||= false new_tab ||= false - data_attributes = {} suggestion_data_attributes = {} dismiss_data_attributes = {} dismiss_link_data_attributes = {} - data_attributes[:module] = "intervention" - data_attributes["intervention-name"] = name - aria_attributes ||= {} - aria_attributes[:label] = 'Intervention' options = { name: name, @@ -52,18 +47,18 @@ suggestion_link_text = intervention_helper.accessible_text end - section_options = { - class: "gem-c-intervention", - role: "region", aria: aria_attributes, - data: data_attributes, - } - section_options.merge!({ hidden: true }) if hide - dismiss_link_data_attributes[:module] = "#{dismiss_link_data_attributes[:module]} ga4-event-tracker".strip unless disable_ga4 dismiss_link_data_attributes[:ga4_event] = { event_name: "select_content", type: "intervention", section: suggestion_text, action: 'closed' }.to_json unless disable_ga4 + + component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns) + component_helper.add_class("gem-c-intervention") + component_helper.add_role("region") + component_helper.add_aria({ label: "Intervention"}) + component_helper.add_data_attribute({ module: "intervention", intervention_name: name }) + %> <% if intervention_helper.show? %> - <%= tag.section **section_options do %> + <%= tag.section(**component_helper.all_attributes) do %>
<%= tag.span suggestion_text, class: "gem-c-intervention__textwrapper" if suggestion_text %> <% if suggestion_link_text && suggestion_link_url %>