Class: PhlexKit::NavigationMenuLink

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

Overview

Plain link item (top-level or inside a panel). Hover fires #switch like a trigger: for a TOP-LEVEL link the closest menu item has no panel, so an open sibling panel closes; for a link INSIDE a panel the closest item IS the open menu, so switch is a no-op and the panel stays. See navigation_menu.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(href: "#", **attrs) ⇒ NavigationMenuLink

Returns a new instance of NavigationMenuLink.



8
9
10
11
# File 'app/components/phlex_kit/navigation_menu/navigation_menu_link.rb', line 8

def initialize(href: "#", **attrs)
  @href = href
  @attrs = attrs
end

Instance Method Details

#view_templateObject



13
14
15
16
17
18
19
20
21
22
# File 'app/components/phlex_kit/navigation_menu/navigation_menu_link.rb', line 13

def view_template(&)
  a(**mix({
    class: "pk-navigation-menu-link",
    href: @href,
    # click: closes the open panel on real activation (and swallows the
    # default href="#" the way dropdown_menu_controller.js's close() does
    # — see menubar_controller.js#close).
    data: { action: "mouseenter->phlex-kit--menubar#switch click->phlex-kit--menubar#close" }
  }, @attrs), &)
end