From ab298f9abbb12053626e222404f4e9e0820ee84a Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Fri, 5 Jan 2024 17:36:22 +0000 Subject: [PATCH] Remove grid mode --- lib/wish_web/live/home_live/details.html.heex | 2 +- lib/wish_web/live/home_live/index.ex | 13 +- lib/wish_web/live/home_live/index.html.heex | 175 +++++------------- 3 files changed, 50 insertions(+), 140 deletions(-) diff --git a/lib/wish_web/live/home_live/details.html.heex b/lib/wish_web/live/home_live/details.html.heex index c3b9dde..5550039 100644 --- a/lib/wish_web/live/home_live/details.html.heex +++ b/lib/wish_web/live/home_live/details.html.heex @@ -1,4 +1,4 @@ -<.link href={~p"/"}> +<.link patch={~p"/"}> <.icon name="hero-arrow-left" /> Back to list diff --git a/lib/wish_web/live/home_live/index.ex b/lib/wish_web/live/home_live/index.ex index 452f5d1..0a9072d 100644 --- a/lib/wish_web/live/home_live/index.ex +++ b/lib/wish_web/live/home_live/index.ex @@ -6,12 +6,6 @@ defmodule WishWeb.HomeLive.Index do @impl true def mount(_params, session, socket) do - grid? = - case Map.get(session, "user_display", "grid") do - "grid" -> true - _ -> false - end - items = if socket.assigns.current_user do Wishlist.list_visible_items() @@ -19,12 +13,7 @@ defmodule WishWeb.HomeLive.Index do Wishlist.list_available_items() end - {:ok, assign(socket, :items, items) |> assign(:grid, grid?) |> assign(:hidden, false)} - end - - @impl true - def handle_event("toggle_view_state", _, socket) do - {:noreply, assign(socket, :grid, !socket.assigns.grid)} + {:ok, assign(socket, :items, items) |> assign(:hidden, false)} end @impl true diff --git a/lib/wish_web/live/home_live/index.html.heex b/lib/wish_web/live/home_live/index.html.heex index 24797e3..70240a3 100644 --- a/lib/wish_web/live/home_live/index.html.heex +++ b/lib/wish_web/live/home_live/index.html.heex @@ -1,19 +1,7 @@ <.header> Daniel's Wishlist - <:actions> - <.button phx-click={ - JS.push("toggle_view_state") - |> JS.dispatch("toggle_view_state", detail: %{"grid" => !@grid}) - }> - <%= if @grid do %> - List View - <% else %> - Grid View - <% end %> - - <:actions :if={!@current_user}> - <.button phx-click={JS.push("toggle_hidden_items")}> + <.button phx-click={JS.push("toggle_hidden_items")} id="showhide-button" phx-throttle="300"> <%= if @hidden do %> Hide <% else %> @@ -24,128 +12,61 @@ -<%= if @grid do %> -
-
+
-
- {item.title} - <%= if item.received && !@current_user do %> -
- <.icon name="hero-check-circle" />Received -
- <% end %> -
-
- <%= item.title %> -
-
- <.icon name="hero-ellipsis-vertical" class="w-full h-full" /> -
- <.dropdown item={item} /> -
-
- <%= if item.price do %> -
-
- Price: -
-
- ~£<%= item.price %> -
-
- <% end %> -
-
- Priority: -
- - <%= for _ <- 1..item.desire do %> - <.icon name="hero-star" class="bg-red-500 text-red-500" /> - <% end %> - -
- <%= if item.description do %> -
-
- Description: -
-
- <%= item.description %> -
+ phx-click={JS.navigate(~p"/details/#{item}")} + > +
+ {item.title} + <%= if item.received && !@current_user do %> +
+ <.icon name="hero-check-circle" />Purchased
<% end %>
-
-<% else %> -
-
-
- {item.title} - <%= if item.received && !@current_user do %> -
- <.icon name="hero-check-circle" />Purchased -
- <% end %> -
-
- <%= item.title %> -
-
- <.icon - name="hero-ellipsis-vertical" - class="w-7 h-7 rounded-full hover:bg-purple-400 active:bg-purple-500" - /> - <.dropdown item={item} /> -
- <%= if item.price do %> -
-
- Price: -
-
- ~£<%= item.price %> -
-
- <% end %> - <%= if item.description do %> -
-
- Description: -
-
- <%= item.description %> -
-
- <% end %> +
+ <%= item.title %> +
+
+ <.icon + name="hero-ellipsis-vertical" + class="w-7 h-7 rounded-full hover:bg-purple-400 active:bg-purple-500" + /> + <.dropdown item={item} /> +
+ <%= if item.price do %>
- Priority: + Price: +
+
+ ~£<%= item.price %>
- - <%= for _ <- 1..item.desire do %> - <.icon name="hero-star" class="bg-red-500 text-red-500" /> - <% end %> -
+ <% end %> + <%= if item.description do %> +
+
+ Description: +
+
+ <%= item.description %> +
+
+ <% end %> +
+
+ Priority: +
+ + <%= for _ <- 1..item.desire do %> + <.icon name="hero-star" class="bg-red-500 text-red-500" /> + <% end %> +
-<% end %> +