Class: Pajamas::AccordionItemComponent
- Defined in:
- app/components/pajamas/accordion_item_component.rb
Constant Summary collapse
- STATE_OPTIONS =
[:opened, :closed].freeze
Instance Method Summary collapse
- #body_class ⇒ Object
- #expanded? ⇒ Boolean
- #icon ⇒ Object
-
#initialize(title: nil, state: :closed, button_options: {}) ⇒ AccordionItemComponent
constructor
A new instance of AccordionItemComponent.
Constructor Details
#initialize(title: nil, state: :closed, button_options: {}) ⇒ AccordionItemComponent
Returns a new instance of AccordionItemComponent.
13 14 15 16 17 |
# File 'app/components/pajamas/accordion_item_component.rb', line 13 def initialize(title: nil, state: :closed, button_options: {}) @title = title @state = filter_attribute(state.to_sym, STATE_OPTIONS) @button_options = end |
Instance Method Details
#body_class ⇒ Object
23 24 25 |
# File 'app/components/pajamas/accordion_item_component.rb', line 23 def body_class @state == :opened ? { class: 'show' } : {} end |
#expanded? ⇒ Boolean
27 28 29 |
# File 'app/components/pajamas/accordion_item_component.rb', line 27 def @state == :opened end |
#icon ⇒ Object
19 20 21 |
# File 'app/components/pajamas/accordion_item_component.rb', line 19 def icon @state == :opened ? "chevron-down" : "chevron-right" end |