Sha256: 97cfb7d2bd92260bfc78e151ab282d4fe9406203e4a4eb160f942a332053fd75

Contents?: true

Size: 1.52 KB

Versions: 143

Compression:

Stored size: 1.52 KB

Contents

<%
  add_gem_component_stylesheet("error-summary")

  id ||= "error-summary-#{SecureRandom.hex(4)}"
  title ||= false
  description ||= false
  data_attributes ||= {}
  items ||= []
  if items.empty? && !title
    raise ArgumentError, "The error_summary component needs at least one item or a title in order to render."
  end

  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
  component_helper.set_id(id)
  component_helper.add_class("gem-c-error-summary govuk-error-summary")
  component_helper.add_data_attribute({ module: "govuk-error-summary" })
%>

<%= tag.div(**component_helper.all_attributes) do %>
  <%= tag.div(
    role: "alert",
  ) do %>
    <% if title %>
      <h2 class="govuk-error-summary__title">
        <%= title %>
      </h2>
    <% end %>
    <div class="govuk-error-summary__body">
      <% if description %>
        <p><%= description %></p>
      <% end %>
      <% if items.present? %>
        <ul class="govuk-list govuk-error-summary__list">
          <% items.each_with_index do |item, index| %>
            <li class="gem-c-error-summary__list-item">
              <% if item[:href] %>
                <%= link_to item[:text], item[:href], target: item[:target], data: item[:data_attributes] %>
              <% else %>
                <%= tag.span data: item[:data_attributes] do %>
                  <%= item[:text] %>
                <% end %>
              <% end %>
            </li>
          <% end %>
        </ul>
      <% end %>
    </div>
  <% end %>
<% end %>

Version data entries

143 entries across 143 versions & 1 rubygems

Version Path
govuk_publishing_components-51.1.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-51.0.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-50.0.1 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-50.0.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-49.1.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-49.0.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-48.0.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-47.0.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-46.4.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-46.3.1 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-46.3.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-46.2.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-46.1.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-46.0.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-45.10.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-45.9.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-45.8.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-45.7.0 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-45.6.1 app/views/govuk_publishing_components/components/_error_summary.html.erb
govuk_publishing_components-45.6.0 app/views/govuk_publishing_components/components/_error_summary.html.erb