Module: UI::DropdownMenuBehavior
- Included in:
- DropdownMenu, DropdownMenuComponent
- Defined in:
- app/behaviors/ui/dropdown_menu_behavior.rb
Overview
UI::DropdownMenuBehavior
Instance Method Summary collapse
-
#dropdown_menu_classes ⇒ Object
Returns combined CSS classes for the dropdown menu.
-
#dropdown_menu_data_attributes ⇒ Object
Returns data attributes for Stimulus controller.
-
#dropdown_menu_html_attributes ⇒ Object
Returns HTML attributes for the dropdown menu container When used with asChild, these attributes will be yielded to the child.
Instance Method Details
#dropdown_menu_classes ⇒ Object
Returns combined CSS classes for the dropdown menu
47 48 49 50 51 52 53 |
# File 'app/behaviors/ui/dropdown_menu_behavior.rb', line 47 def classes_value = respond_to?(:classes, true) ? classes : @classes TailwindMerge::Merger.new.merge([ "relative inline-block text-left", classes_value ].compact.join(" ")) end |
#dropdown_menu_data_attributes ⇒ Object
Returns data attributes for Stimulus controller
56 57 58 59 60 61 62 63 64 |
# File 'app/behaviors/ui/dropdown_menu_behavior.rb', line 56 def attributes_value = respond_to?(:attributes, true) ? attributes : @attributes (attributes_value&.fetch(:data, {}) || {}).merge({ controller: "ui--dropdown", "ui--dropdown-placement-value": @placement, "ui--dropdown-offset-value": @offset, "ui--dropdown-flip-value": @flip }) end |
#dropdown_menu_html_attributes ⇒ Object
Returns HTML attributes for the dropdown menu container When used with asChild, these attributes will be yielded to the child
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/behaviors/ui/dropdown_menu_behavior.rb', line 32 def attrs = { data: } # Only add container classes if not using asChild # When asChild is true, we don't render a wrapper unless @as_child attrs[:class] = end attrs end |