Skip to content

Commit

Permalink
Add action btn to create new thread @ discuss mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rtshkmr committed Dec 8, 2024
1 parent 80fa60c commit 60cad30
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 16 deletions.
20 changes: 20 additions & 0 deletions lib/vyasa_web/components/contexts/components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -835,4 +835,24 @@ defmodule VyasaWeb.Context.Components do
</div>
"""
end

def floating_action_button(assigns) do
~H"""
<div class="absolute bottom-20 right-4 z-50 transform">
<button
id="floating_action"
class={[
"bg-white/30 hover:bg-white/40 text-white rounded-full focus:outline-none transition-all duration-300 backdrop-blur-lg shadow-lg active:scale-95 flex items-center justify-center w-11 h-11 p-1 border border-white/20"
]}
phx-click={@on_click}
phx-target={@event_target}
>
<.icon
name={@icon_name}
class={"w-5 h-5 text-gray-500 hover:text-primaryAccent transition-colors duration-200 stroke-current stroke-2" <> @icon_class}
/>
</button>
</div>
"""
end
end
56 changes: 40 additions & 16 deletions lib/vyasa_web/components/contexts/discuss.ex
Original file line number Diff line number Diff line change
Expand Up @@ -893,10 +893,26 @@ defmodule VyasaWeb.Context.Discuss do
[]
end

{reflected_sheaf, reflected_sheaf_ui} =
case Map.has_key?(assigns, :draft_reflector_path) do
true ->
lattice_key = assigns.draft_reflector_path.labels

{assigns.sheaf_lattice |> Map.get(lattice_key),
assigns.sheaf_ui_lattice |> Map.get(lattice_key)}

false ->
{nil, nil}
end

assigns =
assigns
|> assign(:reply_to, reply_to_sheaf)
|> assign(:root_sheaves, root_sheaves)
|> assign(%{
reply_to: reply_to_sheaf,
root_sheaves: root_sheaves,
reflected_sheaf: reflected_sheaf,
reflected_sheaf_ui: reflected_sheaf_ui
})

~H"""
<div id={@id}>
Expand All @@ -905,8 +921,8 @@ defmodule VyasaWeb.Context.Discuss do
label="Context Dump on Discussions"
draft_reflector_path={@draft_reflector_path}
reply_to={@reply_to}
reflected={@sheaf_lattice |> Map.get(@draft_reflector_path.labels)}
reflected_ui={@sheaf_ui_lattice |> Map.get(@draft_reflector_path.labels)}
reflected={@reflected_sheaf}
reflected_ui={@reflected_sheaf_ui}
/> -->
<div id="content-display" class="mx-auto max-w-4xl pb-16 w-full">
<.header class="m-8 ml-0">
Expand All @@ -931,12 +947,8 @@ defmodule VyasaWeb.Context.Discuss do
id="sheaf-creator"
session={@session}
reply_to={@reply_to}
draft_sheaf={
@sheaf_lattice |> SheafLattice.get_sheaf_from_lattice(@draft_reflector_path.labels)
}
draft_sheaf_ui={
@sheaf_ui_lattice |> SheafLattice.get_sheaf_from_lattice(@draft_reflector_path.labels)
}
draft_sheaf={@reflected_sheaf}
draft_sheaf_ui={@reflected_sheaf_ui}
event_target="#content-display"
/>
Expand All @@ -948,12 +960,8 @@ defmodule VyasaWeb.Context.Discuss do
not is_nil(@draft_reflector_path)
}
label="CHECK SHEAF CREATOR MODAL INPUTS"
draft_sheaf_ui={
@sheaf_ui_lattice |> SheafLattice.get_sheaf_from_lattice(@draft_reflector_path.labels)
}
draft_sheaf={
@sheaf_lattice |> SheafLattice.get_sheaf_from_lattice(@draft_reflector_path.labels)
}
draft_sheaf={@reflected_sheaf}
draft_sheaf_ui={@reflected_sheaf_ui}
event_target="#content-display"
/> -->
</div>
Expand All @@ -976,6 +984,22 @@ defmodule VyasaWeb.Context.Discuss do
</div>
<% end %>
</div>
<!-- Floating Action Button -->
<div class="fixed bottom-20 right-4 z-50">
<.floating_action_button
:if={@reflected_sheaf_ui}
icon_name="hero-plus"
icon_class="w-6 h-6"
event_target="#content-display"
on_click={
case @reflected_sheaf_ui.marks_ui.show_sheaf_modal? do
# ignores this click event since the clickaway listener for the modal will already do the toggle:
true -> nil
false -> "ui::toggle_show_sheaf_modal?"
end
}
/>
</div>
</div>
"""
end
Expand Down

0 comments on commit 60cad30

Please sign in to comment.