Sha256: ff3c7f40e554348a076619526a2db9c6fdfaabebda7e93df710c4bd3e4bc8008

Contents?: true

Size: 1.67 KB

Versions: 12

Compression:

Stored size: 1.67 KB

Contents

<%
  local_assigns[:margin_bottom] ||= 6
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)

  id ||= "default-id-#{SecureRandom.hex(4)}"
  items ||= []
  condensed ||= false
  anchor_navigation ||= false

  accordion_classes = %w(gem-c-accordion)
  accordion_classes << 'gem-c-accordion--condensed' if condensed
  accordion_classes << (shared_helper.get_margin_bottom)

  data_attributes ||= {}
  data_attributes[:module] = 'gem-accordion'
  data_attributes[:anchor_navigation] = anchor_navigation
%>
<% if items.any? %>
  <%= tag.div(class: accordion_classes, id: id, data: data_attributes) do %>
    <% items.each_with_index do |item, i| %>
      <%
        index = i + 1

        section_classes = %w(gem-c-accordion__section)
        section_classes << 'gem-c-accordion__section--expanded' if item[:expanded]

        summary_classes = %w(gem-c-accordion__section-summary govuk-body)
      %>

      <%= tag.section(class: section_classes) do %>
        <div class="gem-c-accordion__section-header">
          <%= content_tag(shared_helper.get_heading_level, class: 'gem-c-accordion__section-heading', id: item[:heading][:id]) do %>
            <%= tag.span(item[:heading][:text], id: "#{id}-heading-#{index}", data: item[:data_attributes], class: 'gem-c-accordion__section-button') %>
          <% end %>
          <%= tag.div(item[:summary][:text], id: "#{id}-summary-#{index}", class: summary_classes) if item[:summary].present? %>
        </div>
        <%= tag.div(item[:content][:html], id: "#{id}-content-#{index}", class: "gem-c-accordion__section-content", 'aria-label': "#{item[:heading][:text]}") %>
      <% end %>
    <% end %>
  <% end %>
<% end %>

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
govuk_publishing_components-24.9.1 app/views/govuk_publishing_components/components/_accordion.html.erb
govuk_publishing_components-24.9.0 app/views/govuk_publishing_components/components/_accordion.html.erb
govuk_publishing_components-24.8.0 app/views/govuk_publishing_components/components/_accordion.html.erb
govuk_publishing_components-24.7.1 app/views/govuk_publishing_components/components/_accordion.html.erb
govuk_publishing_components-24.7.0 app/views/govuk_publishing_components/components/_accordion.html.erb
govuk_publishing_components-24.6.1 app/views/govuk_publishing_components/components/_accordion.html.erb
govuk_publishing_components-24.6.0 app/views/govuk_publishing_components/components/_accordion.html.erb
govuk_publishing_components-24.5.0 app/views/govuk_publishing_components/components/_accordion.html.erb
govuk_publishing_components-24.4.1 app/views/govuk_publishing_components/components/_accordion.html.erb
govuk_publishing_components-24.4.0 app/views/govuk_publishing_components/components/_accordion.html.erb
govuk_publishing_components-24.3.1 app/views/govuk_publishing_components/components/_accordion.html.erb
govuk_publishing_components-24.3.0 app/views/govuk_publishing_components/components/_accordion.html.erb