% add_gem_component_stylesheet("contents-list") underline_links ||= false format_numbers ||= false alternative_line_style ||= false title ||= nil brand ||= false local_assigns[:aria] ||= {} local_assigns[:margin_bottom] ||= 4 cl_helper = GovukPublishingComponents::Presenters::ContentsListHelper.new(local_assigns) brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand) link_classes = %w[gem-c-contents-list__link govuk-link gem-c-force-print-link-styles] link_classes << brand_helper.color_class link_classes << "govuk-link--no-underline" unless underline_links disable_ga4 ||= false ga4_data = { event_name: "navigation", section: t("components.contents_list.contents", locale: :en) || "", type: "contents list", index_total: cl_helper.get_index_total, } unless disable_ga4 component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns) component_helper.add_class("gem-c-contents-list #{brand_helper.brand_class}") component_helper.add_class("gem-c-contents-list--alternative-line-style") if alternative_line_style component_helper.add_class("gem-c-contents-list--custom-title") if title component_helper.add_data_attribute({ module: "ga4-link-tracker" }) unless disable_ga4 component_helper.add_aria_attribute({ label: t("components.contents_list.contents") }) unless local_assigns[:aria][:label] title_fallback = t("components.contents_list.contents", locale: I18n.locale, fallback: false, default: "en") %> <% if cl_helper.contents.any? %> <%= tag.nav(**component_helper.all_attributes) do %> <%= content_tag( :h2, {class: "gem-c-contents-list__title"}.merge( title_fallback == "en" ? {:lang => "en",} : {} ) ) do %> <%= title || t("components.contents_list.contents") %> <% end %>