Class: UI::DropdownMenuCheckboxItem

Inherits:
Phlex::HTML
  • Object
show all
Includes:
DropdownMenuCheckboxItemBehavior
Defined in:
app/components/ui/dropdown_menu_checkbox_item.rb

Overview

CheckboxItem - Phlex implementation

Menu item with checkbox state that can be toggled. Uses DropdownMenuCheckboxItemBehavior concern for shared styling logic.

Examples:

Basic checkbox item

render UI::CheckboxItem.new(checked: true) { "Show Status Bar" }

Instance Method Summary collapse

Methods included from DropdownMenuCheckboxItemBehavior

#checkbox_indicator, #dropdown_menu_checkbox_item_classes, #dropdown_menu_checkbox_item_data_attributes, #dropdown_menu_checkbox_item_html_attributes

Constructor Details

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

Returns a new instance of DropdownMenuCheckboxItem.

Parameters:

  • checked (Boolean) (defaults to: false)

    Whether checkbox is checked

  • disabled (Boolean) (defaults to: false)

    Whether item is disabled

  • classes (String) (defaults to: "")

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



17
18
19
20
21
22
# File 'app/components/ui/dropdown_menu_checkbox_item.rb', line 17

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

Instance Method Details

#view_template(&block) ⇒ Object



24
25
26
27
28
29
# File 'app/components/ui/dropdown_menu_checkbox_item.rb', line 24

def view_template(&block)
  div(**dropdown_menu_checkbox_item_html_attributes.deep_merge(@attributes)) do
    render_checkbox_indicator
    yield if block_given?
  end
end