Class: PhlexKit::MenubarTrigger

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

Overview

See menubar.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(**attrs) ⇒ MenubarTrigger

Returns a new instance of MenubarTrigger.



4
# File 'app/components/phlex_kit/menubar/menubar_trigger.rb', line 4

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

Instance Method Details

#view_templateObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/components/phlex_kit/menubar/menubar_trigger.rb', line 5

def view_template(&)
  base = {
    type: :button,
    class: "pk-menubar-trigger",
    data: { action: "click->phlex-kit--menubar#toggle mouseenter->phlex-kit--menubar#switch" }
  }
  # Defaults only when the caller didn't supply their own — `mix` fuses.
  base[:role] = "menuitem" unless attr_set?(:role)
  base[:"aria-haspopup"] = "menu" unless aria_key_set?(:haspopup)
  base[:"aria-expanded"] = "false" unless aria_key_set?(:expanded)
  button(**mix(base, @attrs), &)
end