Class: DesignSystem::Generic::ButtonComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- DesignSystem::Generic::ButtonComponent
- Defined in:
- app/components/design_system/generic/button_component.rb
Overview
Submit button rendered by ds_button_tag. Brand subclasses add their button classes and style modifiers. Content can be supplied via the first argument or a block.
Direct Known Subclasses
DesignSystem::Govuk::ButtonComponent, Nhsuk::ButtonComponent
Instance Attribute Summary collapse
-
#content_or_options ⇒ Object
readonly
Returns the value of attribute content_or_options.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(content_or_options = nil, options = nil) ⇒ ButtonComponent
constructor
A new instance of ButtonComponent.
Methods included from Helpers::CssHelper
Methods included from BrandDerivable
Constructor Details
#initialize(content_or_options = nil, options = nil) ⇒ ButtonComponent
Returns a new instance of ButtonComponent.
7 8 9 10 11 |
# File 'app/components/design_system/generic/button_component.rb', line 7 def initialize( = nil, = nil) super() @content_or_options = @options = end |
Instance Attribute Details
#content_or_options ⇒ Object (readonly)
Returns the value of attribute content_or_options.
13 14 15 |
# File 'app/components/design_system/generic/button_component.rb', line 13 def @content_or_options end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'app/components/design_system/generic/button_component.rb', line 13 def @options end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/components/design_system/generic/button_component.rb', line 15 def call = (, ) style = .delete('style') ['aria-disabled'] = true if ['disabled'] = (, ["#{brand}-button"]) do |classes| style_class = style_class_hash[style] classes << style_class if style_class end if content.present? () { content } else (, ) end end |