Class: Shadcn::Accordion::Item::Component
- Inherits:
-
Shadcn::ApplicationViewComponent
- Object
- ViewComponent::Base
- Shadcn::ApplicationViewComponent
- Shadcn::Accordion::Item::Component
- Defined in:
- app/components/shadcn/accordion/item/component.rb
Overview
AccordionItem
Constant Summary
Constants inherited from Shadcn::ApplicationViewComponent
Shadcn::ApplicationViewComponent::CONTENTS_STYLE, Shadcn::ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Shadcn::ApplicationViewComponent
Instance Method Summary collapse
- #call ⇒ Object
- #element_attributes(**defaults) ⇒ Object
-
#initialize(value:, disabled: false, **attributes) ⇒ Component
constructor
A new instance of Component.
Methods inherited from Shadcn::ApplicationViewComponent
#css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
#initialize(value:, disabled: false, **attributes) ⇒ Component
Returns a new instance of Component.
19 20 21 22 23 |
# File 'app/components/shadcn/accordion/item/component.rb', line 19 def initialize(value:, disabled: false, **attributes) @value = value.to_s @disabled = disabled super(**attributes) end |
Instance Attribute Details
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
17 18 19 |
# File 'app/components/shadcn/accordion/item/component.rb', line 17 def disabled @disabled end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
17 18 19 |
# File 'app/components/shadcn/accordion/item/component.rb', line 17 def value @value end |
Instance Method Details
#call ⇒ Object
35 36 37 |
# File 'app/components/shadcn/accordion/item/component.rb', line 35 def call render_element(body: safe_join([ trigger, panel, content ].compact)) end |
#element_attributes(**defaults) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'app/components/shadcn/accordion/item/component.rb', line 25 def element_attributes(**defaults) super(**{ "data-value" => value, "data-state" => "closed", "data-orientation" => "vertical", "data-disabled" => (true if disabled), "data-shadcn--accordion-target" => "item" }.merge(defaults)) end |