Class: DesignSystem::Generic::SummaryCardComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- DesignSystem::Generic::SummaryCardComponent
- Includes:
- DesignSystemHelper
- Defined in:
- app/components/design_system/generic/summary_card_component.rb
Overview
Card that groups a titled summary list (or any content) with optional actions, rendered by ds_summary_card. The GOV.UK brand renders a summary-card variant via its own subclass and template.
Each action is a hash of { text:, href:, hidden_text: }, where hidden_text is appended in a visually hidden span to give the link an accessible, unambiguous name (e.g. " (Karen Francis)").
Direct Known Subclasses
DesignSystem::Govuk::SummaryCardComponent, Nhsuk::SummaryCardComponent
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(title:, actions: []) ⇒ SummaryCardComponent
constructor
A new instance of SummaryCardComponent.
- #render_action(action) ⇒ Object
Methods included from DesignSystemHelper
#brand, #ds_action_link, #ds_alert, #ds_button_tag, #ds_callout, #ds_code, #ds_details, #ds_fixed_elements, #ds_form_builder, #ds_form_with, #ds_grid, #ds_heading, #ds_inset_text, #ds_link_to, #ds_list, #ds_notice, #ds_pagination, #ds_panel, #ds_paragraph, #ds_render_template, #ds_start_button, #ds_summary_card, #ds_summary_list, #ds_tab, #ds_table, #ds_timeago
Methods included from Helpers::CssHelper
Methods included from BrandDerivable
Constructor Details
#initialize(title:, actions: []) ⇒ SummaryCardComponent
Returns a new instance of SummaryCardComponent.
13 14 15 16 17 |
# File 'app/components/design_system/generic/summary_card_component.rb', line 13 def initialize(title:, actions: []) super() @title = title @actions = Array(actions) end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
19 20 21 |
# File 'app/components/design_system/generic/summary_card_component.rb', line 19 def actions @actions end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
19 20 21 |
# File 'app/components/design_system/generic/summary_card_component.rb', line 19 def title @title end |
Instance Method Details
#render_action(action) ⇒ Object
21 22 23 24 25 |
# File 'app/components/design_system/generic/summary_card_component.rb', line 21 def render_action(action) link_to(action[:href] || '#', class: "#{brand}-link") do safe_join([action[:text], render_hidden_text(action[:hidden_text])]) end end |