Module: UI::DropdownMenuLabelBehavior

Included in:
DropdownMenuLabel, DropdownMenuLabelComponent
Defined in:
app/behaviors/ui/dropdown_menu_label_behavior.rb

Overview

DropdownMenuLabelBehavior

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

Instance Method Summary collapse

Instance Method Details

Returns combined CSS classes for the label



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

def dropdown_menu_label_classes
  classes_value = respond_to?(:classes, true) ? classes : @classes
  base_classes = "px-2 py-1.5 text-sm font-medium data-[inset=true]:pl-8"

  TailwindMerge::Merger.new.merge([base_classes, classes_value].compact.join(" "))
end

Returns data attributes



24
25
26
27
28
29
# File 'app/behaviors/ui/dropdown_menu_label_behavior.rb', line 24

def dropdown_menu_label_data_attributes
  attributes_value = respond_to?(:attributes, true) ? attributes : @attributes
  data_attrs = (attributes_value&.fetch(:data, {}) || {}).dup
  data_attrs[:inset] = @inset if @inset
  data_attrs
end

Returns HTML attributes for the label



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

def dropdown_menu_label_html_attributes
  {
    class: dropdown_menu_label_classes,
    data: dropdown_menu_label_data_attributes
  }
end