Class: CCS::Components::GovUK::Button
- Defined in:
- lib/ccs/components/govuk/button.rb
Overview
GOV.UK Button
This is used to generate the button component from the GDS - Components - Button
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the button
{ class: 'govuk-button', data: { module: 'govuk-button' } }.freeze
Instance Method Summary collapse
-
#initialize(text:, **options) ⇒ Button
constructor
A new instance of Button.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Back link component.
Constructor Details
#initialize(text:, **options) ⇒ Button
Returns a new instance of Button.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ccs/components/govuk/button.rb', line 32 def initialize(text:, **) super(**) if @options[:attributes][:disabled] @options[:attributes][:aria] ||= {} @options[:attributes][:aria][:disabled] = true end @options[:attributes][:class] << ' govuk-button--start' if @options[:is_start_button] @text = text @render_method = :"render_#{if @options[:href] :link elsif @options[:form] :submit else :button end}" end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Back link component
55 56 57 |
# File 'lib/ccs/components/govuk/button.rb', line 55 def render send(@render_method) end |