Class: CCS::Components::GovUK::CookieBanner::Action
- Defined in:
- lib/ccs/components/govuk/cookie_banner/action.rb
Overview
GOV.UK Cookie Banner Action
The individual cookie banner action. It defaults to creating button unless a href
is set which will create a link
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the cookie banner action
{ class: 'govuk-link' }.freeze
Instance Method Summary collapse
-
#initialize(text:, href: nil, **options) ⇒ Action
constructor
the action will be rendered as a button.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for a cookie banner message action.
Constructor Details
#initialize(text:, href: nil, **options) ⇒ Action
the action will be rendered as a button
34 35 36 37 38 39 |
# File 'lib/ccs/components/govuk/cookie_banner/action.rb', line 34 def initialize(text:, href: nil, **) super(**) @text = text @href = href end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for a cookie banner message action
45 46 47 48 49 50 51 52 |
# File 'lib/ccs/components/govuk/cookie_banner/action.rb', line 45 def render if href && [:attributes][:type] != :button link_to(text, href, **[:attributes]) else [:attributes][:type] ||= :button Button.new(text: text, href: href, context: context, **).render end end |