Class: Shadcn::Accordion::Content::Component

Inherits:
Shadcn::ApplicationViewComponent show all
Defined in:
app/components/shadcn/accordion/content/component.rb

Overview

AccordionContent — the animated wrapper carries the classes, the inner div takes the padding, exactly as in the TSX.

Constant Summary collapse

WRAPPER_CLASSES =
"overflow-hidden text-sm data-[state=closed]:animate-accordion-up " \
"data-[state=open]:animate-accordion-down"

Constants inherited from Shadcn::ApplicationViewComponent

Shadcn::ApplicationViewComponent::CONTENTS_STYLE, Shadcn::ApplicationViewComponent::VOID_TAGS

Instance Attribute Summary

Attributes inherited from Shadcn::ApplicationViewComponent

#attributes

Instance Method Summary collapse

Methods inherited from Shadcn::ApplicationViewComponent

#css_classes, default_tag, #initialize, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name

Constructor Details

This class inherits a constructor from Shadcn::ApplicationViewComponent

Instance Method Details

#callObject



31
32
33
# File 'app/components/shadcn/accordion/content/component.rb', line 31

def call
  (:div, inner, element_attributes)
end

#element_attributes(**defaults) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/components/shadcn/accordion/content/component.rb', line 18

def element_attributes(**defaults)
  # The outer element gets no caller classes: shadcn puts them on the
  # inner div instead.
  {
    "data-slot" => "accordion-content",
    "data-state" => "closed",
    "data-orientation" => "vertical",
    role: "region",
    hidden: true,
    class: WRAPPER_CLASSES
  }.merge(defaults).compact
end