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(open: false, **attrs) ⇒ DropdownMenu

open: true renders the menu open on connect (matching Collapsible's kwarg -> Stimulus value -> connect flow).



10
11
12
13
# File 'app/components/phlex_kit/dropdown_menu/dropdown_menu.rb', line 10

def initialize(open: false, **attrs)
  @open = open
  @attrs = attrs
end

Instance Method Details

#view_template(&block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'app/components/phlex_kit/dropdown_menu/dropdown_menu.rb', line 15

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