Class: PhlexKit::ContextMenu

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/context_menu/context_menu.rb

Overview

Right-click menu, positioned at the cursor with CSS. Ported from ruby_ui's RubyUI::ContextMenu. Compose ContextMenu > (ContextMenuTrigger + ContextMenuContent > ContextMenuItem/Label/Separator). phlex-kit--context-menu.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(**attrs) ⇒ ContextMenu

Returns a new instance of ContextMenu.



6
# File 'app/components/phlex_kit/context_menu/context_menu.rb', line 6

def initialize(**attrs) = (@attrs = attrs)

Instance Method Details

#view_templateObject



7
8
9
10
11
12
13
14
15
16
17
# File 'app/components/phlex_kit/context_menu/context_menu.rb', line 7

def view_template(&)
  div(**mix({
    class: "pk-context-menu",
    data: {
      controller: "phlex-kit--context-menu",
      # focusout: tabbing (or otherwise moving real focus) out of the
      # menu closes the open [popover=manual] panel (menubar's pattern).
      action: "focusout->phlex-kit--context-menu#onFocusout"
    }
  }, @attrs), &)
end