Class: PhlexKit::DropdownMenu

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

Overview

Dropdown menu, ported from ruby_ui's RubyUI::DropdownMenu. Keeps the Stimulus controller (toggle, click-outside, keyboard nav) but — like PhlexKit::Select — drops the @floating-ui/dom dependency and positions the panel with CSS. Compose Trigger + Content (+ Item / Label / Separator). Tailwind → vanilla .pk-dropdown-menu* (dropdown_menu.css).

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(**attrs) ⇒ DropdownMenu

Returns a new instance of DropdownMenu.



8
9
10
# File 'app/components/phlex_kit/dropdown_menu/dropdown_menu.rb', line 8

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

Instance Method Details

#view_template(&block) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'app/components/phlex_kit/dropdown_menu/dropdown_menu.rb', line 12

def view_template(&block)
  div(**mix({
    class: "pk-dropdown-menu",
    data: {
      controller: "phlex-kit--dropdown-menu",
      action: "click@window->phlex-kit--dropdown-menu#onClickOutside"
    }
  }, @attrs), &block)
end