diff --git a/lib/simpleshop_theme_web/live/theme_live/index.ex b/lib/simpleshop_theme_web/live/theme_live/index.ex
index 01dbcff..df9f8a2 100644
--- a/lib/simpleshop_theme_web/live/theme_live/index.ex
+++ b/lib/simpleshop_theme_web/live/theme_live/index.ex
@@ -308,7 +308,16 @@ defmodule SimpleshopThemeWeb.ThemeLive.Index do
def error_to_string(:not_accepted), do: "File type not accepted"
def error_to_string(err), do: inspect(err)
- # Preview page component - delegates to shared PageTemplates with preview-specific assigns
+ defp preview_assigns(assigns) do
+ assign(assigns, %{
+ mode: :preview,
+ cart_items: PreviewData.cart_drawer_items(),
+ cart_count: 2,
+ cart_subtotal: "£72.00"
+ })
+ end
+
+ # Preview page component — delegates to shared PageTemplates with preview-specific assigns
attr :page, :atom, required: true
attr :preview_data, :map, required: true
attr :theme_settings, :map, required: true
@@ -317,35 +326,13 @@ defmodule SimpleshopThemeWeb.ThemeLive.Index do
attr :cart_drawer_open, :boolean, default: false
defp preview_page(%{page: :home} = assigns) do
- ~H"""
-
- """
+ assigns = preview_assigns(assigns)
+ ~H""
end
defp preview_page(%{page: :collection} = assigns) do
- ~H"""
-
- """
+ assigns = preview_assigns(assigns)
+ ~H""
end
defp preview_page(%{page: :pdp} = assigns) do
@@ -353,14 +340,12 @@ defmodule SimpleshopThemeWeb.ThemeLive.Index do
option_types = product[:option_types] || []
variants = product[:variants] || []
- # Select first variant by default for preview
{selected_options, selected_variant} =
case variants do
[first | _] -> {first.options, first}
[] -> {%{}, nil}
end
- # All options available in preview mode (show all values)
available_options =
Enum.reduce(option_types, %{}, fn opt, acc ->
values = Enum.map(opt.values, & &1.title)
@@ -372,6 +357,7 @@ defmodule SimpleshopThemeWeb.ThemeLive.Index do
assigns =
assigns
+ |> preview_assigns()
|> assign(:product, product)
|> assign(:gallery_images, build_gallery_images(product))
|> assign(:related_products, Enum.slice(assigns.preview_data.products, 1, 4))
@@ -379,27 +365,9 @@ defmodule SimpleshopThemeWeb.ThemeLive.Index do
|> assign(:selected_options, selected_options)
|> assign(:available_options, available_options)
|> assign(:display_price, display_price)
+ |> assign(:quantity, 1)
- ~H"""
-
- """
+ ~H""
end
defp preview_page(%{page: :cart} = assigns) do
@@ -410,136 +378,89 @@ defmodule SimpleshopThemeWeb.ThemeLive.Index do
assigns =
assigns
+ |> preview_assigns()
|> assign(:cart_page_items, cart_items)
|> assign(:cart_page_subtotal, subtotal)
- ~H"""
-
- """
+ ~H""
end
defp preview_page(%{page: :about} = assigns) do
- ~H"""
-
- """
+ assigns =
+ assigns
+ |> preview_assigns()
+ |> assign(%{
+ active_page: "about",
+ hero_title: "About the studio",
+ hero_description: "Your story goes here – this is sample content for the demo shop",
+ hero_background: :sunken,
+ image_src: "/mockups/night-sky-blanket-3",
+ image_alt: "Night sky blanket draped over a chair",
+ content_blocks: PreviewData.about_content()
+ })
+
+ ~H""
end
defp preview_page(%{page: :delivery} = assigns) do
- ~H"""
-
- """
+ assigns =
+ assigns
+ |> preview_assigns()
+ |> assign(%{
+ active_page: "delivery",
+ hero_title: "Delivery & returns",
+ hero_description: "Everything you need to know about shipping and returns",
+ content_blocks: PreviewData.delivery_content()
+ })
+
+ ~H""
end
defp preview_page(%{page: :privacy} = assigns) do
- ~H"""
-
- """
+ assigns =
+ assigns
+ |> preview_assigns()
+ |> assign(%{
+ active_page: "privacy",
+ hero_title: "Privacy policy",
+ hero_description: "How we handle your personal information",
+ content_blocks: PreviewData.privacy_content()
+ })
+
+ ~H""
end
defp preview_page(%{page: :terms} = assigns) do
- ~H"""
-
- """
+ assigns =
+ assigns
+ |> preview_assigns()
+ |> assign(%{
+ active_page: "terms",
+ hero_title: "Terms of service",
+ hero_description: "The legal bits",
+ content_blocks: PreviewData.terms_content()
+ })
+
+ ~H""
end
defp preview_page(%{page: :contact} = assigns) do
- ~H"""
-
- """
+ assigns = preview_assigns(assigns)
+ ~H""
end
defp preview_page(%{page: :error} = assigns) do
- ~H"""
-
- """
+ assigns =
+ assigns
+ |> preview_assigns()
+ |> assign(%{
+ error_code: "404",
+ error_title: "Page Not Found",
+ error_description:
+ "Sorry, we couldn't find the page you're looking for. Perhaps you've mistyped the URL or the page has been moved."
+ })
+
+ ~H""
end
defp build_gallery_images(product) do