Class: CCS::Components::GovUK::SummaryList
- Defined in:
- lib/ccs/components/govuk/summary_list.rb,
lib/ccs/components/govuk/summary_list/row.rb,
lib/ccs/components/govuk/summary_list/card.rb,
lib/ccs/components/govuk/summary_list/row/key.rb,
lib/ccs/components/govuk/summary_list/row/value.rb,
lib/ccs/components/govuk/summary_list/card/title.rb,
lib/ccs/components/govuk/summary_list/action/link.rb,
lib/ccs/components/govuk/summary_list/row/actions.rb,
lib/ccs/components/govuk/summary_list/card/actions.rb
Overview
GOV.UK Summary list
This is used for generating the summary list component from the GDS - Components - Summary list
Defined Under Namespace
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the summary list
{ class: 'govuk-summary-list' }.freeze
Instance Method Summary collapse
-
#initialize(summary_list_items:, card: nil, **options) ⇒ SummaryList
constructor
A new instance of SummaryList.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Summary list component.
Constructor Details
#initialize(summary_list_items:, card: nil, **options) ⇒ SummaryList
Returns a new instance of SummaryList.
33 34 35 36 37 38 39 40 |
# File 'lib/ccs/components/govuk/summary_list.rb', line 33 def initialize(summary_list_items:, card: nil, **) super(**) any_row_has_actions = summary_list_items.any? { |summary_list_item| summary_list_item.dig(:actions, :items).present? } @summary_list_rows = summary_list_items.map { |summary_list_item| Row.new(any_row_has_actions: any_row_has_actions, card_title: card&.dig(:title, :text), context: @context, **summary_list_item) } @card = Card.new(context: @context, **card) if card end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Summary list component
46 47 48 49 50 51 52 53 54 |
# File 'lib/ccs/components/govuk/summary_list.rb', line 46 def render if card card.render do render_summary_list end else render_summary_list end end |