From aaa89c7c76993fd37c6a741988c51c12bbd5d44c Mon Sep 17 00:00:00 2001 From: Chris McCord Date: Tue, 2 Nov 2021 12:24:53 -0400 Subject: [PATCH] Checkpoint --- lib/live_beats_web/live/live_helpers.ex | 33 +++++++++++++++---- lib/live_beats_web/live/song_live/index.ex | 19 +++++++---- .../templates/layout/live.html.heex | 4 +-- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/lib/live_beats_web/live/live_helpers.ex b/lib/live_beats_web/live/live_helpers.ex index d06a4f9..5574458 100644 --- a/lib/live_beats_web/live/live_helpers.ex +++ b/lib/live_beats_web/live/live_helpers.ex @@ -82,7 +82,27 @@ defmodule LiveBeatsWeb.LiveHelpers do ) end - def show_modal(js \\ %JS{}, id) do + def show_modal(%JS{} = js, id, opts) when is_binary(id) and is_list(opts) do + on_confirm = Keyword.get(opts, :on_confirm, %JS{}) |> hide_modal(id) + title = Keyword.get(opts, :title, "") + content = Keyword.get(opts, :content, "") + + js + |> JS.inner_text(title, to: "##{id}-title") + |> JS.inner_text(content, to: "##{id}-content") + |> JS.set_attribute("phx-click", to: "##{id}-confirm", value: on_confirm) + |> show_modal(id) + end + + def show_modal(id) when is_binary(id) do + show_modal(%JS{}, id, []) + end + + def show_modal(id, opts) when is_binary(id) and is_list(opts) do + show_modal(%JS{}, id, opts) + end + + def show_modal(%JS{} = js, id) when is_binary(id) do js |> JS.show( to: "##{id}", @@ -90,7 +110,7 @@ defmodule LiveBeatsWeb.LiveHelpers do transition: {"ease-out duration-300", "opacity-0", "opacity-100"} ) |> JS.show( - to: "##{id}-content", + to: "##{id}-container", display: "inline-block", transition: {"ease-out duration-300", "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95", @@ -106,7 +126,7 @@ defmodule LiveBeatsWeb.LiveHelpers do transition: {"ease-in duration-200", "opacity-100", "opacity-0"} ) |> JS.hide( - to: "##{id}-content", + to: "##{id}-container", transition: {"ease-in duration-200", "opacity-100 translate-y-0 sm:scale-100", "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"} @@ -133,7 +153,7 @@ defmodule LiveBeatsWeb.LiveHelpers do
-

<%= render_slot(@title) %>

-

+

<%= render_slot(@inner_block) %>

@@ -162,6 +182,7 @@ defmodule LiveBeatsWeb.LiveHelpers do
<%= for confirm <- @confirm do %>