Class: CCS::Components::GovUK::Panel
- Defined in:
- lib/ccs/components/govuk/panel.rb
Overview
GOV.UK Panel
This is used to generate the panel component from the GDS - Components - Panel
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the panel
{ class: 'govuk-panel govuk-panel--confirmation' }.freeze
Instance Method Summary collapse
-
#initialize(title_text:, panel_text: nil, **options) ⇒ Panel
constructor
A new instance of Panel.
-
#render { ... } ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Panel component.
Constructor Details
#initialize(title_text:, panel_text: nil, **options) ⇒ Panel
Returns a new instance of Panel.
32 33 34 35 36 37 |
# File 'lib/ccs/components/govuk/panel.rb', line 32 def initialize(title_text:, panel_text: nil, **) super(**) @title_text = title_text @panel_text = panel_text end |
Instance Method Details
#render { ... } ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Panel component
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ccs/components/govuk/panel.rb', line 45 def render tag.div(**[:attributes]) do concat(tag.send(:"h#{[:heading_level] || 1}", title_text, class: 'govuk-panel__title')) if panel_text || block_given? concat(tag.div(class: 'govuk-panel__body') do panel_text || yield end) end end end |