Module: UI::MenubarShortcutBehavior

Included in:
MenubarShortcut, MenubarShortcutComponent
Defined in:
app/behaviors/ui/menubar_shortcut_behavior.rb

Overview

MenubarShortcutBehavior

Shared behavior for MenubarShortcut component across ERB, ViewComponent, and Phlex implementations.

Instance Method Summary collapse

Instance Method Details

Returns combined CSS classes for the shortcut



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

def menubar_shortcut_classes
  classes_value = respond_to?(:classes, true) ? classes : @classes
  TailwindMerge::Merger.new.merge([
    "text-muted-foreground ml-auto text-xs tracking-widest",
    classes_value
  ].compact.join(" "))
end

Returns data attributes for the shortcut



25
26
27
28
# File 'app/behaviors/ui/menubar_shortcut_behavior.rb', line 25

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

Returns HTML attributes for the shortcut



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

def menubar_shortcut_html_attributes
  {
    class: menubar_shortcut_classes,
    data: menubar_shortcut_data_attributes
  }
end