Class: AccordionComponent
- Includes:
- Attachable
- Defined in:
- app/components/accordion_component.rb
Overview
Accordion — collapsible content panel using <details>/<summary>.
Usage:
Accordion(attached: true) { |a|
a.title { text "Section" }
text "Panel content"
}
Constant Summary
Constants inherited from Component
Instance Method Summary collapse
Methods inherited from Component
default, #initialize, #render_in, slot
Constructor Details
This class inherits a constructor from Component
Instance Method Details
#to_s ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/components/accordion_component.rb', line 24 def to_s classes = class_names( "ui", color, { "attached" => attached, "raised" => raised, "inverted" => inverted, "basic" => basic, "compact" => compact, "secondary" => secondary }, "segment" ) opts = (class: classes) opts[:open] = "" if open tag.details(**opts) { safe_join([ tag.summary { @slots[:title] || "" }, tag.div { @content } ]) } end |