Module: UI::MenubarSubBehavior

Included in:
MenubarSub, MenubarSubComponent
Defined in:
app/behaviors/ui/menubar_sub_behavior.rb

Overview

MenubarSubBehavior

Shared behavior for MenubarSub component across ERB, ViewComponent, and Phlex implementations. This is a wrapper for submenus within the menubar menu.

Instance Method Summary collapse

Instance Method Details

Returns combined CSS classes for the submenu wrapper



17
18
19
20
21
22
23
# File 'app/behaviors/ui/menubar_sub_behavior.rb', line 17

def menubar_sub_classes
  classes_value = respond_to?(:classes, true) ? classes : @classes
  TailwindMerge::Merger.new.merge([
    "relative",
    classes_value
  ].compact.join(" "))
end

Returns data attributes for the submenu wrapper



26
27
28
29
# File 'app/behaviors/ui/menubar_sub_behavior.rb', line 26

def menubar_sub_data_attributes
  attributes_value = respond_to?(:attributes, true) ? attributes : @attributes
  attributes_value&.fetch(:data, {}) || {}
end

Returns HTML attributes for the submenu wrapper



9
10
11
12
13
14
# File 'app/behaviors/ui/menubar_sub_behavior.rb', line 9

def menubar_sub_html_attributes
  {
    class: menubar_sub_classes,
    data: menubar_sub_data_attributes
  }
end