Class: PhlexKit::MenubarItem
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::MenubarItem
- Defined in:
- app/components/phlex_kit/menubar/menubar_item.rb
Overview
Instance Method Summary collapse
-
#initialize(as: :a, href: "#", shortcut: nil, **attrs) ⇒ MenubarItem
constructor
A new instance of MenubarItem.
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(as: :a, href: "#", shortcut: nil, **attrs) ⇒ MenubarItem
Returns a new instance of MenubarItem.
5 6 7 8 9 10 |
# File 'app/components/phlex_kit/menubar/menubar_item.rb', line 5 def initialize(as: :a, href: "#", shortcut: nil, **attrs) @as = as.to_sym @href = href @shortcut = shortcut @attrs = attrs end |
Instance Method Details
#view_template(&block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/components/phlex_kit/menubar/menubar_item.rb', line 12 def view_template(&block) base = { role: "menuitem", tabindex: "-1", class: "pk-menubar-item", data: { action: "click->phlex-kit--menubar#close" } } base[:href] = @href unless @as == :div send(@as, **mix(base, @attrs)) do block&.call span(class: "pk-menubar-shortcut") { @shortcut } if @shortcut end end |