Class: PhlexKit::ContextMenuItem

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/context_menu/context_menu_item.rb

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(href: "#", checked: false, shortcut: nil, disabled: false, **attrs) ⇒ ContextMenuItem

Returns a new instance of ContextMenuItem.



3
4
5
6
7
8
9
# File 'app/components/phlex_kit/context_menu/context_menu_item.rb', line 3

def initialize(href: "#", checked: false, shortcut: nil, disabled: false, **attrs)
  @href = href
  @checked = checked
  @shortcut = shortcut
  @disabled = disabled
  @attrs = attrs
end

Instance Method Details

#view_template(&block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/components/phlex_kit/context_menu/context_menu_item.rb', line 10

def view_template(&block)
  a(**mix({ href: @href, role: "menuitem", tabindex: "-1", class: "pk-context-menu-item",
            data: { action: "click->phlex-kit--context-menu#close", phlex_kit__context_menu_target: "menuItem", disabled: @disabled } }, @attrs)) do
    if @checked
      span(class: "pk-context-menu-check") do
        render Icon.new(:check, size: 15)
      end
    end
    yield
    span(class: "pk-context-menu-shortcut") { @shortcut } if @shortcut
  end
end