Class: Daisy::DataDisplay::AccordionComponent::AccordionSectionComponent
Overview
Renders a single section of the accordion.
Constant Summary
LocoMotion::BaseComponent::EMPTY_PART_IGNORED_TAGS, LocoMotion::BaseComponent::SELF_CLOSING_TAGS
Instance Attribute Summary collapse
#config, #loco_parent
Instance Method Summary
collapse
name
build, #component_ref, #config_option, #cssify, define_modifier, define_modifiers, define_part, define_parts, define_size, define_sizes, #empty_part_content, #inspect, #part, register_component_initializer, register_component_setup, #rendered_css, #rendered_data, #rendered_html, #rendered_stimulus_controllers, #rendered_tag_name, renders_many, renders_one, set_component_name, #set_loco_parent, #strip_spaces
Constructor Details
Creates a new accordion section.
78
79
80
81
82
83
84
85
|
# File 'app/components/daisy/data_display/accordion_component.rb', line 78
def initialize(**kws, &block)
super
@value = config_option(:value)
@checked = config_option(:checked, false)
@simple_title = config_option(:title)
@name = config_option(:name)
end
|
Instance Attribute Details
#simple_title ⇒ String
Returns Accessor for the ‘title` string passed via the component config.
60
61
62
|
# File 'app/components/daisy/data_display/accordion_component.rb', line 60
def simple_title
@simple_title
end
|
Instance Method Details
#before_render ⇒ Object
87
88
89
90
91
92
|
# File 'app/components/daisy/data_display/accordion_component.rb', line 87
def before_render
setup_component
setup_radio_button
setup_title
setup_content
end
|
#call ⇒ Object
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'app/components/daisy/data_display/accordion_component.rb', line 117
def call
part(:component) do
concat(part(:radio_button))
if title?
concat(title)
elsif @simple_title.present?
concat(part(:title) { @simple_title })
end
concat(part(:content) { content })
end
end
|
#setup_component ⇒ Object
94
95
96
97
98
99
100
101
|
# File 'app/components/daisy/data_display/accordion_component.rb', line 94
def setup_component
@name = config_option(:name, loco_parent.name)
add_css(:component, "collapse")
add_css(:component, "collapse-arrow") if loco_parent.config.modifiers.include?(:arrow)
add_css(:component, "collapse-plus") if loco_parent.config.modifiers.include?(:plus)
end
|
#setup_content ⇒ Object
113
114
115
|
# File 'app/components/daisy/data_display/accordion_component.rb', line 113
def setup_content
add_css(:content, "collapse-content")
end
|
103
104
105
106
|
# File 'app/components/daisy/data_display/accordion_component.rb', line 103
def setup_radio_button
set_tag_name(:radio_button, :input)
add_html(:radio_button, { type: "radio", name: @name, value: @value, checked: @checked })
end
|
#setup_title ⇒ Object
108
109
110
111
|
# File 'app/components/daisy/data_display/accordion_component.rb', line 108
def setup_title
set_tag_name(:title, :h2)
add_css(:title, "collapse-title text-lg font-bold")
end
|