diff --git a/lib/vyasa_web/components/contexts/components.ex b/lib/vyasa_web/components/contexts/components.ex index 4b08c119..aa462a66 100644 --- a/lib/vyasa_web/components/contexts/components.ex +++ b/lib/vyasa_web/components/contexts/components.ex @@ -217,4 +217,29 @@ defmodule VyasaWeb.Context.Components do """ end + + def sheaf_creator_modal(assigns) do + ~H""" + <.debug_dump label="Sheaf Creator Dump" show={@marks_ui.show_sheaf_modal?} class="relative" /> + <.generic_modal_wrapper + id="my-modal" + show={@marks_ui.show_sheaf_modal?} + on_cancel_callback={JS.push("toggle_show_sheaf_modal?", target: "#content-display")} + on_click_away_callback={JS.push("toggle_show_sheaf_modal?", target: "#content-display")} + window_keydown_callback={JS.push("toggle_show_sheaf_modal?", target: "#content-display")} + container_class="rounded-lg shadow-lg overflow-hidden" + background_class="bg-gray-800 bg-opacity-75 backdrop-blur-md" + dialog_class="rounded-lg shadow-xl p-6 w-3/4 h-3/4 max-w-lg max-h-screen mx-auto my-auto" + focus_wrap_class="flex flex-col items-center justify-center h-full" + inner_block_container_class="w-full p-4" + close_button_icon_class="text-red-500 hover:text-red-700" + > +

My Modal Title

+

+ This is a description of what the modal is about. You can provide additional information here. +

+ <.debug_dump assigns={assigns} class="mt-4" /> + + """ + end end diff --git a/lib/vyasa_web/components/contexts/read.ex b/lib/vyasa_web/components/contexts/read.ex index 88ae03c3..4725c161 100644 --- a/lib/vyasa_web/components/contexts/read.ex +++ b/lib/vyasa_web/components/contexts/read.ex @@ -15,6 +15,7 @@ defmodule VyasaWeb.Context.Read do alias Phoenix.LiveView.Socket alias Vyasa.Sangh.{Mark, Sheaf} alias VyasaWeb.OgImageController + import VyasaWeb.Context.Components @impl true def update( @@ -116,7 +117,6 @@ defmodule VyasaWeb.Context.Read do |> stream(:chapters, chapters |> Enum.sort_by(fn chap -> chap.no end)) else [%Chapter{} = chapter | _] -> - socket |> apply_action(:show_verses, params |> Map.put("chap_no", chapter.no)) @@ -224,6 +224,8 @@ defmodule VyasaWeb.Context.Read do This reflector is hot-swappable to other sheafs if there's a need to switch what sheaf to focus on and gather marks for. + + TODO: add other params-based sheaf-setting """ def init_draft_reflector( %Socket{ @@ -283,6 +285,37 @@ defmodule VyasaWeb.Context.Read do |> cascade_stream_change()} end + @impl true + def handle_event( + "toggle_show_sheaf_modal?", + _, + %Socket{ + assigns: + %{ + marks_ui: %MarksUiState{} = ui_state + } = _assigns + } = socket + ) do + { + :noreply, + socket + |> assign(marks_ui: ui_state |> MarksUiState.toggle_show_sheaf_modal?()) + |> cascade_stream_change() + } + end + + @impl true + def handle_event( + "toggle_show_sheaf_modal?", + _, + %Socket{} = socket + ) do + { + :noreply, + socket + } + end + @impl true def handle_event( "toggle_is_editing_mark_content?", @@ -614,13 +647,11 @@ defmodule VyasaWeb.Context.Read do <% end %> <%= if @content_action == :show_verses do %> - <.debug_dump - :for={mark <- @marks} - label={Atom.to_string(mark.state) <> " Mark " <> Integer.to_string(mark.order) } - mark_state={mark.state} - mark_id={mark.id} - class="relative" - mark_order={mark.order} + <.debug_dump label="UI State Info" marks_ui={@marks_ui} class="relative w-screen" /> + <.sheaf_creator_modal + id="sheaf-creator" + marks_ui={@marks_ui} + event_target="content-display" /> <.live_component module={VyasaWeb.Context.Read.Verses} diff --git a/lib/vyasa_web/components/contexts/read/verse_matrix.ex b/lib/vyasa_web/components/contexts/read/verse_matrix.ex index 1ec918d7..a0611604 100644 --- a/lib/vyasa_web/components/contexts/read/verse_matrix.ex +++ b/lib/vyasa_web/components/contexts/read/verse_matrix.ex @@ -222,11 +222,11 @@ defmodule VyasaWeb.Context.Read.VerseMatrix do + +
+
+ <%= render_slot(@inner_block) %> +
+
+ + + + + + """ + end + @doc """ Renders a waiting spinner """ @@ -919,13 +1050,13 @@ defmodule VyasaWeb.CoreComponents do A generic debug dump component that displays all assigned properties. ## Examples - + """ def debug_dump(assigns) do ~H"""

<%= Map.get(assigns, :label, "Developer Dump") %>