Class: GovukComponent::PanelComponent::Action
- Includes:
- GovukLinkHelper, GovukVisuallyHiddenHelper
- Defined in:
- app/components/govuk_component/panel_component.rb
Instance Attribute Summary collapse
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
- #default_attributes ⇒ Object
-
#initialize(text:, href:, type: :button, classes: [], html_attributes: {}) ⇒ Action
constructor
A new instance of Action.
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(text:, href:, type: :button, classes: [], html_attributes: {}) ⇒ Action
Returns a new instance of Action.
73 74 75 76 77 78 79 |
# File 'app/components/govuk_component/panel_component.rb', line 73 def initialize(text:, href:, type: :button, classes: [], html_attributes: {}) @text = text @href = href @type = type super(classes:, html_attributes:) end |
Instance Attribute Details
#href ⇒ Object (readonly)
Returns the value of attribute href.
71 72 73 |
# File 'app/components/govuk_component/panel_component.rb', line 71 def href @href end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
71 72 73 |
# File 'app/components/govuk_component/panel_component.rb', line 71 def text @text end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
71 72 73 |
# File 'app/components/govuk_component/panel_component.rb', line 71 def type @type end |
Instance Method Details
#call ⇒ Object
85 86 87 88 89 90 91 |
# File 'app/components/govuk_component/panel_component.rb', line 85 def call case type.to_sym when :button then (text, href, inverse: true, **html_attributes) when :link then govuk_link_to(text, href, inverse: true, **html_attributes) else fail ArgumentError, "unrecognised type (must be :link or :button)" end end |
#default_attributes ⇒ Object
81 82 83 |
# File 'app/components/govuk_component/panel_component.rb', line 81 def default_attributes {} end |