Class: PhlexKit::MenubarCheckboxItem
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::MenubarCheckboxItem
- Defined in:
- app/components/phlex_kit/menubar/menubar_checkbox_item.rb
Overview
Toggleable row, mirroring shadcn/ui's MenubarCheckboxItem: a
Instance Method Summary collapse
-
#initialize(checked: false, name: nil, value: "1", **attrs) ⇒ MenubarCheckboxItem
constructor
A new instance of MenubarCheckboxItem.
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(checked: false, name: nil, value: "1", **attrs) ⇒ MenubarCheckboxItem
Returns a new instance of MenubarCheckboxItem.
6 7 8 9 10 11 |
# File 'app/components/phlex_kit/menubar/menubar_checkbox_item.rb', line 6 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
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/components/phlex_kit/menubar/menubar_checkbox_item.rb', line 13 def view_template(&block) label(**mix({ class: "pk-menubar-item pk-menubar-checkbox-item", role: "menuitemcheckbox", tabindex: "-1", aria: { checked: @checked ? "true" : "false" } }, @attrs)) do input(type: :checkbox, class: "pk-menubar-item-input", name: @name, value: @value, checked: @checked, tabindex: "-1", data: { action: "change->phlex-kit--menubar#syncChecked" }) span(class: "pk-menubar-item-indicator", aria: { hidden: "true" }) do render Icon.new(:check, size: nil) end yield if block end end |