Class: GovukComponent::StartButtonComponent
- Defined in:
- app/components/govuk_component/start_button_component.rb
Constant Summary collapse
- BUTTON_ATTRIBUTES =
{ draggable: 'false', data: { module: 'govuk-button' } }.freeze
- LINK_ATTRIBUTES =
BUTTON_ATTRIBUTES.merge({ role: 'button' }).freeze
Instance Attribute Summary collapse
-
#as_button ⇒ Object
readonly
Returns the value of attribute as_button.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(text:, href:, as_button: config.default_start_button_as_button, classes: [], html_attributes: {}) ⇒ StartButtonComponent
constructor
A new instance of StartButtonComponent.
Constructor Details
#initialize(text:, href:, as_button: config.default_start_button_as_button, classes: [], html_attributes: {}) ⇒ StartButtonComponent
Returns a new instance of StartButtonComponent.
11 12 13 14 15 16 17 |
# File 'app/components/govuk_component/start_button_component.rb', line 11 def initialize(text:, href:, as_button: config., classes: [], html_attributes: {}) @text = text @href = href @as_button = super(classes: classes, html_attributes: html_attributes) end |
Instance Attribute Details
#as_button ⇒ Object (readonly)
Returns the value of attribute as_button.
9 10 11 |
# File 'app/components/govuk_component/start_button_component.rb', line 9 def @as_button end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
9 10 11 |
# File 'app/components/govuk_component/start_button_component.rb', line 9 def href @href end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
9 10 11 |
# File 'app/components/govuk_component/start_button_component.rb', line 9 def text @text end |
Instance Method Details
#call ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/components/govuk_component/start_button_component.rb', line 19 def call if (href, **html_attributes) do safe_join([text, icon]) end else link_to(href, **html_attributes) do safe_join([text, icon]) end end end |