Class: PhlexKit::CommandDialogTrigger
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::CommandDialogTrigger
- Defined in:
- app/components/phlex_kit/command/command_dialog_trigger.rb
Overview
Opens the command palette on click and on ctrl/cmd+K (override with
keybindings:). Wrap a PhlexKit::Button or any clickable. See command.rb.
Constant Summary collapse
- DEFAULT_KEYBINDINGS =
[ "keydown.ctrl+k@window", "keydown.meta+k@window" ].freeze
Instance Method Summary collapse
-
#initialize(keybindings: DEFAULT_KEYBINDINGS, **attrs) ⇒ CommandDialogTrigger
constructor
A new instance of CommandDialogTrigger.
- #view_template ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(keybindings: DEFAULT_KEYBINDINGS, **attrs) ⇒ CommandDialogTrigger
Returns a new instance of CommandDialogTrigger.
10 11 12 13 |
# File 'app/components/phlex_kit/command/command_dialog_trigger.rb', line 10 def initialize(keybindings: DEFAULT_KEYBINDINGS, **attrs) @keybindings = keybindings.map { |kb| "#{kb}->phlex-kit--command-dialog#open" } @attrs = attrs end |
Instance Method Details
#view_template ⇒ Object
15 16 17 18 19 20 |
# File 'app/components/phlex_kit/command/command_dialog_trigger.rb', line 15 def view_template(&) div(**mix({ class: "pk-command-dialog-trigger", data: { action: [ "click->phlex-kit--command-dialog#open", *@keybindings ].join(" ") } }, @attrs), &) end |