Class: PhlexKit::DropdownMenuItem
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::DropdownMenuItem
- Defined in:
- app/components/phlex_kit/dropdown_menu/dropdown_menu_item.rb
Overview
A menu row in a PhlexKit::DropdownMenuContent. as: :a (default, pass href:) or
:div (e.g. to wrap a button_to). Closes the menu on click. See dropdown_menu.rb.
Instance Method Summary collapse
-
#initialize(as: :a, href: "#", **attrs) ⇒ DropdownMenuItem
constructor
A new instance of DropdownMenuItem.
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(as: :a, href: "#", **attrs) ⇒ DropdownMenuItem
Returns a new instance of DropdownMenuItem.
5 6 7 8 9 |
# File 'app/components/phlex_kit/dropdown_menu/dropdown_menu_item.rb', line 5 def initialize(as: :a, href: "#", **attrs) @as = as.to_sym @href = href @attrs = attrs end |
Instance Method Details
#view_template(&block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'app/components/phlex_kit/dropdown_menu/dropdown_menu_item.rb', line 11 def view_template(&block) base = { role: "menuitem", tabindex: "-1", class: "pk-dropdown-menu-item", data: { phlex_kit__dropdown_menu_target: "menuItem", action: "click->phlex-kit--dropdown-menu#close" } } base[:href] = @href unless @as == :div send(@as, **mix(base, @attrs), &block) end |