Class: CCS::Components::GovUK::PhaseBanner
- Defined in:
- lib/ccs/components/govuk/phase_banner.rb
Overview
GOV.UK Phase banner
This is used to generate the phase banner component from the GDS - Components - Phase banner
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the phase banner
{ class: 'govuk-phase-banner' }.freeze
Instance Method Summary collapse
-
#initialize(tag_options:, text: nil, **options) ⇒ PhaseBanner
constructor
A new instance of PhaseBanner.
-
#render { ... } ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Phase banner component.
Constructor Details
#initialize(tag_options:, text: nil, **options) ⇒ PhaseBanner
Returns a new instance of PhaseBanner.
36 37 38 39 40 41 42 43 44 |
# File 'lib/ccs/components/govuk/phase_banner.rb', line 36 def initialize(tag_options:, text: nil, **) super(**) [:classes] = "govuk-phase-banner__content__tag #{[:classes]}".rstrip [:context] = @context @text = text @tag_options = end |
Instance Method Details
#render { ... } ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Phase banner component
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/ccs/components/govuk/phase_banner.rb', line 52 def render tag.div(**[:attributes]) do tag.p(class: 'govuk-phase-banner__content') do concat(Tag.new(**).render) concat(tag.span(class: 'govuk-phase-banner__text') do text || yield end) end end end |