Class: Fluxbit::AccordionComponent
- Includes:
- Config::AccordionComponent
- Defined in:
- app/components/fluxbit/accordion_component.rb
Overview
The ‘Fluxbit::AccordionComponent` renders an accordion component following Flowbite styles. It supports collapsible panels with headers and content, customizable icons, and various styling options.
Defined Under Namespace
Classes: Panel
Constant Summary
Constants inherited from Component
Instance Method Summary collapse
- #before_render ⇒ Object
- #call ⇒ Object
-
#initialize(**props) ⇒ Fluxbit::AccordionComponent
constructor
Initializes the accordion component with the given properties.
Methods inherited from Component
#add, #add_popover_or_tooltip, #anyicon, #element_name, #fx_id, #icon, #options, #popover?, #random_id, #remove_class, #remove_class_from_props, #render_popover_or_tooltip, #target, #tooltip?
Methods included from IconHelpers
#chevron_double_left, #chevron_double_right, #chevron_down, #chevron_left, #chevron_right, #chevron_up, #close_icon, #ellipsis_horizontal, #eye_icon, #eye_slash_icon, #plus_icon
Constructor Details
#initialize(**props) ⇒ Fluxbit::AccordionComponent
Initializes the accordion component with the given properties.
28 29 30 31 32 33 34 |
# File 'app/components/fluxbit/accordion_component.rb', line 28 def initialize(**props) super @props = props @flush = (@props.delete(:flush), default: @@flush) @color = (@props.delete(:color), collection: styles[:colors].keys, default: @@color).to_sym @collapse_all = (@props.delete(:collapse_all), default: @@collapse_all) end |
Instance Method Details
#before_render ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'app/components/fluxbit/accordion_component.rb', line 36 def before_render add to: @props, first_element: true, class: [ styles[:base], @flush ? "" : "border border-gray-200 dark:border-gray-700 rounded-xl" ] @props[:class] = remove_class(@props.delete(:remove_class) || "", @props[:class]) @props[:id] ||= fx_id @props["data-accordion"] = @collapse_all ? "collapse" : "open" end |
#call ⇒ Object
46 47 48 49 50 |
# File 'app/components/fluxbit/accordion_component.rb', line 46 def call tag.div(**@props) do safe_join(panels) end end |