Module: UI::MenubarBehavior
- Included in:
- Menubar, MenubarComponent
- Defined in:
- app/behaviors/ui/menubar_behavior.rb
Overview
UI::MenubarBehavior
Instance Method Summary collapse
-
#menubar_classes ⇒ Object
Returns combined CSS classes for the menubar.
-
#menubar_data_attributes ⇒ Object
Returns data attributes for Stimulus controller.
-
#menubar_html_attributes ⇒ Object
Returns HTML attributes for the menubar container.
Instance Method Details
#menubar_classes ⇒ Object
Returns combined CSS classes for the menubar
61 62 63 64 65 66 67 |
# File 'app/behaviors/ui/menubar_behavior.rb', line 61 def classes_value = respond_to?(:classes, true) ? classes : @classes TailwindMerge::Merger.new.merge([ "bg-background flex h-9 items-center gap-1 rounded-md border p-1 shadow-xs", classes_value ].compact.join(" ")) end |
#menubar_data_attributes ⇒ Object
Returns data attributes for Stimulus controller
70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/behaviors/ui/menubar_behavior.rb', line 70 def attributes_value = respond_to?(:attributes, true) ? attributes : @attributes base_data = { controller: "ui--menubar" } # Add loop value if specified base_data[:"ui--menubar-loop-value"] = @loop if defined?(@loop) && @loop (attributes_value&.fetch(:data, {}) || {}).merge(base_data) end |
#menubar_html_attributes ⇒ Object
Returns HTML attributes for the menubar container
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/behaviors/ui/menubar_behavior.rb', line 47 def attrs = { class: , data: , role: "menubar" } # Add aria-label if provided attrs[:"aria-label"] = @aria_label if defined?(@aria_label) && @aria_label attrs end |