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 @@ +