Class: UI::DropdownMenuRadioItem

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

Overview

RadioItem - Phlex implementation

Menu item with radio state for exclusive selection within a group. Uses DropdownMenuRadioItemBehavior concern for shared styling logic.

Examples:

Radio item

render UI::RadioItem.new(value: "top", checked: true) { "Top" }

Instance Method Summary collapse

Methods included from DropdownMenuRadioItemBehavior

#dropdown_menu_radio_item_classes, #dropdown_menu_radio_item_data_attributes, #dropdown_menu_radio_item_html_attributes, #radio_indicator

Constructor Details

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

Returns a new instance of DropdownMenuRadioItem.

Parameters:

  • value (String)

    Value of the radio item

  • checked (Boolean) (defaults to: false)

    Whether item 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



18
19
20
21
22
23
24
# File 'app/components/ui/dropdown_menu_radio_item.rb', line 18

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

Instance Method Details

#view_template(&block) ⇒ Object



26
27
28
29
30
31
# File 'app/components/ui/dropdown_menu_radio_item.rb', line 26

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