31 lines
710 B
Elixir
31 lines
710 B
Elixir
defmodule LokalWeb.ModalComponent do
|
|
@moduledoc """
|
|
Component that provides a floating modal
|
|
"""
|
|
|
|
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" %>
|
|
<%= live_component @component, @opts %>
|
|
</div>
|
|
</div>
|
|
"""
|
|
end
|
|
|
|
@impl true
|
|
def handle_event("close", _, socket) do
|
|
{:noreply, push_patch(socket, to: socket.assigns.return_to)}
|
|
end
|
|
end
|