Class: PhlexKit::ContextMenuSubTrigger
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::ContextMenuSubTrigger
- Defined in:
- app/components/phlex_kit/context_menu/context_menu_sub_trigger.rb
Overview
The row that opens a ContextMenuSub (trailing ▸ chevron). See context_menu.rb.
Instance Method Summary collapse
-
#initialize(**attrs) ⇒ ContextMenuSubTrigger
constructor
A new instance of ContextMenuSubTrigger.
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(**attrs) ⇒ ContextMenuSubTrigger
Returns a new instance of ContextMenuSubTrigger.
4 |
# File 'app/components/phlex_kit/context_menu/context_menu_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 21 22 23 |
# File 'app/components/phlex_kit/context_menu/context_menu_sub_trigger.rb', line 5 def view_template(&block) base = { class: "pk-context-menu-item pk-context-menu-sub-trigger", data: { phlex_kit__context_menu_target: "menuItem" } } # Defaults only when the caller didn't supply their own — `mix` fuses. base[:role] = "menuitem" unless attr_set?(:role) # -1: roving focus reaches it via arrows (focus-within opens the sub); # tabindex 0 made it a stray tab stop inside the menu. base[:tabindex] = "-1" unless attr_set?(:tabindex) base[:"aria-haspopup"] = "menu" unless aria_key_set?(:haspopup) # expanded starts false and is mirrored live by the controller's # syncSub (the reveal itself is pure CSS :hover/:focus-within). base[:"aria-expanded"] = "false" unless aria_key_set?(:expanded) div(**mix(base, @attrs)) do block&.call render Icon.new(:chevron_right, size: nil, class: "pk-context-menu-sub-chevron") end end |