2021-09-02 23:31:14 -04:00
|
|
|
defmodule CanneryWeb.ModalComponent do
|
2022-01-22 21:40:29 -05:00
|
|
|
@moduledoc """
|
|
|
|
Livecomponent that displays a floating modal window
|
|
|
|
"""
|
|
|
|
|
2021-09-02 23:31:14 -04:00
|
|
|
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
|
|
|
|
>
|
2022-02-05 16:22:02 -05:00
|
|
|
<div class="w-full max-w-3xl max-h-128 relative overflow-y-auto
|
|
|
|
flex flex-col justify-start items-center
|
2021-09-10 21:38:03 -04:00
|
|
|
bg-white border-2 rounded-lg">
|
|
|
|
<%= live_patch to: @return_to,
|
2022-02-05 16:22:02 -05:00
|
|
|
class: "absolute top-8 right-10 text-gray-500 hover:text-gray-800
|
2022-02-05 16:22:20 -05:00
|
|
|
transition-all duration-500 ease-in-out" do %>
|
2022-02-01 01:08:18 -05:00
|
|
|
<i class="fa-fw fa-lg fas fa-times"></i>
|
2021-09-10 21:38:03 -04:00
|
|
|
<% end %>
|
2022-02-05 16:22:02 -05:00
|
|
|
<div class="p-8 flex flex-col space-y-4 justify-start 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
|