Module: UI::MenubarCheckboxItemBehavior
- Included in:
- MenubarCheckboxItem, MenubarCheckboxItemComponent
- Defined in:
- app/behaviors/ui/menubar_checkbox_item_behavior.rb
Overview
MenubarCheckboxItemBehavior
Shared behavior for MenubarCheckboxItem component across ERB, ViewComponent, and Phlex implementations.
Instance Method Summary collapse
-
#menubar_checkbox_item_classes ⇒ Object
Returns combined CSS classes for the checkbox item.
-
#menubar_checkbox_item_data_attributes ⇒ Object
Returns data attributes for the checkbox item.
-
#menubar_checkbox_item_html_attributes ⇒ Object
Returns HTML attributes for the checkbox item.
Instance Method Details
#menubar_checkbox_item_classes ⇒ Object
Returns combined CSS classes for the checkbox item
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/behaviors/ui/menubar_checkbox_item_behavior.rb', line 24 def classes_value = respond_to?(:classes, true) ? classes : @classes TailwindMerge::Merger.new.merge([ "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 whitespace-nowrap", "data-[disabled]:pointer-events-none data-[disabled]:opacity-50", "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", classes_value ].compact.join(" ")) end |
#menubar_checkbox_item_data_attributes ⇒ Object
Returns data attributes for the checkbox item
38 39 40 41 42 43 44 45 |
# File 'app/behaviors/ui/menubar_checkbox_item_behavior.rb', line 38 def attributes_value = respond_to?(:attributes, true) ? attributes : @attributes (attributes_value&.fetch(:data, {}) || {}).merge({ "ui--menubar-target": "item", action: "click->ui--menubar#selectItem mouseenter->ui--menubar#trackHoveredItem", state: checked? ? "checked" : "unchecked" }) end |
#menubar_checkbox_item_html_attributes ⇒ Object
Returns HTML attributes for the checkbox item
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/behaviors/ui/menubar_checkbox_item_behavior.rb', line 8 def attrs = { class: , data: , role: "menuitemcheckbox", "aria-checked": checked?.to_s, tabindex: "-1" } # Add disabled attribute if specified attrs[:"data-disabled"] = "" if disabled? attrs end |