Class: AccordionItemComponent

Inherits:
Component show all
Defined in:
app/components/accordion_item_component.rb

Overview

AccordionItem — a single panel inside an Accordion.

Renders two sibling divs (.title + .content) with no wrapper, exactly the structure Fomantic-UI expects as direct children of .ui.accordion or a nested .accordion.

Usage:

Accordion(styled: true) {
  AccordionItem(active: true) { |i|
    i.title { "What is a dog?" }
    i.content {
      Paragraph { "A dog is a type of domesticated animal." }
    }
  }
}

Constant Summary

Constants inherited from Component

Component::HTML_OPTIONS

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_sObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/components/accordion_item_component.rb', line 26

def to_s
  title_classes   = class_names({ "active" => active }, "title")
  content_classes = class_names({ "active" => active }, "content")

  title_el = @slots[:title] ? tag.div(class: title_classes) {
    safe_join([ tag.i(class: "#{icon} icon"), @slots[:title] ])
  } : nil

  content_el = @slots[:content] ? tag.div(class: content_classes) {
    @slots[:content]
  } : nil

  safe_join([ title_el, content_el ])
end