Module: UI::ContextMenuTriggerBehavior
- Included in:
- ContextMenuTrigger, ContextMenuTriggerComponent
- Defined in:
- app/behaviors/ui/context_menu_trigger_behavior.rb
Overview
ContextMenuTriggerBehavior
Shared behavior for ContextMenuTrigger component across ERB, ViewComponent, and Phlex implementations.
Instance Method Summary collapse
-
#context_menu_trigger_classes ⇒ Object
Returns combined CSS classes for the trigger.
-
#context_menu_trigger_data_attributes ⇒ Object
Returns data attributes for Stimulus action.
-
#context_menu_trigger_html_attributes ⇒ Object
Returns HTML attributes for the context menu trigger.
Instance Method Details
#context_menu_trigger_classes ⇒ Object
Returns combined CSS classes for the trigger
16 17 18 19 20 21 22 |
# File 'app/behaviors/ui/context_menu_trigger_behavior.rb', line 16 def classes_value = respond_to?(:classes, true) ? classes : @classes TailwindMerge::Merger.new.merge([ "flex h-[150px] w-[300px] items-center justify-center rounded-md border border-dashed text-sm", classes_value ].compact.join(" ")) end |
#context_menu_trigger_data_attributes ⇒ Object
Returns data attributes for Stimulus action
25 26 27 28 29 30 31 |
# File 'app/behaviors/ui/context_menu_trigger_behavior.rb', line 25 def attributes_value = respond_to?(:attributes, true) ? attributes : @attributes (attributes_value&.fetch(:data, {}) || {}).merge({ action: "contextmenu->ui--context-menu#open", "ui--context-menu-target": "trigger" }) end |
#context_menu_trigger_html_attributes ⇒ Object
Returns HTML attributes for the context menu trigger
8 9 10 11 12 13 |
# File 'app/behaviors/ui/context_menu_trigger_behavior.rb', line 8 def { class: , data: } end |