Class: PhlexKit::SelectTrigger
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::SelectTrigger
- 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.
Constant Summary collapse
- SIZES =
{ md: nil, sm: "sm" }.freeze
Instance Method Summary collapse
-
#initialize(size: :md, **attrs) ⇒ SelectTrigger
constructor
A new instance of SelectTrigger.
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(size: :md, **attrs) ⇒ SelectTrigger
Returns a new instance of SelectTrigger.
8 9 10 11 |
# File 'app/components/phlex_kit/select/select_trigger.rb', line 8 def initialize(size: :md, **attrs) @size = size.to_sym @attrs = attrs end |
Instance Method Details
#view_template(&block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/components/phlex_kit/select/select_trigger.rb', line 13 def view_template(&block) (**mix({ type: :button, role: "combobox", class: [ "pk-select-trigger", fetch_option(SIZES, @size, :size) ].compact.join(" "), 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 |