Class: ShadcnPhlexcomponents::AlertDialog

Inherits:
Base
  • Object
show all
Defined in:
lib/shadcn_phlexcomponents/components/alert_dialog.rb

Constant Summary

Constants inherited from Base

Base::SANITIZER_ALLOWED_ATTRIBUTES, Base::SANITIZER_ALLOWED_TAGS, Base::TAILWIND_MERGER

Instance Method Summary collapse

Methods inherited from Base

#before_template, #convert_collection_hash_to_struct, #find_as_child, #icon, #item_disabled?, #merge_default_attributes, #merged_as_child_attributes, #nokogiri_attributes_to_hash, #overlay, #sanitize_as_child

Constructor Details

#initialize(open: false, **attributes) ⇒ AlertDialog

Returns a new instance of AlertDialog.



14
15
16
17
18
# File 'lib/shadcn_phlexcomponents/components/alert_dialog.rb', line 14

def initialize(open: false, **attributes)
  @open = open
  @aria_id = "alert-dialog-#{SecureRandom.hex(5)}"
  super(**attributes)
end

Instance Method Details

#action(**attributes) ⇒ Object



48
49
50
# File 'lib/shadcn_phlexcomponents/components/alert_dialog.rb', line 48

def action(**attributes, &)
  AlertDialogAction(**attributes, &)
end

#action_to(name = nil, options = nil, html_options = nil) ⇒ Object



52
53
54
# File 'lib/shadcn_phlexcomponents/components/alert_dialog.rb', line 52

def action_to(name = nil, options = nil, html_options = nil, &)
  AlertDialogActionTo(name, options, html_options, &)
end

#cancel(**attributes) ⇒ Object



44
45
46
# File 'lib/shadcn_phlexcomponents/components/alert_dialog.rb', line 44

def cancel(**attributes, &)
  AlertDialogCancel(**attributes, &)
end

#content(**attributes) ⇒ Object



24
25
26
# File 'lib/shadcn_phlexcomponents/components/alert_dialog.rb', line 24

def content(**attributes, &)
  AlertDialogContent(aria_id: @aria_id, **attributes, &)
end

#default_attributes ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/shadcn_phlexcomponents/components/alert_dialog.rb', line 56

def default_attributes
  {
    data: {
      controller: "alert-dialog",
      alert_dialog_is_open_value: @open.to_s,
    },
  }
end

#description(**attributes) ⇒ Object



36
37
38
# File 'lib/shadcn_phlexcomponents/components/alert_dialog.rb', line 36

def description(**attributes, &)
  AlertDialogDescription(aria_id: @aria_id, **attributes, &)
end


40
41
42
# File 'lib/shadcn_phlexcomponents/components/alert_dialog.rb', line 40

def footer(**attributes, &)
  AlertDialogFooter(**attributes, &)
end

#header(**attributes) ⇒ Object



28
29
30
# File 'lib/shadcn_phlexcomponents/components/alert_dialog.rb', line 28

def header(**attributes, &)
  AlertDialogHeader(**attributes, &)
end

#title(**attributes) ⇒ Object



32
33
34
# File 'lib/shadcn_phlexcomponents/components/alert_dialog.rb', line 32

def title(**attributes, &)
  AlertDialogTitle(aria_id: @aria_id, **attributes, &)
end

#trigger(**attributes) ⇒ Object



20
21
22
# File 'lib/shadcn_phlexcomponents/components/alert_dialog.rb', line 20

def trigger(**attributes, &)
  AlertDialogTrigger(aria_id: @aria_id, **attributes, &)
end

#view_template ⇒ Object



65
66
67
68
69
70
71
# File 'lib/shadcn_phlexcomponents/components/alert_dialog.rb', line 65

def view_template(&)
  div(**@attributes) do
    overlay("alert-dialog")

    yield
  end
end