Class: CCS::Components::GovUK::CookieBanner
- Defined in:
- lib/ccs/components/govuk/cookie_banner.rb,
lib/ccs/components/govuk/cookie_banner/action.rb,
lib/ccs/components/govuk/cookie_banner/message.rb
Overview
GOV.UK Cookie Banner
This is used to generate the cookie banner component from the GDS - Components - Cookie banner
Defined Under Namespace
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the cookie banner
{ class: 'govuk-cookie-banner' }.freeze
Instance Method Summary collapse
-
#initialize(messages:, **options) ⇒ CookieBanner
constructor
A new instance of CookieBanner.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Cookie banner component.
Constructor Details
#initialize(messages:, **options) ⇒ CookieBanner
Returns a new instance of CookieBanner.
29 30 31 32 33 34 35 36 37 |
# File 'lib/ccs/components/govuk/cookie_banner.rb', line 29 def initialize(messages:, **) super(**) (@options[:attributes][:data] ||= {})[:nosnippet] = 'true' @options[:attributes][:role] = 'region' (@options[:attributes][:aria] ||= {})[:label] ||= 'Cookie banner' @messages = .map { || Message.new(context: @context, **) } end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Cookie banner component
43 44 45 46 47 |
# File 'lib/ccs/components/govuk/cookie_banner.rb', line 43 def render tag.div(**[:attributes]) do .each { || concat(.render) } end end |