Class: PhlexKit::MenubarSubTrigger

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

Overview

The row that opens a MenubarSub (trailing ▸ chevron). See menubar.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(**attrs) ⇒ MenubarSubTrigger

Returns a new instance of MenubarSubTrigger.



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

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

Instance Method Details

#view_template(&block) ⇒ Object



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

def view_template(&block)
  div(**mix({
    class: "pk-menubar-item pk-menubar-sub-trigger",
    role: "menuitem",
    # -1: the roving focus reaches it via arrows (focus-within opens the
    # sub); tabindex 0 made it a stray tab stop inside the open panel.
    tabindex: "-1",
    # expanded starts false; the sub is revealed by CSS (:hover /
    # :focus-within), so MenubarSub's syncSub actions mirror that state
    # onto this attribute.
    aria: { haspopup: "menu", expanded: "false" }
  }, @attrs)) do
    block&.call
    render Icon.new(:chevron_right, size: nil, class: "pk-menubar-sub-chevron")
  end
end