Class: PhlexKit::Accordion
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::Accordion
- Defined in:
- app/components/phlex_kit/accordion/accordion.rb
Overview
Vertically stacked, individually-collapsible sections. Ported from ruby_ui's
RubyUI::Accordion. Compose Accordion > AccordionItem > (AccordionTrigger +
AccordionContent). Animated open/close via the phlex-kit--accordion controller
(native Web Animations API — no motion dependency).
Constant Summary collapse
- TYPES =
single (default, shadcn's): opening an item closes the others.
{ single: "single", multiple: "multiple" }.freeze
Instance Method Summary collapse
-
#initialize(type: :single, **attrs) ⇒ Accordion
constructor
A new instance of Accordion.
- #view_template ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(type: :single, **attrs) ⇒ Accordion
Returns a new instance of Accordion.
10 11 12 13 |
# File 'app/components/phlex_kit/accordion/accordion.rb', line 10 def initialize(type: :single, **attrs) @type = type.to_sym @attrs = attrs end |
Instance Method Details
#view_template ⇒ Object
15 16 17 |
# File 'app/components/phlex_kit/accordion/accordion.rb', line 15 def view_template(&) div(**mix({ class: "pk-accordion", data: { type: fetch_option(TYPES, @type, :type) } }, @attrs), &) end |