Module: UI::ContextMenuLabelBehavior

Included in:
ContextMenuLabel, ContextMenuLabelComponent
Defined in:
app/behaviors/ui/context_menu_label_behavior.rb

Overview

ContextMenuLabelBehavior

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

Instance Method Summary collapse

Instance Method Details

#context_menu_label_classesObject

Returns combined CSS classes for the label



16
17
18
19
20
21
22
23
24
25
# File 'app/behaviors/ui/context_menu_label_behavior.rb', line 16

def context_menu_label_classes
  classes_value = respond_to?(:classes, true) ? classes : @classes
  base_classes = "text-foreground px-2 py-1.5 text-sm font-medium"

  TailwindMerge::Merger.new.merge([
    base_classes,
    @inset ? "pl-8" : nil,
    classes_value
  ].compact.join(" "))
end

#context_menu_label_data_attributesObject

Returns data attributes for the label



28
29
30
31
32
# File 'app/behaviors/ui/context_menu_label_behavior.rb', line 28

def context_menu_label_data_attributes
  {
    inset: @inset
  }
end

#context_menu_label_html_attributesObject

Returns HTML attributes for the context menu label



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

def context_menu_label_html_attributes
  {
    class: context_menu_label_classes,
    data: context_menu_label_data_attributes
  }
end