2021-09-02 23:31:14 -04:00
|
|
|
defmodule CanneryWeb.ModalComponent do
|
|
|
|
use CanneryWeb, :live_component
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
def render(assigns) do
|
2022-01-22 15:15:23 -05:00
|
|
|
~H"""
|
2022-01-22 17:21:10 -05:00
|
|
|
<div
|
|
|
|
id={@id}
|
|
|
|
class="fixed z-10 left-0 top-0
|
2021-09-10 21:38:03 -04:00
|
|
|
w-full h-full overflow-hidden
|
|
|
|
p-8 flex flex-col justify-center items-center"
|
|
|
|
style="opacity: 1 !important; background-color: rgba(0,0,0,0.4);"
|
2021-09-02 23:31:14 -04:00
|
|
|
phx-capture-click="close"
|
|
|
|
phx-window-keydown="close"
|
|
|
|
phx-key="escape"
|
2022-01-22 15:15:23 -05:00
|
|
|
phx-target={"#{@id}"}
|
2022-01-22 17:21:10 -05:00
|
|
|
phx-page-loading
|
|
|
|
>
|
2021-09-10 21:38:03 -04:00
|
|
|
<div class="w-full max-w-4xl relative
|
|
|
|
p-8 flex flex-col justify-start items-center
|
|
|
|
bg-white border-2 rounded-lg">
|
|
|
|
<%= live_patch to: @return_to,
|
2022-01-22 17:21:10 -05:00
|
|
|
class:
|
|
|
|
"absolute top-8 right-10 text-gray-500 hover:text-gray-800 transition-all duration-500 ease-in-out" do %>
|
|
|
|
<i class="fa-fw fa-lg fas fa-times">
|
|
|
|
</i>
|
2021-09-10 21:38:03 -04:00
|
|
|
<% end %>
|
2021-09-12 18:55:15 -04:00
|
|
|
<div class="w-full flex flex-col space-y-4 justify-center items-center">
|
2022-01-22 17:21:10 -05:00
|
|
|
<%= live_component(@component, @opts) %>
|
2021-09-10 21:38:03 -04:00
|
|
|
</div>
|
2021-09-02 23:31:14 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
"""
|
|
|
|
end
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
def handle_event("close", _, socket) do
|
|
|
|
{:noreply, push_patch(socket, to: socket.assigns.return_to)}
|
|
|
|
end
|
|
|
|
end
|