Class: FoxTail::AccordionComponent

Inherits:
BaseComponent show all
Includes:
Concerns::HasStimulusController
Defined in:
app/components/fox_tail/accordion_component.rb

Defined Under Namespace

Classes: StimulusController

Instance Attribute Summary collapse

Attributes inherited from BaseComponent

#html_attributes

Instance Method Summary collapse

Methods inherited from BaseComponent

classname_merger, stimulus_merger, use_stimulus?, #with_html_attributes, #with_html_class

Methods inherited from Base

fox_tail_config

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

#idObject (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_renderObject



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

#callObject



33
34
35
36
37
# File 'app/components/fox_tail/accordion_component.rb', line 33

def call
   :div, html_attributes do
    items.each { |item| concat item }
  end
end

#render?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'app/components/fox_tail/accordion_component.rb', line 22

def render?
  items?
end

#stimulus_controller_optionsObject



39
40
41
# File 'app/components/fox_tail/accordion_component.rb', line 39

def stimulus_controller_options
  { always_open: always_open }
end