Class: GovukComponent::StartButtonComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/govuk_component/start_button_component.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#html_attributes

Instance Method Summary collapse

Methods inherited from Base

#brand, #class_prefix

Constructor Details

#initialize(text:, href:, as_button: config.default_start_button_as_button, classes: [], html_attributes: {}) ⇒ StartButtonComponent

Returns a new instance of StartButtonComponent.



4
5
6
7
8
9
10
# File 'app/components/govuk_component/start_button_component.rb', line 4

def initialize(text:, href:, as_button: config.default_start_button_as_button, classes: [], html_attributes: {})
  @text = text
  @href = href
  @as_button = as_button

  super(classes:, html_attributes:)
end

Instance Attribute Details

#as_buttonObject (readonly)

Returns the value of attribute as_button.



2
3
4
# File 'app/components/govuk_component/start_button_component.rb', line 2

def as_button
  @as_button
end

#hrefObject (readonly)

Returns the value of attribute href.



2
3
4
# File 'app/components/govuk_component/start_button_component.rb', line 2

def href
  @href
end

#textObject (readonly)

Returns the value of attribute text.



2
3
4
# File 'app/components/govuk_component/start_button_component.rb', line 2

def text
  @text
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
# File 'app/components/govuk_component/start_button_component.rb', line 12

def call
  if as_button
    button_to(href, **html_attributes) do
      safe_join([text, icon])
    end
  else
    link_to(href, **html_attributes) do
      safe_join([text, icon])
    end
  end
end