Sha256: b91527b3d543035a9ed5bbe1f8b957b3ecd3ad2ca5b844f3c2e6c4f6a6e36111

Contents?: true

Size: 1.96 KB

Versions: 8

Compression:

Stored size: 1.96 KB

Contents

require_relative '../../../base'
require_relative '../action/link'

module CCS
  module Components
    module GovUK
      class SummaryList < Base
        class Row < Base
          # = GOV.UK Summary list row actions
          #
          # @!attribute [r] action_links
          #   @return [Array<Action::Link>] An array of the initialised aummary list row action links

          class Actions < Base
            private

            attr_reader :action_links

            public

            # @param items [Array<Hash>] An array of attributes for the action links.
            #                            See {Components::GovUK::SummaryList::Action::Link#initialize Action::Link#initialize} for details of the items in the array.
            # @param options [Hash] options that will be used in customising the HTML
            #
            # @option options [String] :classes additional CSS classes for the summary list row actions HTML

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

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

            # Generates the HTML for the GOV.UK Summary list row actions
            #
            # @return [ActiveSupport::SafeBuffer]

            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

            # The default attributes for the summary list row actions

            DEFAULT_ATTRIBUTES = { class: 'govuk-summary-list__actions' }.freeze
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ccs-frontend_helpers-0.1.2 lib/ccs/components/govuk/summary_list/row/actions.rb
ccs-frontend_helpers-0.1.1 lib/ccs/components/govuk/summary_list/row/actions.rb
ccs-frontend_helpers-0.1.1.rc.1 lib/ccs/components/govuk/summary_list/row/actions.rb
ccs-frontend_helpers-0.1.0.rc.7 lib/ccs/components/govuk/summary_list/row/actions.rb
ccs-frontend_helpers-0.1.0.rc.6 lib/ccs/components/govuk/summary_list/row/actions.rb
ccs-frontend_helpers-0.1.0.rc.5 lib/ccs/components/govuk/summary_list/row/actions.rb
ccs-frontend_helpers-0.1.0.rc.4 lib/ccs/components/govuk/summary_list/row/actions.rb
ccs-frontend_helpers-0.1.0.rc.3 lib/ccs/components/govuk/summary_list/row/actions.rb