Class: PhlexKit::ComboboxTrigger

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/combobox/combobox_trigger.rb

Overview

The closed-state button for PhlexKit::Combobox — shows the placeholder until the controller writes the selected item text (or "N ") into the content span. See combobox.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(placeholder: "", **attrs) ⇒ ComboboxTrigger

Returns a new instance of ComboboxTrigger.



6
7
8
9
# File 'app/components/phlex_kit/combobox/combobox_trigger.rb', line 6

def initialize(placeholder: "", **attrs)
  @placeholder = placeholder
  @attrs = attrs
end

Instance Method Details

#view_templateObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/components/phlex_kit/combobox/combobox_trigger.rb', line 11

def view_template
  button(**mix({
    type: :button,
    class: "pk-combobox-trigger",
    aria: { haspopup: "listbox", expanded: "false" },
    data: {
      placeholder: @placeholder,
      phlex_kit__combobox_target: "trigger",
      action: "phlex-kit--combobox#togglePopover"
    }
  }, @attrs)) do
    span(class: "pk-combobox-trigger-content", data: { phlex_kit__combobox_target: "triggerContent" }) do
      @placeholder
    end
    icon
  end
end