Class: Shadcn::Accordion::Trigger::Component
- Inherits:
-
Shadcn::ApplicationViewComponent
- Object
- ViewComponent::Base
- Shadcn::ApplicationViewComponent
- Shadcn::Accordion::Trigger::Component
- Defined in:
- app/components/shadcn/accordion/trigger/component.rb
Overview
AccordionTrigger — Radix wraps the button in an <h3> header, which is
where shadcn puts the flex class.
Constant Summary collapse
- HEADER_CLASSES =
"flex"- CHEVRON_CLASSES =
"pointer-events-none size-4 shrink-0 translate-y-0.5 " \ "text-muted-foreground transition-transform duration-200"
Constants inherited from Shadcn::ApplicationViewComponent
Shadcn::ApplicationViewComponent::CONTENTS_STYLE, Shadcn::ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary
Attributes inherited from Shadcn::ApplicationViewComponent
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
#call ⇒ Object
38 39 40 41 42 |
# File 'app/components/shadcn/accordion/trigger/component.rb', line 38 def call tag.h3(class: HEADER_CLASSES, "data-slot": "accordion-header") do render_element(body: safe_join([ content, chevron ])) end end |
#element_attributes(**defaults) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'app/components/shadcn/accordion/trigger/component.rb', line 27 def element_attributes(**defaults) super(**{ type: "button", "data-state" => "closed", "data-orientation" => "vertical", "aria-expanded" => "false", "data-shadcn--accordion-target" => "trigger", "data-action" => "click->shadcn--accordion#toggle keydown->shadcn--accordion#keydown" }.merge(defaults)) end |