Class: UI::MenubarCheckboxItemComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
MenubarCheckboxItemBehavior
Defined in:
app/view_components/ui/menubar_checkbox_item_component.rb

Overview

CheckboxItemComponent - ViewComponent implementation

A toggleable checkbox menu item.

Examples:

Basic usage

render UI::CheckboxItemComponent.new(checked: true) { "Show Toolbar" }

Instance Method Summary collapse

Methods included from MenubarCheckboxItemBehavior

#menubar_checkbox_item_classes, #menubar_checkbox_item_data_attributes, #menubar_checkbox_item_html_attributes

Constructor Details

#initialize(checked: false, disabled: false, classes: "", **attributes) ⇒ MenubarCheckboxItemComponent

Returns a new instance of MenubarCheckboxItemComponent.



12
13
14
15
16
17
# File 'app/view_components/ui/menubar_checkbox_item_component.rb', line 12

def initialize(checked: false, disabled: false, classes: "", **attributes)
  @checked = checked
  @disabled = disabled
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#callObject



19
20
21
22
23
# File 'app/view_components/ui/menubar_checkbox_item_component.rb', line 19

def call
   :div, **menubar_checkbox_item_html_attributes.deep_merge(@attributes) do
    render_check_icon + (:span, content)
  end
end