Class: CCS::Components::GovUK::SummaryList::Row::Actions

Inherits:
Base
  • Object
show all
Defined in:
lib/ccs/components/govuk/summary_list/row/actions.rb

Overview

GOV.UK Summary list row actions

Constant Summary collapse

DEFAULT_ATTRIBUTES =

The default attributes for the summary list row actions

{ class: 'govuk-summary-list__actions' }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(items:, card_title: nil, **options) ⇒ Actions

Returns a new instance of Actions.

Parameters:

  • items (Array<Hash>)

    An array of attributes for the action links. See Action::Link#initialize for details of the items in the array.

  • card_title (String) (defaults to: nil)

    the text for the card title

  • options (Hash)

    options that will be used in customising the HTML

Options Hash (**options):

  • :classes (String)

    additional CSS classes for the summary list row actions HTML



28
29
30
31
32
# File 'lib/ccs/components/govuk/summary_list/row/actions.rb', line 28

def initialize(items:, card_title: nil, **options)
  super(**options)

  @action_links = items.map { |item| Action::Link.new(card_title: card_title, context: @context, **item) }
end

Instance Method Details

#renderActiveSupport::SafeBuffer

Generates the HTML for the GOV.UK Summary list row actions

Returns:

  • (ActiveSupport::SafeBuffer)


38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ccs/components/govuk/summary_list/row/actions.rb', line 38

def render
  tag.dd(class: @options[:attributes][:class]) do
    if action_links.length == 1
      action_links.first.render
    else
      tag.ul(class: 'govuk-summary-list__actions-list') do
        action_links.each do |action_link|
          concat(tag.li(action_link.render, class: 'govuk-summary-list__actions-list-item'))
        end
      end
    end
  end
end