Class: UI::Modal

Inherits:
Base
  • Object
show all
Defined in:
app/views/ui/modal.rb

Constant Summary

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Method Summary collapse

Methods inherited from Base

#before_template

Constructor Details

#initialize(**props) ⇒ Modal

Returns a new instance of Modal.



9
10
11
12
13
# File 'app/views/ui/modal.rb', line 9

def initialize(**props)
  super
  @trigger_block = nil
  @footer_block = nil
end

Instance Method Details



43
44
45
46
47
# File 'app/views/ui/modal.rb', line 43

def footer(class: nil, &block)
  @footer_block = block
  @footer_classes = grab(class:)
  nil
end

#trigger(class: nil, &block) ⇒ Object



37
38
39
40
41
# File 'app/views/ui/modal.rb', line 37

def trigger(class: nil, &block)
  @trigger_block = block
  @trigger_classes = grab(class:)
  nil
end

#view_template(&block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/views/ui/modal.rb', line 15

def view_template(&block)
  vanish(&block) if block_given?

  div data: {controller: "modal", modal_open_value: open}.merge(backdrop_closeable_attributes) do
    dialog(data: {modal_target: "dialog"}, class: classes) do
      div(class: "ui-modal-body") do
        div(class: "flex justify-between items-start") do
          render_heading
          render_close_trigger
        end
        render_text

        yield
      end

      render_footer
    end

    render_trigger
  end
end