Sha256: 4d3f3feecbf9c3ba67cd532cc6e11698f2263bfd123578bd4d72db7c5a0208c8

Contents?: true

Size: 1.51 KB

Versions: 38

Compression:

Stored size: 1.51 KB

Contents

<%
  add_gem_component_stylesheet("breadcrumbs")

  border ||= false
  breadcrumbs ||= []
  collapse_on_mobile ||= false
  inverse ||= false

  breadcrumb_presenter = GovukPublishingComponents::Presenters::Breadcrumbs.new(breadcrumbs)

  classes = %w[gem-c-breadcrumbs govuk-breadcrumbs]
  classes << "govuk-breadcrumbs--collapse-on-mobile" if collapse_on_mobile
  classes << "gem-c-breadcrumbs--inverse" if inverse
  classes << "gem-c-breadcrumbs--border-bottom" if border == "bottom"

  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
  component_helper.add_class(classes.join(" "))
  component_helper.add_aria_attribute({ label: "Breadcrumb" })
  component_helper.add_data_attribute({ module: "ga4-link-tracker" })
%>

<script type="application/ld+json">
  <%= raw JSON.pretty_generate(breadcrumb_presenter.structured_data) %>
</script>

<%= tag.nav(**component_helper.all_attributes) do %>
  <ol class="govuk-breadcrumbs__list">
    <% breadcrumbs.each_with_index do |crumb, index| %>
      <% breadcrumb = GovukPublishingComponents::Presenters::Breadcrumb.new(crumb, index) %>
        <li class="govuk-breadcrumbs__list-item">
        <% if breadcrumb.is_link? %>
          <%= link_to(
            breadcrumb[:title],
            breadcrumb.path,
            data: breadcrumb.tracking_data(breadcrumbs.length),
            class: "govuk-breadcrumbs__link",
          ) %>
        <% else %>
          <%= breadcrumb[:title] %>
        <% end %>
        </li>
    <% end %>
  </ol>
<% end %>

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
govuk_publishing_components-45.9.0 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
govuk_publishing_components-45.8.0 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
govuk_publishing_components-45.7.0 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
govuk_publishing_components-45.6.1 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
govuk_publishing_components-45.6.0 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
govuk_publishing_components-45.5.0 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
govuk_publishing_components-45.4.1 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
govuk_publishing_components-45.4.0 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
govuk_publishing_components-45.3.0 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
govuk_publishing_components-45.2.0 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
govuk_publishing_components-45.1.0 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
govuk_publishing_components-45.0.0 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
govuk_publishing_components-44.11.0 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
govuk_publishing_components-44.10.0 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
govuk_publishing_components-44.9.1 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
govuk_publishing_components-44.9.0 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
govuk_publishing_components-44.8.0 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
govuk_publishing_components-44.7.1 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
govuk_publishing_components-44.7.0 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
govuk_publishing_components-44.6.0 app/views/govuk_publishing_components/components/_breadcrumbs.html.erb