Class: PhlexKit::CommandItem

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/command/command_item.rb

Overview

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(value:, text: "", href: "#", disabled: false, **attrs) ⇒ CommandItem

Returns a new instance of CommandItem.



8
9
10
11
12
13
14
# File 'app/components/phlex_kit/command/command_item.rb', line 8

def initialize(value:, text: "", href: "#", disabled: false, **attrs)
  @value = value
  @text = text
  @href = href
  @disabled = disabled
  @attrs = attrs
end

Instance Method Details

#view_templateObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/components/phlex_kit/command/command_item.rb', line 16

def view_template(&)
  a(**mix({
    class: "pk-command-item",
    href: @href,
    role: "option",
    aria: { disabled: (@disabled ? "true" : nil) },
    data: {
      phlex_kit__command_target: "item",
      value: @value,
      text: @text,
      disabled: (@disabled ? "true" : nil)
    }
  }, @attrs), &)
end