Skip to content

Commit

Permalink
render list.name + list_url in nav menu #424 #165
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Nov 1, 2023
1 parent 284a496 commit 31df47e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 17 deletions.
3 changes: 2 additions & 1 deletion lib/app_web/controllers/tag_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ defmodule AppWeb.TagController do
person_id = conn.assigns[:person][:id] || 0
tags = Tag.list_person_tags(person_id)

render(conn, "index.html", tags: tags)
render(conn, "index.html", tags: tags,
lists: App.List.get_lists_for_person(person_id))
end

def new(conn, _params) do
Expand Down
1 change: 1 addition & 0 deletions lib/app_web/live/app_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ defmodule AppWeb.AppLive do
filter: "active",
filter_tag: nil,
list_cid: all_list.cid,
lists: App.List.get_lists_for_person(person_id),
tags: tags,
selected_tags: selected_tags,
text_value: draft_item.text || "",
Expand Down
2 changes: 1 addition & 1 deletion lib/app_web/templates/layout/live.html.heex
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<.live_component module={AppWeb.Nav} id="menu" {assigns} />
<%= render(AppWeb.NavView, "nav.html", assigns) %>
<%= @inner_content %>
2 changes: 2 additions & 0 deletions lib/app_web/templates/list/index.html.heex
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%= render(AppWeb.NavView, "nav.html", assigns) %>

<h2 class="text-center mt-3 text-4xl font-semibold leading-6 text-gray-900">
Lists
</h2>
Expand Down
20 changes: 6 additions & 14 deletions lib/app_web/templates/nav/nav.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -115,26 +115,18 @@
</div>
<!-- Mobile menu, show/hide based on menu state. -->
<div x-show="openMenu">
<div class="space-y-1 px-2 pb-3 pt-2 text-right">
<%= link("📥 All",
to: "/tags",
class:
"text-gray-300 hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 text-sm font-medium"
) %>
</div>
<%= for list <- @lists do %>
<div class="space-y-1 px-2 pb-3 pt-2 text-right">
<a class="text-gray-300 hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 text-sm font-medium"
href={list_url(list.cid)}><%= list_name(list.name) %></a>
</div>
<% end %>
<div class="space-y-1 px-2 pb-3 pt-2 text-right">
<%= link("🏷️ Tags",
to: "/tags",
class:
"text-gray-300 hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 text-sm font-medium"
) %>
</div>
<div class="space-y-1 px-2 pb-3 pt-2 text-right">
<%= link("🛒 Shopping",
to: "/tags",
class:
"text-gray-300 hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 text-sm font-medium"
) %>
</div>
</div>
</nav>
2 changes: 1 addition & 1 deletion lib/app_web/templates/tag/index.html.heex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= render AppWeb.NavView, "nav.html", assigns %>
<%= render(AppWeb.NavView, "nav.html", assigns) %>
<.h2 class="text-center mt-3">Listing Tags</.h2>

<.container>
Expand Down
8 changes: 8 additions & 0 deletions lib/app_web/views/nav_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@ defmodule AppWeb.NavView do
# defp btn(color) do
# "text-6xl pb-2 w-20 rounded-lg bg-#{color}-500 hover:bg-#{color}-600"
# end
def list_url(cid) do
"/?list_cid=" <> cid
end

def list_name(name) do
name = if name == "all", do: "📥 All", else: name
AppWeb.ListView.title_case(name)
end
end

0 comments on commit 31df47e

Please sign in to comment.