Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add component wrapper helper to intervention #4378

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 %>
<p class="govuk-body">
<%= tag.span suggestion_text, class: "gem-c-intervention__textwrapper" if suggestion_text %>
<% if suggestion_link_text && suggestion_link_url %>
Expand Down
Loading