Sha256: 813e71277b7a4aa1e1a44a9265caf08d403b7e58fd59e1189d589049ee4bbae9
Contents?: true
Size: 1.84 KB
Versions: 98
Compression:
Stored size: 1.84 KB
Contents
<% shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns) id ||= "default-id-#{SecureRandom.hex(4)}" items ||= [] condensed ||= false accordion_classes = %w(gem-c-accordion govuk-accordion) accordion_classes << 'govuk-accordion--condensed' if condensed data_attributes ||= {} data_attributes[:module] = 'govuk-accordion' %> <% if items.any? %> <%= tag.div(class: accordion_classes, id: id, data: data_attributes) do %> <% items.each_with_index do |item, i| %> <% # Nunjucks starts a loop on 1 and the client side JavaScript also # adopts this behaviour. To prevent things from breaking, the index # here also need to be increase by one. (Nunjucks is used by GOV.UK # Frontend, which this component is based on.) index = i + 1 item[:data_attributes] ||= nil section_classes = %w(govuk-accordion__section) section_classes << 'govuk-accordion__section--expanded' if item[:expanded] summary_classes = %w(govuk-accordion__section-summary govuk-body) %> <%= tag.div(class: section_classes) do %> <div class="govuk-accordion__section-header"> <%= content_tag( shared_helper.get_heading_level, content_tag('span', item[:heading][:text], class: "govuk-accordion__section-button", id: "#{id}-heading-#{index}", data: item[:data_attributes]), class: 'govuk-accordion__section-heading' ) %> <%= 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: "govuk-accordion__section-content", 'aria-labelledby': "#{id}-heading-#{index}") %> <% end %> <% end %> <% end %> <% end %>
Version data entries
98 entries across 98 versions & 1 rubygems