2021-09-02 23:32:53 -04:00
|
|
|
defmodule LokalWeb.ModalComponent do
|
2022-01-22 20:44:38 -05:00
|
|
|
@moduledoc """
|
|
|
|
Component that provides a floating modal
|
|
|
|
"""
|
|
|
|
|
2021-09-02 23:32:53 -04:00
|
|
|
use LokalWeb, :live_component
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
def render(assigns) do
|
|
|
|
~L"""
|
|
|
|
<div id="<%= @id %>" class="phx-modal"
|
|
|
|
phx-capture-click="close"
|
|
|
|
phx-window-keydown="close"
|
|
|
|
phx-key="escape"
|
|
|
|
phx-target="#<%= @id %>"
|
|
|
|
phx-page-loading>
|
|
|
|
|
|
|
|
<div class="phx-modal-content">
|
|
|
|
<%= live_patch raw("×"), to: @return_to, class: "phx-modal-close" %>
|
2022-01-22 13:01:36 -05:00
|
|
|
<%= live_component @component, @opts %>
|
2021-09-02 23:32:53 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
"""
|
|
|
|
end
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
def handle_event("close", _, socket) do
|
|
|
|
{:noreply, push_patch(socket, to: socket.assigns.return_to)}
|
|
|
|
end
|
|
|
|
end
|