Class: GovukComponent::SummaryListComponent::ActionComponent
- Inherits:
-
Base
- Object
- ViewComponent::Base
- Base
- GovukComponent::SummaryListComponent::ActionComponent
- Includes:
- GovukLinkHelper, GovukVisuallyHiddenHelper
- 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_action_suffix ⇒ Object
readonly
Returns the value of attribute visually_hidden_action_suffix.
-
#visually_hidden_text ⇒ Object
readonly
Returns the value of attribute visually_hidden_text.
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(href: nil, text: 'Change', visually_hidden_text: false, visually_hidden_action_suffix: nil, classes: [], html_attributes: {}) ⇒ ActionComponent
constructor
A new instance of ActionComponent.
- #render? ⇒ Boolean
Methods included from GovukVisuallyHiddenHelper
Methods included from GovukLinkHelper
#govuk_breadcrumb_link_to, #govuk_button_classes, #govuk_button_link_to, #govuk_button_to, #govuk_footer_link_to, #govuk_link_classes, #govuk_link_to, #govuk_mail_to
Methods inherited from Base
Constructor Details
#initialize(href: nil, text: 'Change', visually_hidden_text: false, visually_hidden_action_suffix: nil, classes: [], html_attributes: {}) ⇒ ActionComponent
Returns a new instance of ActionComponent.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/components/govuk_component/summary_list_component/action_component.rb', line 7 def initialize(href: nil, text: 'Change', visually_hidden_text: false, visually_hidden_action_suffix: nil, classes: [], html_attributes: {}) @visually_hidden_text = visually_hidden_text if config.require_summary_list_action_visually_hidden_text && visually_hidden_text == false fail(ArgumentError, "missing keyword: visually_hidden_text") end super(classes:, html_attributes:) @href = href @text = text @visually_hidden_action_suffix = visually_hidden_action_suffix end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'app/components/govuk_component/summary_list_component/action_component.rb', line 5 def attributes @attributes end |
#classes ⇒ Object (readonly)
Returns the value of attribute classes.
5 6 7 |
# File 'app/components/govuk_component/summary_list_component/action_component.rb', line 5 def classes @classes end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
5 6 7 |
# File 'app/components/govuk_component/summary_list_component/action_component.rb', line 5 def href @href end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'app/components/govuk_component/summary_list_component/action_component.rb', line 5 def text @text end |
#visually_hidden_action_suffix ⇒ Object (readonly)
Returns the value of attribute visually_hidden_action_suffix.
5 6 7 |
# File 'app/components/govuk_component/summary_list_component/action_component.rb', line 5 def visually_hidden_action_suffix @visually_hidden_action_suffix end |
#visually_hidden_text ⇒ Object (readonly)
Returns the value of attribute visually_hidden_text.
5 6 7 |
# File 'app/components/govuk_component/summary_list_component/action_component.rb', line 5 def visually_hidden_text @visually_hidden_text end |
Instance Method Details
#call ⇒ Object
24 25 26 27 28 |
# File 'app/components/govuk_component/summary_list_component/action_component.rb', line 24 def call link_to(href, **html_attributes) do safe_join([action_text, visually_hidden_span].compact) end end |
#render? ⇒ Boolean
20 21 22 |
# File 'app/components/govuk_component/summary_list_component/action_component.rb', line 20 def render? href.present? end |