Class: CCS::Components::GovUK::SummaryList::Card
- Defined in:
- lib/ccs/components/govuk/summary_list/card.rb,
lib/ccs/components/govuk/summary_list/card/title.rb,
lib/ccs/components/govuk/summary_list/card/actions.rb
Overview
GOV.UK Summary card
This is used for generating the summary cards component from the GDS - Components - Summary cards
Defined Under Namespace
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the summary card
{ class: 'govuk-summary-card' }.freeze
Instance Method Summary collapse
-
#initialize(title: nil, actions: nil, **options) ⇒ Card
constructor
A new instance of Card.
-
#render { ... } ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Summary card.
Constructor Details
#initialize(title: nil, actions: nil, **options) ⇒ Card
Returns a new instance of Card.
33 34 35 36 37 38 |
# File 'lib/ccs/components/govuk/summary_list/card.rb', line 33 def initialize(title: nil, actions: nil, **) super(**) @title = Title.new(context: @context, **title) if title @actions = Actions.new(context: @context, card_title: title&.dig(:text), **actions) if actions end |
Instance Method Details
#render { ... } ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Summary card
46 47 48 49 50 51 52 53 54 |
# File 'lib/ccs/components/govuk/summary_list/card.rb', line 46 def render(&block) tag.div(**@options[:attributes]) do concat(tag.div(class: 'govuk-summary-card__title-wrapper') do concat(title.render) if title concat(actions.render) if actions end) concat(tag.div(class: 'govuk-summary-card__content', &block)) end end |