diff --git a/lib/simpleshop_theme_web/components/shop_components.ex b/lib/simpleshop_theme_web/components/shop_components.ex
index 9f9d1d6..d1b5312 100644
--- a/lib/simpleshop_theme_web/components/shop_components.ex
+++ b/lib/simpleshop_theme_web/components/shop_components.ex
@@ -781,4 +781,82 @@ defmodule SimpleshopThemeWeb.ShopComponents do
defp title_style(:featured), do: "color: var(--t-text-primary);"
defp title_style(:compact), do: "font-family: var(--t-font-heading); color: var(--t-text-primary);"
defp title_style(:minimal), do: "color: var(--t-text-primary);"
+
+ @doc """
+ Renders a responsive product grid container.
+
+ This component wraps product cards in a responsive grid layout. It supports
+ theme-based column settings or fixed column layouts for specific use cases.
+
+ ## Attributes
+
+ * `theme_settings` - Optional. When provided, uses `grid_columns` setting for lg breakpoint.
+ * `columns` - Optional. Fixed column count for lg breakpoint (overrides theme_settings).
+ Use `:fixed_4` for a fixed 2/4 column layout (error page, related products).
+ * `gap` - Optional. Gap size. Defaults to standard gap.
+ * `class` - Optional. Additional CSS classes to add.
+
+ ## Slots
+
+ * `inner_block` - Required. The product cards to render inside the grid.
+
+ ## Examples
+
+ <.product_grid theme_settings={@theme_settings}>
+ <%= for product <- @products do %>
+ <.product_card product={product} theme_settings={@theme_settings} />
+ <% end %>
+
+
+ <.product_grid columns={:fixed_4} gap="gap-6">
+ ...
+
+ """
+ attr :theme_settings, :map, default: nil
+ attr :columns, :atom, default: nil
+ attr :gap, :string, default: nil
+ attr :class, :string, default: nil
+
+ slot :inner_block, required: true
+
+ def product_grid(assigns) do
+ ~H"""
+
+ <%= render_slot(@inner_block) %>
+
+ """
+ end
+
+ defp grid_classes(theme_settings, columns, gap, extra_class) do
+ base = "product-grid grid"
+
+ cols =
+ cond do
+ columns == :fixed_4 ->
+ "grid-cols-2 md:grid-cols-4"
+
+ theme_settings != nil ->
+ responsive_cols = "grid-cols-1 sm:grid-cols-2"
+
+ lg_cols =
+ case theme_settings.grid_columns do
+ "2" -> "lg:grid-cols-2"
+ "3" -> "lg:grid-cols-3"
+ "4" -> "lg:grid-cols-4"
+ _ -> "lg:grid-cols-3"
+ end
+
+ "#{responsive_cols} #{lg_cols}"
+
+ true ->
+ "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3"
+ end
+
+ gap_class = gap || ""
+
+ [base, cols, gap_class, extra_class]
+ |> Enum.reject(&is_nil/1)
+ |> Enum.reject(&(&1 == ""))
+ |> Enum.join(" ")
+ end
end
diff --git a/lib/simpleshop_theme_web/live/theme_live/preview_pages/collection.html.heex b/lib/simpleshop_theme_web/live/theme_live/preview_pages/collection.html.heex
index dc36b33..77fa2d4 100644
--- a/lib/simpleshop_theme_web/live/theme_live/preview_pages/collection.html.heex
+++ b/lib/simpleshop_theme_web/live/theme_live/preview_pages/collection.html.heex
@@ -52,25 +52,17 @@
- "lg:grid-cols-2"
- "3" -> "lg:grid-cols-3"
- "4" -> "lg:grid-cols-4"
- _ -> "lg:grid-cols-3"
- end
- ]}>
- <%= for product <- @preview_data.products do %>
- <.product_card
- product={product}
- theme_settings={@theme_settings}
- mode={:preview}
- variant={:default}
- show_category={true}
- />
- <% end %>
-
+ <.product_grid theme_settings={@theme_settings}>
+ <%= for product <- @preview_data.products do %>
+ <.product_card
+ product={product}
+ theme_settings={@theme_settings}
+ mode={:preview}
+ variant={:default}
+ show_category={true}
+ />
+ <% end %>
+
diff --git a/lib/simpleshop_theme_web/live/theme_live/preview_pages/error.html.heex b/lib/simpleshop_theme_web/live/theme_live/preview_pages/error.html.heex
index 83df93d..d528dc1 100644
--- a/lib/simpleshop_theme_web/live/theme_live/preview_pages/error.html.heex
+++ b/lib/simpleshop_theme_web/live/theme_live/preview_pages/error.html.heex
@@ -40,7 +40,7 @@
-
+ <.product_grid columns={:fixed_4} gap="gap-4" class="mt-12 max-w-xl mx-auto">
<%= for product <- Enum.take(@preview_data.products, 4) do %>
<.product_card
product={product}
@@ -49,7 +49,7 @@
variant={:minimal}
/>
<% end %>
-
+
diff --git a/lib/simpleshop_theme_web/live/theme_live/preview_pages/home.html.heex b/lib/simpleshop_theme_web/live/theme_live/preview_pages/home.html.heex
index 8e49838..4122d78 100644
--- a/lib/simpleshop_theme_web/live/theme_live/preview_pages/home.html.heex
+++ b/lib/simpleshop_theme_web/live/theme_live/preview_pages/home.html.heex
@@ -52,15 +52,7 @@
Featured products
- "lg:grid-cols-2"
- "3" -> "lg:grid-cols-3"
- "4" -> "lg:grid-cols-4"
- _ -> "lg:grid-cols-3"
- end
- ]}>
+ <.product_grid theme_settings={@theme_settings}>
<%= for product <- Enum.take(@preview_data.products, 4) do %>
<.product_card
product={product}
@@ -69,7 +61,7 @@
variant={:featured}
/>
<% end %>
-
+
<% end %>