Sha256: d4f55bc9b31ad9e98e5af3fe84641caf3d0b35eccbe7fdfe2d8fa490fd6248c1

Contents?: true

Size: 1.38 KB

Versions: 4

Compression:

Stored size: 1.38 KB

Contents

<%
  heading ||= nil
  items ||= nil
  sub_heading_level ||= 3
  two_column_layout ||= false
  local_assigns ||= nil
  data_attributes ||= nil

  ul_classes = %w[gem-c-cards__list]
  ul_classes << 'gem-c-cards__list--two-column-desktop' if two_column_layout

  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
%>
<% if items.present? %>
  <div class="gem-c-cards">
    <% if heading %>
      <%= content_tag(shared_helper.get_heading_level, class: "gem-c-cards__heading govuk-heading-m") do %>
        <%= heading %>
      <% end %>
    <% end %>    

    <%= content_tag('ul', class: ul_classes) do %>
      <%
        items.each do |item|
        link = item[:link]

        if !link[:path].present?
          raise ArgumentError, "The cards component requires a href for all the links"
        end
      %>
        <li class="gem-c-cards__list-item">
          <%= content_tag("h#{sub_heading_level}", class: "gem-c-cards__sub-heading govuk-heading-s") do %>
            <%= 
              link_to link[:text], link[:path], 
              class: "govuk-link gem-c-cards__link", 
              data: link[:data_attributes] 
            %>
          <% end %>
          <% if item[:description] %>
            <p class="govuk-body gem-c-cards__description"><%= item[:description] %></p>
          <% end %>
        </li>
      <% end %>
    <% end %>
  </div>
<% end %>

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
govuk_publishing_components-29.1.0 app/views/govuk_publishing_components/components/_cards.html.erb
govuk_publishing_components-29.0.1 app/views/govuk_publishing_components/components/_cards.html.erb
govuk_publishing_components-29.0.0 app/views/govuk_publishing_components/components/_cards.html.erb
govuk_publishing_components-28.9.2 app/views/govuk_publishing_components/components/_cards.html.erb