Class: FoxTail::AccordionComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- Base
- BaseComponent
- FoxTail::AccordionComponent
- Includes:
- Concerns::HasStimulusController
- Defined in:
- app/components/fox_tail/accordion_component.rb
Defined Under Namespace
Classes: StimulusController
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Attributes inherited from BaseComponent
Instance Method Summary collapse
- #before_render ⇒ Object
- #call ⇒ Object
-
#initialize(id, html_attributes = {}) ⇒ AccordionComponent
constructor
A new instance of AccordionComponent.
- #render? ⇒ Boolean
- #stimulus_controller_options ⇒ Object
Methods inherited from BaseComponent
classname_merger, stimulus_merger, use_stimulus?, #with_html_attributes, #with_html_class
Methods inherited from Base
Constructor Details
#initialize(id, html_attributes = {}) ⇒ AccordionComponent
Returns a new instance of AccordionComponent.
17 18 19 20 |
# File 'app/components/fox_tail/accordion_component.rb', line 17 def initialize(id, html_attributes = {}) @id = id super(html_attributes) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'app/components/fox_tail/accordion_component.rb', line 6 def id @id end |
Instance Method Details
#before_render ⇒ Object
26 27 28 29 30 31 |
# File 'app/components/fox_tail/accordion_component.rb', line 26 def before_render super html_attributes[:id] = id html_attributes[:class] = classnames theme.apply(:root, self), html_class end |
#call ⇒ Object
33 34 35 36 37 |
# File 'app/components/fox_tail/accordion_component.rb', line 33 def call content_tag :div, html_attributes do items.each { |item| concat item } end end |
#render? ⇒ Boolean
22 23 24 |
# File 'app/components/fox_tail/accordion_component.rb', line 22 def render? items? end |
#stimulus_controller_options ⇒ Object
39 40 41 |
# File 'app/components/fox_tail/accordion_component.rb', line 39 def { always_open: always_open } end |