Class: PhlexKit::ContextMenuRadioItem

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/phlex_kit/context_menu/context_menu_radio_item.rb

Overview

One choice in a ContextMenuRadioGroup — a

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

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

Returns a new instance of ContextMenuRadioItem.



6
7
8
9
10
11
# File 'app/components/phlex_kit/context_menu/context_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
# File 'app/components/phlex_kit/context_menu/context_menu_radio_item.rb', line 13

def view_template(&block)
  label(**mix({
    class: "pk-context-menu-item pk-context-menu-radio-item",
    role: "menuitemradio"
  }, @attrs)) do
    input(type: :radio, class: "pk-context-menu-item-input", name: @name, value: @value, checked: @checked)
    span(class: "pk-context-menu-item-indicator", aria: { hidden: "true" }) do
      # A filled selection dot is geometry, not icon-library vocabulary —
      # identical across icon_library settings (matches the dropdown).
      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