Class: PhlexKit::SelectTrigger

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/select/select_trigger.rb

Overview

The closed-state button for PhlexKit::Select — shows the current SelectValue and a up/down chevron, and opens the panel on click (phlex-kit--select#onClick). See select.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(**attrs) ⇒ SelectTrigger

Returns a new instance of SelectTrigger.



6
7
8
# File 'app/components/phlex_kit/select/select_trigger.rb', line 6

def initialize(**attrs)
  @attrs = attrs
end

Instance Method Details

#view_template(&block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/components/phlex_kit/select/select_trigger.rb', line 10

def view_template(&block)
  button(**mix({
    type: :button,
    role: "combobox",
    class: "pk-select-trigger",
    aria: { expanded: "false", haspopup: "listbox", autocomplete: "none" },
    data: { action: "phlex-kit--select#onClick", phlex_kit__select_target: "trigger" }
  }, @attrs)) do
    block&.call
    icon
  end
end