Class: PhlexKit::ContextMenuCheckboxItem

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/phlex_kit/context_menu/context_menu_checkbox_item.rb

Overview

Toggleable row, mirroring shadcn/ui's ContextMenuCheckboxItem: a

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(checked: false, name: nil, value: "1", **attrs) ⇒ ContextMenuCheckboxItem

Returns a new instance of ContextMenuCheckboxItem.



7
8
9
10
11
12
# File 'app/components/phlex_kit/context_menu/context_menu_checkbox_item.rb', line 7

def initialize(checked: false, name: nil, value: "1", **attrs)
  @checked = checked
  @name = name
  @value = value
  @attrs = attrs
end

Instance Method Details

#view_template(&block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/components/phlex_kit/context_menu/context_menu_checkbox_item.rb', line 14

def view_template(&block)
  label(**mix({
    class: "pk-context-menu-item pk-context-menu-checkbox-item",
    role: "menuitemcheckbox"
  }, @attrs)) do
    input(type: :checkbox, class: "pk-context-menu-item-input", name: @name, value: @value, checked: @checked)
    span(class: "pk-context-menu-item-indicator", aria: { hidden: "true" }) do
      render Icon.new(:check, size: nil)
    end
    yield if block
  end
end