Module: UI::ContextMenuContentBehavior
- Included in:
- ContextMenuContent, ContextMenuContentComponent
- Defined in:
- app/behaviors/ui/context_menu_content_behavior.rb
Overview
ContextMenuContentBehavior
Shared behavior for ContextMenuContent component across ERB, ViewComponent, and Phlex implementations.
Instance Method Summary collapse
-
#context_menu_content_classes ⇒ Object
Returns combined CSS classes for the content.
-
#context_menu_content_data_attributes ⇒ Object
Returns data attributes for Stimulus target.
-
#context_menu_content_html_attributes ⇒ Object
Returns HTML attributes for the context menu content.
Instance Method Details
#context_menu_content_classes ⇒ Object
Returns combined CSS classes for the content
18 19 20 21 22 23 24 25 26 27 |
# File 'app/behaviors/ui/context_menu_content_behavior.rb', line 18 def classes_value = respond_to?(:classes, true) ? classes : @classes base_classes = "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-md" TailwindMerge::Merger.new.merge([ "hidden", base_classes, classes_value ].compact.join(" ")) end |
#context_menu_content_data_attributes ⇒ Object
Returns data attributes for Stimulus target
30 31 32 33 34 35 36 |
# File 'app/behaviors/ui/context_menu_content_behavior.rb', line 30 def attributes_value = respond_to?(:attributes, true) ? attributes : @attributes (attributes_value&.fetch(:data, {}) || {}).merge({ "ui--context-menu-target": "content", state: "closed" }) end |
#context_menu_content_html_attributes ⇒ Object
Returns HTML attributes for the context menu content
8 9 10 11 12 13 14 15 |
# File 'app/behaviors/ui/context_menu_content_behavior.rb', line 8 def { class: , data: , role: "menu", tabindex: "-1" } end |