Module: UI::DropdownMenuSubContentBehavior
- Included in:
- DropdownMenuSubContent, DropdownMenuSubContentComponent
- Defined in:
- app/behaviors/ui/dropdown_menu_sub_content_behavior.rb
Overview
DropdownMenuSubContentBehavior
Shared behavior for DropdownMenuSubContent component across ERB, ViewComponent, and Phlex implementations.
Instance Method Summary collapse
-
#dropdown_menu_sub_content_classes ⇒ Object
Returns combined CSS classes for the sub content.
-
#dropdown_menu_sub_content_data_attributes ⇒ Object
Returns data attributes for Stimulus.
-
#dropdown_menu_sub_content_html_attributes ⇒ Object
Returns HTML attributes for the sub content.
Instance Method Details
#dropdown_menu_sub_content_classes ⇒ Object
Returns combined CSS classes for the sub content
18 19 20 21 22 23 24 25 26 27 |
# File 'app/behaviors/ui/dropdown_menu_sub_content_behavior.rb', line 18 def classes_value = respond_to?(:classes, true) ? classes : @classes base_classes = "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[11rem] origin-(--ui-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg absolute" TailwindMerge::Merger.new.merge([ "hidden absolute", base_classes, classes_value ].compact.join(" ")) end |
#dropdown_menu_sub_content_data_attributes ⇒ Object
Returns data attributes for Stimulus
30 31 32 33 34 35 36 37 |
# File 'app/behaviors/ui/dropdown_menu_sub_content_behavior.rb', line 30 def attributes_value = respond_to?(:attributes, true) ? attributes : @attributes (attributes_value&.fetch(:data, {}) || {}).merge({ state: "closed", side: @side || "right", align: @align || "start" }) end |
#dropdown_menu_sub_content_html_attributes ⇒ Object
Returns HTML attributes for the sub content
8 9 10 11 12 13 14 15 |
# File 'app/behaviors/ui/dropdown_menu_sub_content_behavior.rb', line 8 def { class: , data: , role: "menu", tabindex: "-1" } end |