Module: UI::ContextMenuCheckboxItemBehavior
- Included in:
- ContextMenuCheckboxItem, ContextMenuCheckboxItemComponent
- Defined in:
- app/behaviors/ui/context_menu_checkbox_item_behavior.rb
Overview
ContextMenuCheckboxItemBehavior
Shared behavior for ContextMenuCheckboxItem component across ERB, ViewComponent, and Phlex implementations.
Instance Method Summary collapse
-
#context_menu_checkbox_item_classes ⇒ Object
Returns combined CSS classes for the checkbox item.
-
#context_menu_checkbox_item_data_attributes ⇒ Object
Returns data attributes for the checkbox item.
-
#context_menu_checkbox_item_html_attributes ⇒ Object
Returns HTML attributes for the checkbox item.
Instance Method Details
#context_menu_checkbox_item_classes ⇒ Object
Returns combined CSS classes for the checkbox item
19 20 21 22 23 24 |
# File 'app/behaviors/ui/context_menu_checkbox_item_behavior.rb', line 19 def classes_value = respond_to?(:classes, true) ? classes : @classes base_classes = "hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4" TailwindMerge::Merger.new.merge([base_classes, classes_value].compact.join(" ")) end |
#context_menu_checkbox_item_data_attributes ⇒ Object
Returns data attributes for the checkbox item
27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/behaviors/ui/context_menu_checkbox_item_behavior.rb', line 27 def attributes_value = respond_to?(:attributes, true) ? attributes : @attributes existing_action = (attributes_value&.fetch(:data, {}) || {}).fetch(:action, "") combined_action = [existing_action, "mouseenter->ui--context-menu#trackHoveredItem"].reject(&:empty?).join(" ") (attributes_value&.fetch(:data, {}) || {}).merge({ "ui--context-menu-target": "item", action: combined_action, state: @checked ? "checked" : "unchecked" }) end |
#context_menu_checkbox_item_html_attributes ⇒ Object
Returns HTML attributes for the checkbox item
8 9 10 11 12 13 14 15 16 |
# File 'app/behaviors/ui/context_menu_checkbox_item_behavior.rb', line 8 def { class: , data: , role: "menuitemcheckbox", "aria-checked": @checked.to_s, tabindex: "-1" } end |