Class: AccordionComponent

Inherits:
Component show all
Includes:
Attachable
Defined in:
app/components/accordion_component.rb

Overview

Accordion — collapsible content panels.

Renders a Fomantic-UI accordion container wired to the fui-accordion Stimulus controller. Block content should contain raw ‘.title` and `.content` div pairs (built with `tag.div`).

Usage:

Accordion(styled: true) {
  tag.div(class: "active title") {
    safe_join([tag.i(class: "dropdown icon"), "What is a dog?"])
  }
  tag.div(class: "active content") {
    tag.p { "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



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/components/accordion_component.rb', line 34

def to_s
  classes = class_names(
    "ui",
    color,
    {
      "attached"     => attached,
      "styled"       => styled,
      "fluid"        => fluid,
      "inverted"     => inverted,
      "basic"        => basic && styled,
      "compact"      => compact,
      "very compact" => very_compact,
      "tree"         => tree
    },
    "accordion"
  )

  data = { controller: "fui-accordion" }
  data[:fui_accordion_exclusive_value]   = "false" unless exclusive
  data[:fui_accordion_collapsible_value] = "false" unless collapsible
  data[:fui_accordion_duration_value]    = duration.to_s if duration != 350

  opts = merge_html_options(class: classes, data: data)

  tag.div(**opts) { @content }
end