Class: UI::MenubarRadioItemComponent

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

Overview

RadioItemComponent - ViewComponent implementation

A radio menu item (only one can be selected).

Examples:

Basic usage

render UI::RadioItemComponent.new(value: "light", checked: true) { "Light" }

Instance Method Summary collapse

Methods included from MenubarRadioItemBehavior

#menubar_radio_item_classes, #menubar_radio_item_data_attributes, #menubar_radio_item_html_attributes

Constructor Details

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

Returns a new instance of MenubarRadioItemComponent.



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

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

Instance Method Details

#callObject



20
21
22
23
24
# File 'app/view_components/ui/menubar_radio_item_component.rb', line 20

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