Class: PhlexKit::DropdownMenuRadioItem

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/phlex_kit/dropdown_menu/dropdown_menu_radio_item.rb

Overview

One choice in a DropdownMenuRadioGroup — a

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(name:, value:, checked: false, **attrs) ⇒ DropdownMenuRadioItem

Returns a new instance of DropdownMenuRadioItem.



6
7
8
9
10
11
# File 'app/components/phlex_kit/dropdown_menu/dropdown_menu_radio_item.rb', line 6

def initialize(name:, value:, checked: false, **attrs)
  @name = name
  @value = value
  @checked = checked
  @attrs = attrs
end

Instance Method Details

#view_template(&block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/components/phlex_kit/dropdown_menu/dropdown_menu_radio_item.rb', line 13

def view_template(&block)
  label(**mix({
    class: "pk-dropdown-menu-item pk-dropdown-menu-radio-item",
    role: "menuitemradio"
  }, @attrs)) do
    input(type: :radio, class: "pk-dropdown-menu-item-input", name: @name, value: @value, checked: @checked)
    span(class: "pk-dropdown-menu-item-indicator", aria: { hidden: "true" }) do
      # Deliberately NOT a PhlexKit::Icon: a filled selection dot is
      # geometry, not icon-library vocabulary — it stays identical across
      # icon_library settings (shadcn fills its Circle icon via CSS too).
      svg(xmlns: "http://www.w3.org/2000/svg", viewbox: "0 0 24 24", fill: "currentColor") do |s|
        s.circle(cx: "12", cy: "12", r: "5")
      end
    end
    yield if block
  end
end