Class: UI::AlertDialog

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

Overview

AlertDialog - Phlex implementation

A modal alert dialog component for important confirmations and alerts. Uses AlertDialogBehavior module for shared styling logic.

Examples:

Basic usage

render UI::AlertDialog.new do
  render UI::Trigger.new { "Open Alert Dialog" }
  render UI::Overlay.new
  render UI::Content.new { "Alert dialog content here" }
end

Instance Method Summary collapse

Methods included from AlertDialogBehavior

#alert_dialog_base_classes, #alert_dialog_classes, #alert_dialog_data_attributes, #alert_dialog_html_attributes, #merged_alert_dialog_data_attributes

Constructor Details

#initialize(open: false, close_on_escape: true, classes: "", **attributes) ⇒ AlertDialog

Returns a new instance of AlertDialog.

Parameters:

  • open (Boolean) (defaults to: false) —

    Whether the alert dialog is initially open

  • close_on_escape (Boolean) (defaults to: true) —

    Whether pressing Escape closes the dialog

  • classes (String) (defaults to: "") —

    Additional CSS classes to merge

  • attributes (Hash) —

    Additional HTML attributes



21
22
23
24
25
26
# File 'app/components/ui/alert_dialog.rb', line 21

def initialize(open: false, close_on_escape: true, classes: "", **attributes)
  @open = open
  @close_on_escape = close_on_escape
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#view_template(&block) ⇒ Object



28
29
30
31
32
# File 'app/components/ui/alert_dialog.rb', line 28

def view_template(&block)
  div(**alert_dialog_html_attributes) do
    yield if block_given?
  end
end