<% add_gem_component_stylesheet("intervention") name ||= "" dismiss_text ||= false suggestion_link_text ||= false suggestion_link_url ||= false suggestion_text ||= nil 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, dismiss_text: dismiss_text, params: request.params, query_string: request.query_string, suggestion_text: suggestion_text, suggestion_link_text: suggestion_link_text, suggestion_link_url: suggestion_link_url, } intervention_helper = GovukPublishingComponents::Presenters::InterventionHelper.new(options) dismiss_href = intervention_helper.dismiss_link disable_ga4 ||= false suggestion_data_attributes[:module] = "#{suggestion_data_attributes[:module]} ga4-link-tracker".strip unless disable_ga4 suggestion_data_attributes[:ga4_link] = { event_name: "navigation", type: "intervention", section: suggestion_text, index_link: 1, index_total: 1 }.to_json unless disable_ga4 data_attributes[:ga4_intervention_banner] = "" unless disable_ga4 # Added to the parent element for the GA4 pageview object to use suggestion_tag_options = { class: "govuk-link", href: suggestion_link_url, data: suggestion_data_attributes, } if new_tab && (suggestion_link_text && suggestion_link_url) target = "_blank" rel = intervention_helper.security_attr suggestion_tag_options.merge!({ target: target, rel: rel }) 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 %> <% if intervention_helper.show? %> <%= tag.section **section_options do %>

<%= tag.span suggestion_text, class: "gem-c-intervention__textwrapper" if suggestion_text %> <% if suggestion_link_text && suggestion_link_url %> <%= tag.a suggestion_link_text, **suggestion_tag_options %> <% end %>

<% if dismiss_text %> <%= tag.p class: "govuk-body", data: dismiss_data_attributes do %> <%= tag.a class: "govuk-link js-dismiss-link", href: dismiss_href, data: dismiss_link_data_attributes do %> <%= dismiss_text %> <% end %> <% end %> <% end %> <% end %> <% end %>