Class: UI::MenubarRadioGroup

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

Overview

RadioGroup - Phlex implementation

Container for radio items in the menu.

Examples:

Basic usage

render UI::RadioGroup.new(value: "option1") do
  render UI::RadioItem.new(value: "option1", checked: true) { "Option 1" }
  render UI::RadioItem.new(value: "option2") { "Option 2" }
end

Instance Method Summary collapse

Methods included from MenubarRadioGroupBehavior

#menubar_radio_group_classes, #menubar_radio_group_data_attributes, #menubar_radio_group_html_attributes

Constructor Details

#initialize(value: nil, classes: "", **attributes) ⇒ MenubarRadioGroup

Returns a new instance of MenubarRadioGroup.

Parameters:

  • value (String) (defaults to: nil)

    Currently selected value

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

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



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

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

Instance Method Details

#view_template(&block) ⇒ Object



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

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