Skip to content

Commit

Permalink
Test SideNotes View
Browse files Browse the repository at this point in the history
  • Loading branch information
ks0m1c_dharma committed Dec 22, 2023
1 parent 78085fb commit cc4573e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 23 additions & 1 deletion lib/vyasa_web/live/gita_live/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,42 @@ defmodule VyasaWeb.GitaLive.Show do
<:subtitle> <%= @chapter.chapter_summary %></:subtitle>
</.header>
<.list :for={{_dom_id, text} <- @streams.verses}>
<:item title={"#{text.chapter_number}.#{text.verse_number}"}><p class="font-dn text-2xl"><%= text.text |> String.split("।।") |> List.first() %></p></:item>
<:item><%= text.transliteration %></:item>
<:item><%= text.word_meanings %></:item>
<.sidenote>
<%= @chapter.name_transliterated %>
<:subtitle> <%= @chapter.chapter_summary %></:subtitle>
</.sidenote>
</.list>
<.back navigate={~p"/gita"}>Back to Gita</.back>
"""
end
#<.link patch={~p"/gita/#{@chapter.id}"} phx-click={JS.push_focus()}> <.button>Annotate</.button> </.link>
@impl true
def handle_params(%{"id" => id}, _, socket) do
def handle_params(%{"id" => id} = params, _, socket) do
{:noreply, socket
|> assign(:chapter, Gita.chapters(id))
|> stream(:verses, Gita.verses(id))}
|> apply_action(socket.assigns.live_action, params)

This comment has been minimized.

Copy link
@rtshkmr

rtshkmr Jan 13, 2024

Member

QQ: the params arg will get automatically "deconstructed" and pattern matched based on the various functions defined below right

nvm it's most likely the case

end


defp apply_action(socket, :sangh, %{"id" => _chapter, "sangh_id" => _sId} = _params) do
socket
|> assign(:sangh, [])
end

defp apply_action(socket, :new_sangh, %{"id" => _chapter} = _params) do
socket
|> assign(:sangh, [])
end

#pokemon clause
defp apply_action(socket, _action, _params) do
socket
end
end
2 changes: 2 additions & 0 deletions lib/vyasa_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ defmodule VyasaWeb.Router do
get "/", PageController, :home
live "/gita/", GitaLive.Index, :index
live "/gita/:id", GitaLive.Show, :show
live "/gita/:id/sangh/new", GitaLive.Show, :new_sangh
live "/gita/:id/sangh/:sangh_id", GitaLive.Show, :sangh
live "/texts", TextLive.Index, :index
live "/texts/new", TextLive.Index, :new
live "/texts/:id/edit", TextLive.Index, :edit
Expand Down

0 comments on commit cc4573e

Please sign in to comment.