wire simple pages to PageRenderer (stage 3)
Home, Content (about/delivery/privacy/terms), Contact, and ErrorHTML now render through the generic PageRenderer instead of hardcoded templates. Block wrapper divs enable CSS grid targeting. Featured products block supports layout/card_variant/columns settings for different page contexts. Contact page uses CSS grid on data-block-type attributes for two-column layout. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -30,9 +30,9 @@ defmodule BerrypodWeb.PageRenderer do
|
||||
error_page={@page.slug == "error"}
|
||||
>
|
||||
<main id="main-content" class={page_main_class(@page.slug)}>
|
||||
<%= for block <- @page.blocks do %>
|
||||
<div :for={block <- @page.blocks} data-block-type={block["type"]}>
|
||||
{render_block(Map.merge(@block_assigns, %{block: block, page_slug: @page.slug}))}
|
||||
<% end %>
|
||||
</div>
|
||||
</main>
|
||||
</.shop_layout>
|
||||
"""
|
||||
@@ -85,14 +85,30 @@ defmodule BerrypodWeb.PageRenderer do
|
||||
assigns =
|
||||
assigns
|
||||
|> assign(:section_title, settings["title"] || "Featured products")
|
||||
|> assign(:layout, settings["layout"] || "section")
|
||||
|> assign(:card_variant, card_variant(settings["card_variant"]))
|
||||
|> assign(:columns, grid_columns(settings["columns"]))
|
||||
|
||||
~H"""
|
||||
<.featured_products_section
|
||||
title={@section_title}
|
||||
products={assigns[:products] || []}
|
||||
theme_settings={@theme_settings}
|
||||
mode={@mode}
|
||||
/>
|
||||
<%= if @layout == "grid" do %>
|
||||
<.product_grid columns={@columns} theme_settings={@theme_settings}>
|
||||
<%= for product <- assigns[:products] || [] do %>
|
||||
<.product_card
|
||||
product={product}
|
||||
theme_settings={@theme_settings}
|
||||
mode={@mode}
|
||||
variant={@card_variant}
|
||||
/>
|
||||
<% end %>
|
||||
</.product_grid>
|
||||
<% else %>
|
||||
<.featured_products_section
|
||||
title={@section_title}
|
||||
products={assigns[:products] || []}
|
||||
theme_settings={@theme_settings}
|
||||
mode={@mode}
|
||||
/>
|
||||
<% end %>
|
||||
"""
|
||||
end
|
||||
|
||||
@@ -728,6 +744,14 @@ defmodule BerrypodWeb.PageRenderer do
|
||||
defp hero_background("sunken"), do: :sunken
|
||||
defp hero_background(_), do: :base
|
||||
|
||||
defp card_variant("minimal"), do: :minimal
|
||||
defp card_variant("compact"), do: :compact
|
||||
defp card_variant("default"), do: :default
|
||||
defp card_variant(_), do: :featured
|
||||
|
||||
defp grid_columns("fixed-4"), do: :fixed_4
|
||||
defp grid_columns(_), do: nil
|
||||
|
||||
defp breadcrumb_items(%{category: cat, title: title}) when not is_nil(cat) do
|
||||
slug = cat |> String.downcase() |> String.replace(" ", "-")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user