Class: FoxTail::AccordionComponent
- Inherits:
-
BaseComponent
show all
- Includes:
- Concerns::HasStimulusController, Concerns::Identifiable
- Defined in:
- app/components/fox_tail/accordion_component.rb
Defined Under Namespace
Classes: StimulusController
Instance Attribute Summary
#html_attributes
Instance Method Summary
collapse
classname_merger, stimulus_merger, use_stimulus?, #with_html_attributes, #with_html_class
Methods inherited from Base
fox_tail_config
Constructor Details
#initialize(id_or_attributes = {}, html_attributes = {}) ⇒ AccordionComponent
Returns a new instance of AccordionComponent.
25
26
27
28
29
30
31
32
33
34
|
# File 'app/components/fox_tail/accordion_component.rb', line 25
def initialize(id_or_attributes = {}, html_attributes = {})
if id_or_attributes.is_a? Hash
html_attributes = id_or_attributes
else
__id_argument_deprecated_warning
html_attributes[:id] = id_or_attributes
end
super(html_attributes)
end
|
Instance Method Details
#before_render ⇒ Object
40
41
42
43
44
45
|
# File 'app/components/fox_tail/accordion_component.rb', line 40
def before_render
super
generate_unique_id
html_attributes[:class] = classnames theme.apply(:root, self), html_class
end
|
#call ⇒ Object
47
48
49
50
51
|
# File 'app/components/fox_tail/accordion_component.rb', line 47
def call
content_tag :div, html_attributes do
items.each { |item| concat item }
end
end
|
#render? ⇒ Boolean
36
37
38
|
# File 'app/components/fox_tail/accordion_component.rb', line 36
def render?
items?
end
|
#stimulus_controller_options ⇒ Object
53
54
55
|
# File 'app/components/fox_tail/accordion_component.rb', line 53
def stimulus_controller_options
{always_open: always_open}
end
|