Class: UI::ContextMenuComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
ContextMenuBehavior
Defined in:
app/view_components/ui/context_menu_component.rb

Overview

ContextMenuComponent - ViewComponent implementation

Instance Method Summary collapse

Methods included from ContextMenuBehavior

#context_menu_classes, #context_menu_data_attributes, #context_menu_html_attributes

Constructor Details

#initialize(classes: "", **attributes) ⇒ ContextMenuComponent

Returns a new instance of ContextMenuComponent.



7
8
9
10
# File 'app/view_components/ui/context_menu_component.rb', line 7

def initialize(classes: "", **attributes)
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
# File 'app/view_components/ui/context_menu_component.rb', line 12

def call
  attrs = context_menu_html_attributes
  attrs[:data] = attrs[:data].merge(@attributes.fetch(:data, {}))

   :div, **attrs.merge(@attributes.except(:data)) do
    content
  end
end