Class: Railsboot::Dropdown::ActionComponent
- Inherits:
-
Component
- Object
- Component
- Railsboot::Dropdown::ActionComponent
- Defined in:
- app/components/railsboot/dropdown/action_component.rb
Constant Summary collapse
- TYPES =
["button", "link"].freeze
- DEFAULT_TYPE =
"button".freeze
Instance Method Summary collapse
- #button? ⇒ Boolean
-
#initialize(text: "", type: DEFAULT_TYPE, variant: Railsboot::ButtonComponent::DEFAULT_VARIANT, **html_attributes) ⇒ ActionComponent
constructor
A new instance of ActionComponent.
- #link? ⇒ Boolean
Constructor Details
#initialize(text: "", type: DEFAULT_TYPE, variant: Railsboot::ButtonComponent::DEFAULT_VARIANT, **html_attributes) ⇒ ActionComponent
Returns a new instance of ActionComponent.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/components/railsboot/dropdown/action_component.rb', line 5 def initialize(text: "", type: DEFAULT_TYPE, variant: Railsboot::ButtonComponent::DEFAULT_VARIANT, **html_attributes) @text = text @variant = variant @type = fetch_or_raise(type, TYPES) @html_attributes = html_attributes @html_attributes[:class] = class_names( "dropdown-toggle", html_attributes.delete(:class) ) end |
Instance Method Details
#button? ⇒ Boolean
17 18 19 |
# File 'app/components/railsboot/dropdown/action_component.rb', line 17 def @type == "button" end |
#link? ⇒ Boolean
21 22 23 |
# File 'app/components/railsboot/dropdown/action_component.rb', line 21 def link? @type == "link" end |