Class: UI::ContextMenuRadioItemComponent

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

Overview

RadioItemComponent - ViewComponent implementation

Instance Method Summary collapse

Methods included from ContextMenuRadioItemBehavior

#context_menu_radio_item_classes, #context_menu_radio_item_data_attributes, #context_menu_radio_item_html_attributes

Constructor Details

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

Returns a new instance of ContextMenuRadioItemComponent.



7
8
9
10
11
# File 'app/view_components/ui/context_menu_radio_item_component.rb', line 7

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

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/view_components/ui/context_menu_radio_item_component.rb', line 13

def call
  attrs = context_menu_radio_item_html_attributes
  attrs[:data] = attrs[:data].merge(@attributes.fetch(:data, {}))

   :div, **attrs.merge(@attributes.except(:data)) do
    safe_join([
      (:span, class: "pointer-events-none absolute left-2 flex size-3.5 items-center justify-center") do
        render_circle_icon if @checked
      end,
      content
    ])
  end
end