diff --git a/lib/simpleshop_theme_web/live/shop_live/products.ex b/lib/simpleshop_theme_web/live/shop_live/products.ex new file mode 100644 index 0000000..6e5927d --- /dev/null +++ b/lib/simpleshop_theme_web/live/shop_live/products.ex @@ -0,0 +1,40 @@ +defmodule SimpleshopThemeWeb.ShopLive.Products do + use SimpleshopThemeWeb, :live_view + + alias SimpleshopTheme.Settings + alias SimpleshopTheme.Media + alias SimpleshopTheme.Theme.{CSSCache, CSSGenerator, PreviewData} + + @impl true + def mount(_params, _session, socket) do + theme_settings = Settings.get_theme_settings() + + generated_css = + case CSSCache.get() do + {:ok, css} -> css + :miss -> + css = CSSGenerator.generate(theme_settings) + CSSCache.put(css) + css + end + + logo_image = Media.get_logo() + header_image = Media.get_header() + + preview_data = %{ + products: PreviewData.products(), + categories: PreviewData.categories() + } + + socket = + socket + |> assign(:page_title, "Products") + |> assign(:theme_settings, theme_settings) + |> assign(:generated_css, generated_css) + |> assign(:logo_image, logo_image) + |> assign(:header_image, header_image) + |> assign(:preview_data, preview_data) + + {:ok, socket} + end +end diff --git a/lib/simpleshop_theme_web/live/shop_live/products.html.heex b/lib/simpleshop_theme_web/live/shop_live/products.html.heex new file mode 100644 index 0000000..0e6f1fe --- /dev/null +++ b/lib/simpleshop_theme_web/live/shop_live/products.html.heex @@ -0,0 +1,35 @@ +
+ <.skip_link /> + + <%= if @theme_settings.announcement_bar do %> + <.announcement_bar theme_settings={@theme_settings} /> + <% end %> + + <.shop_header theme_settings={@theme_settings} logo_image={@logo_image} header_image={@header_image} active_page="collection" mode={:shop} cart_count={0} /> + +
+ <.collection_header title="All Products" product_count={length(@preview_data.products)} /> + +
+ <.filter_bar categories={@preview_data.categories} /> + + <.product_grid theme_settings={@theme_settings}> + <%= for product <- @preview_data.products do %> + <.product_card + product={product} + theme_settings={@theme_settings} + mode={:shop} + variant={:default} + show_category={true} + /> + <% end %> + +
+
+ + <.shop_footer theme_settings={@theme_settings} mode={:shop} /> + + <.cart_drawer cart_items={[]} subtotal="£0.00" mode={:shop} /> + + <.search_modal hint_text={~s(Try searching for "mountain", "forest", or "ocean")} /> +
diff --git a/lib/simpleshop_theme_web/router.ex b/lib/simpleshop_theme_web/router.ex index 1b773ab..a4d79c0 100644 --- a/lib/simpleshop_theme_web/router.ex +++ b/lib/simpleshop_theme_web/router.ex @@ -29,6 +29,7 @@ defmodule SimpleshopThemeWeb.Router do live "/", ShopLive.Home, :index live "/about", ShopLive.About, :index live "/contact", ShopLive.Contact, :index + live "/products", ShopLive.Products, :index end end