Class: CCS::Components::GovUK::CookieBanner::Message
- Defined in:
- lib/ccs/components/govuk/cookie_banner/message.rb
Overview
GOV.UK Cookie Banner Message
The individual cookie banner message
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the cookie banner message
{ class: 'govuk-cookie-banner__message govuk-width-container' }.freeze
Instance Method Summary collapse
-
#initialize(heading_text: nil, content: nil, text: nil, actions: nil, **options) ⇒ Message
constructor
A new instance of Message.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Cookie Banner Message.
Constructor Details
#initialize(heading_text: nil, content: nil, text: nil, actions: nil, **options) ⇒ Message
Returns a new instance of Message.
38 39 40 41 42 43 44 45 |
# File 'lib/ccs/components/govuk/cookie_banner/message.rb', line 38 def initialize(heading_text: nil, content: nil, text: nil, actions: nil, **) super(**) @heading_text = heading_text @content = content @text = text @actions = actions.map { |action| Action.new(context: @context, **action) } if actions end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Cookie Banner Message
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ccs/components/govuk/cookie_banner/message.rb', line 53 def render tag.div(**[:attributes]) do concat(tag.div(class: 'govuk-grid-row') do tag.div(class: 'govuk-grid-column-two-thirds') do concat(tag.h2(heading_text, class: 'govuk-cookie-banner__heading govuk-heading-m')) if heading_text concat(tag.div(class: 'govuk-cookie-banner__content') do content || tag.p(text, class: 'govuk-body') if content || text end) end end) if actions concat(tag.div(class: 'govuk-button-group') do actions.each { |action| concat(action.render) } end) end end end |