Class: GovukComponent::SummaryListComponent::ActionComponent
- Inherits:
-
Base
- Object
- ViewComponent::Base
- Base
- GovukComponent::SummaryListComponent::ActionComponent
- Defined in:
- app/components/govuk_component/summary_list_component/action_component.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#classes ⇒ Object
readonly
Returns the value of attribute classes.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#visually_hidden_text ⇒ Object
readonly
Returns the value of attribute visually_hidden_text.
Attributes inherited from Base
Attributes included from Traits::CustomHtmlAttributes
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(href: nil, text: 'Change', visually_hidden_text: nil, classes: [], html_attributes: {}) ⇒ ActionComponent
constructor
A new instance of ActionComponent.
- #render? ⇒ Boolean
Methods inherited from Base
Methods included from Traits::CustomClasses
Methods included from Govuk::Components::Helpers::CssUtilities
Constructor Details
#initialize(href: nil, text: 'Change', visually_hidden_text: nil, classes: [], html_attributes: {}) ⇒ ActionComponent
Returns a new instance of ActionComponent.
4 5 6 7 8 9 10 |
# File 'app/components/govuk_component/summary_list_component/action_component.rb', line 4 def initialize(href: nil, text: 'Change', visually_hidden_text: nil, classes: [], html_attributes: {}) super(classes: classes, html_attributes: html_attributes) @href = href @text = text @visually_hidden_text = visually_hidden_text end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
2 3 4 |
# File 'app/components/govuk_component/summary_list_component/action_component.rb', line 2 def attributes @attributes end |
#classes ⇒ Object (readonly)
Returns the value of attribute classes.
2 3 4 |
# File 'app/components/govuk_component/summary_list_component/action_component.rb', line 2 def classes @classes end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
2 3 4 |
# File 'app/components/govuk_component/summary_list_component/action_component.rb', line 2 def href @href end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
2 3 4 |
# File 'app/components/govuk_component/summary_list_component/action_component.rb', line 2 def text @text end |
#visually_hidden_text ⇒ Object (readonly)
Returns the value of attribute visually_hidden_text.
2 3 4 |
# File 'app/components/govuk_component/summary_list_component/action_component.rb', line 2 def visually_hidden_text @visually_hidden_text end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 |
# File 'app/components/govuk_component/summary_list_component/action_component.rb', line 16 def call link_classes = govuk_link_classes.append(classes).flatten link_to(href, class: link_classes, **html_attributes) do safe_join([action_text, visually_hidden_span].compact, " ") end end |
#render? ⇒ Boolean
12 13 14 |
# File 'app/components/govuk_component/summary_list_component/action_component.rb', line 12 def render? href.present? end |