Sha256: bd51a5fed91ff16f77e23cfffd31f0c10e86c742f29a51576d17b5f92eb12b53

Contents?: true

Size: 1.88 KB

Versions: 11

Compression:

Stored size: 1.88 KB

Contents

<%
  add_gem_component_stylesheet("reorderable-list")

  items ||= []
  input_name ||= "ordering"

  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
  component_helper.add_class("gem-c-reorderable-list")
  component_helper.add_data_attribute({ module: "reorderable-list" })
%>

<%= tag.ol(**component_helper.all_attributes) do %>
  <% items.each_with_index do |item, index| %>
    <%= tag.li class: "gem-c-reorderable-list__item" do %>
      <%= tag.div class: "gem-c-reorderable-list__wrapper" do %>
        <%= tag.div class: "gem-c-reorderable-list__content" do %>
          <%= tag.p item[:title], class: "gem-c-reorderable-list__title" %>
          <%= tag.p(item[:description], class: "gem-c-reorderable-list__description") if item[:description].present? %>
        <% end %>
        <%= tag.div class: "gem-c-reorderable-list__actions" do %>
          <% label_text = capture do %>
            Position<span class='govuk-visually-hidden'> for <%= item[:title] %></span>
          <% end %>
          <%= render "govuk_publishing_components/components/input", {
            label: { text: label_text },
            name: "#{input_name}[#{item[:id]}]",
            type: "number",
            value: index + 1,
            width: 2
          } %>
          <%= render "govuk_publishing_components/components/button", {
            text: "Up",
            type: "button",
            aria_label: "Move \"#{item[:title]}\" up",
            classes: "js-reorderable-list-up",
            secondary_solid: true
          } %>
          <%= render "govuk_publishing_components/components/button", {
            text: "Down",
            type: "button",
            aria_label: "Move \"#{item[:title]}\" down",
            classes: "js-reorderable-list-down",
            secondary_solid: true
          } %>
        <% end %>
      <% end %>
    <% end %>
  <% end %>
<% end %>

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
govuk_publishing_components-51.1.0 app/views/govuk_publishing_components/components/_reorderable_list.html.erb
govuk_publishing_components-51.0.0 app/views/govuk_publishing_components/components/_reorderable_list.html.erb
govuk_publishing_components-50.0.1 app/views/govuk_publishing_components/components/_reorderable_list.html.erb
govuk_publishing_components-50.0.0 app/views/govuk_publishing_components/components/_reorderable_list.html.erb
govuk_publishing_components-49.1.0 app/views/govuk_publishing_components/components/_reorderable_list.html.erb
govuk_publishing_components-49.0.0 app/views/govuk_publishing_components/components/_reorderable_list.html.erb
govuk_publishing_components-48.0.0 app/views/govuk_publishing_components/components/_reorderable_list.html.erb
govuk_publishing_components-47.0.0 app/views/govuk_publishing_components/components/_reorderable_list.html.erb
govuk_publishing_components-46.4.0 app/views/govuk_publishing_components/components/_reorderable_list.html.erb
govuk_publishing_components-46.3.1 app/views/govuk_publishing_components/components/_reorderable_list.html.erb
govuk_publishing_components-46.3.0 app/views/govuk_publishing_components/components/_reorderable_list.html.erb