Class: Daisy::DataDisplay::AccordionComponent

Inherits:
LocoMotion::BaseComponent show all
Includes:
LocoMotion::Concerns::TippableComponent
Defined in:
app/components/daisy/data_display/accordion_component.rb

Overview

The Accordion component shows collapsible sections of content, with only one section open at a time. Each section has a title that can be clicked to show or hide its content.

Includes the LocoMotion::Concerns::TippableComponent module to enable easy tooltip addition.

Defined Under Namespace

Classes: AccordionSectionComponent

Constant Summary

Constants inherited from LocoMotion::BaseComponent

LocoMotion::BaseComponent::EMPTY_PART_IGNORED_TAGS, LocoMotion::BaseComponent::SELF_CLOSING_TAGS

Instance Attribute Summary collapse

Attributes inherited from LocoMotion::BaseComponent

#config, #loco_parent

Instance Method Summary collapse

Methods inherited from LocoMotion::BaseComponent

build, #component_ref, #config_option, #cssify, define_modifier, define_modifiers, define_part, define_parts, define_size, define_sizes, #empty_part_content, #inspect, #part, register_component_initializer, register_component_setup, #rendered_css, #rendered_data, #rendered_html, #rendered_stimulus_controllers, #rendered_tag_name, renders_many, renders_one, set_component_name, #set_loco_parent, #strip_spaces

Constructor Details

#initialize(**kws, &block) ⇒ AccordionComponent

Creates a new accordion component.

Parameters:

  • kws (Hash)

    The keyword arguments for the component.

Options Hash (**kws):

  • name (String)

    The name attribute for all radio buttons in this accordion. Defaults to a random string.

  • modifier (Symbol)

    Optional modifier for the accordion’s appearance. Use ‘:arrow` to show arrow indicators, or `:plus` to show plus/minus indicators.

  • tip (String)

    The tooltip text to display when hovering over the component.



157
158
159
160
161
# File 'app/components/daisy/data_display/accordion_component.rb', line 157

def initialize(**kws, &block)
  super

  @name = config_option(:name, "accordion-#{SecureRandom.uuid}")
end

Instance Attribute Details

#nameString (readonly)

Returns The name attribute for all radio buttons in this accordion.

Returns:

  • (String)

    The name attribute for all radio buttons in this accordion.



140
141
142
# File 'app/components/daisy/data_display/accordion_component.rb', line 140

def name
  @name
end

Instance Method Details

#before_renderObject



163
164
165
# File 'app/components/daisy/data_display/accordion_component.rb', line 163

def before_render
  super
end