Class: PhlexKit::MenubarRadioItem

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/menubar/menubar_radio_item.rb

Overview

One choice in a MenubarRadioGroup — a

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

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

Returns a new instance of MenubarRadioItem.



6
7
8
9
10
11
# File 'app/components/phlex_kit/menubar/menubar_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
30
# File 'app/components/phlex_kit/menubar/menubar_radio_item.rb', line 13

def view_template(&block)
  label(**mix({
    class: "pk-menubar-item pk-menubar-radio-item",
    role: "menuitemradio",
    tabindex: "-1",
    aria: { checked: @checked ? "true" : "false" }
  }, @attrs)) do
    input(type: :radio, class: "pk-menubar-item-input", name: @name, value: @value, checked: @checked,
          tabindex: "-1", data: { action: "change->phlex-kit--menubar#syncChecked" })
    span(class: "pk-menubar-item-indicator", aria: { hidden: "true" }) do
      # A filled selection dot is geometry, not icon-library vocabulary.
      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