Class: CCS::Components::GovUK::ExitThisPage
- Includes:
- ActionView::Context, ActionView::Helpers
- Defined in:
- lib/ccs/components/govuk/exit_this_page.rb
Overview
GOV.UK Exit this page
This is used to generate the exit this page component from the GDS - Components - Exit this page
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the exit this page
{ class: 'govuk-exit-this-page', data: { module: 'govuk-exit-this-page' } }.freeze
Instance Method Summary collapse
-
#initialize(text: nil, redirect_url: nil, **options) ⇒ ExitThisPage
constructor
A new instance of ExitThisPage.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Exit this page component.
Constructor Details
#initialize(text: nil, redirect_url: nil, **options) ⇒ ExitThisPage
Returns a new instance of ExitThisPage.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ccs/components/govuk/exit_this_page.rb', line 38 def initialize(text: nil, redirect_url: nil, **) super(**) @text = text || default_text @redirect_url = redirect_url || 'https://www.bbc.co.uk/weather' %i[activated timed_out press_two_more_times press_one_more_time].each do |data_attribute| data_attribute_name = :"#{data_attribute}_text" @options[:attributes][:data][:"i18n.#{data_attribute.to_s.gsub('_', '-')}"] = [data_attribute_name] if [data_attribute_name] end end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Exit this page component
54 55 56 57 58 |
# File 'lib/ccs/components/govuk/exit_this_page.rb', line 54 def render tag.div(**[:attributes]) do Button.new(text: text, href: redirect_url, context: context, classes: 'govuk-button--warning govuk-exit-this-page__button govuk-js-exit-this-page-button', attributes: { rel: 'nofollow noreferrer' }).render end end |