Class: Shadcn::Accordion::Item::Component

Inherits:
Shadcn::ApplicationViewComponent show all
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

Attributes inherited from Shadcn::ApplicationViewComponent

#attributes

Instance Method Summary collapse

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

#disabledObject (readonly)

Returns the value of attribute disabled.



17
18
19
# File 'app/components/shadcn/accordion/item/component.rb', line 17

def disabled
  @disabled
end

#valueObject (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

#callObject



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