diff --git a/assets/js/app.js b/assets/js/app.js index 66d6514..4cc9a3e 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -32,6 +32,14 @@ import Uploaders from "./uploaders"; window.Alpine = Alpine; Alpine.start() +window.addEventListener("scroll-top", () => { + window.scrollTo({ + top: 0, + behavior: "smooth" + }); +}); + + let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content") let liveSocket = new LiveSocket("/live", Socket, { longPollFallbackMs: 2500, diff --git a/lib/digistab_store_web/live/products/product_card_component.ex b/lib/digistab_store_web/live/products/product_card_component.ex index 9d61076..5857b93 100644 --- a/lib/digistab_store_web/live/products/product_card_component.ex +++ b/lib/digistab_store_web/live/products/product_card_component.ex @@ -23,14 +23,17 @@ defmodule DigistabStoreWeb.Components.ProductCard do
<%= if @product.photos && Enum.any?(@product.photos) do %> - <.link patch={~p"/products/#{@product.id}"}> +
JS.dispatch("scroll-top")} + class="cursor-pointer" + > {@product.name} - +
<% else %>
<.icon name="hero-photo" class="w-12 h-12 text-gray-400" />