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
-
#dropdown_menu_label_classes ⇒ Object
Returns combined CSS classes for the label.
-
#dropdown_menu_label_data_attributes ⇒ Object
Returns data attributes.
-
#dropdown_menu_label_html_attributes ⇒ Object
Returns HTML attributes for the label.
Instance Method Details
#dropdown_menu_label_classes ⇒ Object
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 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 |
#dropdown_menu_label_data_attributes ⇒ Object
Returns data attributes
24 25 26 27 28 29 |
# File 'app/behaviors/ui/dropdown_menu_label_behavior.rb', line 24 def attributes_value = respond_to?(:attributes, true) ? attributes : @attributes data_attrs = (attributes_value&.fetch(:data, {}) || {}).dup data_attrs[:inset] = @inset if @inset data_attrs end |
#dropdown_menu_label_html_attributes ⇒ Object
Returns HTML attributes for the label
8 9 10 11 12 13 |
# File 'app/behaviors/ui/dropdown_menu_label_behavior.rb', line 8 def { class: , data: } end |