Class: UI::CommandDialog

Inherits:
Phlex::HTML
  • Object
show all
Includes:
CommandDialogBehavior
Defined in:
app/components/ui/command_dialog.rb

Instance Method Summary collapse

Methods included from CommandDialogBehavior

#command_dialog_base_classes, #command_dialog_classes, #command_dialog_content_classes, #command_dialog_html_attributes, #shortcut_action

Constructor Details

#initialize(shortcut: "meta+j", autofocus: true, classes: "", **attributes) ⇒ CommandDialog

Returns a new instance of CommandDialog.



6
7
8
9
10
11
# File 'app/components/ui/command_dialog.rb', line 6

def initialize(shortcut: "meta+j", autofocus: true, classes: "", **attributes)
  @shortcut = shortcut
  @autofocus = autofocus
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#view_template(&block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/components/ui/command_dialog.rb', line 13

def view_template(&block)
  div(**command_dialog_html_attributes.deep_merge(@attributes)) do
    render UI::Dialog.new(close_on_escape: true, close_on_overlay_click: true) do
      render UI::DialogOverlay.new do
        render UI::DialogContent.new(classes: command_dialog_content_classes) do
          render UI::Command.new(autofocus: @autofocus) do
            yield if block_given?
          end
        end
      end
    end
  end
end