Class: PhlexKit::MenubarContent

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

Overview

Dropdown panel of a MenubarMenu. See menubar.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(**attrs) ⇒ MenubarContent

Returns a new instance of MenubarContent.



4
5
6
7
8
9
# File 'app/components/phlex_kit/menubar/menubar_content.rb', line 4

def initialize(**attrs)
  # Default id so the controller can wire the trigger's aria-controls to
  # this panel in menuTargetConnected (same pattern as accordion).
  @id = attrs.delete(:id) || "pk-menubar-content-#{SecureRandom.hex(4)}"
  @attrs = attrs
end

Instance Method Details

#view_templateObject



11
12
13
14
15
16
17
# File 'app/components/phlex_kit/menubar/menubar_content.rb', line 11

def view_template(&)
  base = { id: @id, class: "pk-menubar-content" }
  # Defaults only when the caller didn't supply their own — `mix` fuses.
  base[:popover] = "manual" unless attr_set?(:popover)
  base[:role] = "menu" unless attr_set?(:role)
  div(**mix(base, @attrs), &)
end