Class: Components::Modal

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

Instance Method Summary collapse

Constructor Details

#initialize(id:, title:) ⇒ Modal

Returns a new instance of Modal.



2
3
4
5
# File 'app/components/modal.rb', line 2

def initialize(id:, title:)
  @id = id
  @title = title
end

Instance Method Details

#view_template ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/components/modal.rb', line 7

def view_template
  div class: "modal fade modal-lg", id: @id, tabindex: "-1", "aria-labelledby": "#{@id}-label", "aria-hidden": "true" do
    div class: "modal-dialog" do
      div class: "modal-content" do
        div class: "modal-header" do
          h1(class: "modal-title fs-5", id: "#{@id}-label") { @title }
          button type: "button", class: "btn-close", "data-bs-dismiss": "modal", "aria-label": t("components.modal.close")
        end
        div class: "modal-body" do
          yield
        end
      end
    end
  end
end