Sha256: 60367b29e1483d254da144645273be966ba9378ec29b12373e53ac0c8a5c2c30

Contents?: true

Size: 1.99 KB

Versions: 2

Compression:

Stored size: 1.99 KB

Contents

<%
  add_gem_component_stylesheet("step-by-step-nav-related")
  disable_ga4 ||= false
  links ||= []
  pretitle ||= t("components.step_by_step_nav_related.part_of")
  always_display_as_list ||= false
  classes = %w(gem-c-step-nav-related)
  classes << "gem-c-step-nav-related--singular" if links.length == 1
  data = {}
  data[:module] = "ga4-link-tracker" unless disable_ga4
%>
<% if links.any? %>
  <%= tag.div(class: classes, data: data) do %>
    <h2 class="gem-c-step-nav-related__heading">
      <span class="gem-c-step-nav-related__pretitle"><%= pretitle %></span>
      <% if links.length == 1 && !always_display_as_list %>
          <a href="<%= links[0][:href] %>"
            class="govuk-link gem-c-print-link"
            <% unless disable_ga4
              ga4_attributes = {
                event_name: "navigation",
                type: "part of",
                "index_link": "1",
                index_total: "1",
                section: pretitle,
              }.to_json
            %>
              data-ga4-link="<%= ga4_attributes %>"
            <% end %>
          >
            <%= links[0][:text] %>
          </a>
        </h2>
      <% else %>
        </h2>
        <ul class="gem-c-step-nav-related__links">
          <% links.each_with_index do |link, index| %>
            <li class="gem-c-step-nav-related__link-item">
              <a href="<%= link[:href] %>"
                class="govuk-link gem-c-print-link"
                <% unless disable_ga4
                  ga4_attributes = {
                    event_name: "navigation",
                    type: "part of",
                    index_link: (index + 1).to_s,
                    index_total: (links.length).to_s,
                    section: pretitle,
                  }.to_json
                %>
                  data-ga4-link="<%= ga4_attributes %>"
                <% end %>
              >
                <%= link[:text] %>
              </a>
            </li>
          <% end %>
        </ul>
      <% end %>
  <% end %>
<% end %>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
govuk_publishing_components-45.4.0 app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb
govuk_publishing_components-45.3.0 app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb