Class: CCS::Components::GovUK::SummaryList::Card::Actions
- Defined in:
- lib/ccs/components/govuk/summary_list/card/actions.rb
Overview
GOV.UK Summary list card actions
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the summary list card actions
{ class: 'govuk-summary-card__actions' }.freeze
Instance Method Summary collapse
-
#initialize(items:, card_title:, **options) ⇒ Actions
constructor
A new instance of Actions.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Summary list card actions.
Constructor Details
#initialize(items:, card_title:, **options) ⇒ Actions
Returns a new instance of Actions.
28 29 30 31 32 |
# File 'lib/ccs/components/govuk/summary_list/card/actions.rb', line 28 def initialize(items:, card_title:, **) super(**) @action_links = items.map { |item| Action::Link.new(context: @context, card_title: card_title, **item) } end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Summary list card actions
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ccs/components/govuk/summary_list/card/actions.rb', line 38 def render if action_links.length == 1 tag.div(class: @options[:attributes][:class]) do action_links.first.render end else tag.ul(class: @options[:attributes][:class]) do action_links.each do |action_link| concat(tag.li(action_link.render, class: 'govuk-summary-card__action')) end end end end |