Class: Fluxbit::DropdownComponent
- Includes:
- Config::DropdownComponent
- Defined in:
- app/components/fluxbit/dropdown_component.rb
Overview
The ‘Fluxbit::DropdownComponent` is a component for rendering customizable Dropdown containers.
Instance Method Summary collapse
- #call ⇒ Object
- #get_item ⇒ Object
-
#initialize(**props) ⇒ DropdownComponent
constructor
Initializes the Dropdown component with various customization options.
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) ⇒ DropdownComponent
Initializes the Dropdown component with various customization options.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/components/fluxbit/dropdown_component.rb', line 14 def initialize(**props) @props = props @sizing = props.delete(:sizing) || @@sizing @auto_divider = props.delete(:auto_divider), default: @@auto_divider @props[:id] ||= "dropdown-#{random_id}" add to: @props, class: [ styles[:base], styles[:sizes][@sizing], @auto_divider ? styles[:auto_divider] : nil ] remove_class_from_props(@props) end |
Instance Method Details
#call ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'app/components/fluxbit/dropdown_component.rb', line 33 def call tag.div(**@props) do tag.ul(class: styles[:ul]) do concat(safe_join(items)) if items.any? concat(Fluxbit::DropdownItemComponent.new(content).render_in(view_context)) if content.present? end end end |
#get_item ⇒ Object
29 30 31 |
# File 'app/components/fluxbit/dropdown_component.rb', line 29 def get_item @props[:id] end |