Class: UI::CommandDialogComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
CommandDialogBehavior
Defined in:
app/view_components/ui/command_dialog_component.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) ⇒ CommandDialogComponent

Returns a new instance of CommandDialogComponent.



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

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

Instance Method Details

#callObject



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

def call
   :div, **command_dialog_html_attributes.deep_merge(@attributes) do
    render UI::DialogComponent.new(close_on_escape: true, close_on_overlay_click: true) do
      render UI::DialogOverlayComponent.new do
        render UI::DialogContentComponent.new(classes: command_dialog_content_classes) do
          render UI::CommandComponent.new(autofocus: @autofocus) do
            content
          end
        end
      end
    end
  end
end