consolidate shop pages into unified LiveView for editor state persistence
All checks were successful
deploy / deploy (push) Successful in 1m27s

Replace individual shop LiveViews with a single Shop.Page that dispatches
to page modules based on live_action. This enables patch navigation between
pages, preserving socket state (including editor state) across transitions.

Changes:
- Add Shop.Page unified LiveView with handle_params dispatch
- Extract page logic into Shop.Pages.* modules (Home, Product, Collection, etc.)
- Update router to use Shop.Page with live_action for all shop routes
- Change navigate= to patch= in shop component links
- Add maybe_sync_editing_blocks to reload editor state when page changes
- Track editor_page_slug to detect cross-page navigation while editing
- Fix picture element height when hover image disabled
- Extract ThemeEditor components for shared use

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-03-09 14:47:50 +00:00
parent ae0a149ecd
commit bb5d220079
29 changed files with 1410 additions and 1037 deletions

View File

@@ -0,0 +1,79 @@
defmodule BerrypodWeb.Shop.Pages.Content do
@moduledoc """
Content page handler for the unified Shop.Page LiveView.
Handles about, delivery, privacy, and terms pages.
"""
import Phoenix.Component, only: [assign: 2, assign: 3]
alias Berrypod.LegalPages
alias Berrypod.Pages
alias Berrypod.Theme.PreviewData
def init(socket, _params, _uri) do
# Content pages load in handle_params based on live_action
{:noreply, socket}
end
def handle_params(_params, _uri, socket) do
action = socket.assigns.live_action
slug = to_string(action)
page = Pages.get_page(slug)
{seo, content_blocks} = page_config(action)
socket =
socket
|> assign(seo)
|> assign(:page, page)
|> assign(:content_blocks, content_blocks)
{:noreply, socket}
end
def handle_event(_event, _params, _socket), do: :cont
# Returns {seo_assigns, content_blocks} for each content page
defp page_config(:about) do
{
%{
page_title: "About",
page_description: "Your story goes here this is sample content for the demo shop",
og_url: BerrypodWeb.Endpoint.url() <> "/about"
},
PreviewData.about_content()
}
end
defp page_config(:delivery) do
{
%{
page_title: "Delivery & returns",
page_description: "Everything you need to know about shipping and returns.",
og_url: BerrypodWeb.Endpoint.url() <> "/delivery"
},
LegalPages.delivery_content()
}
end
defp page_config(:privacy) do
{
%{
page_title: "Privacy policy",
page_description: "How we handle your personal information.",
og_url: BerrypodWeb.Endpoint.url() <> "/privacy"
},
LegalPages.privacy_content()
}
end
defp page_config(:terms) do
{
%{
page_title: "Terms of service",
page_description: "The terms and conditions governing purchases from our shop.",
og_url: BerrypodWeb.Endpoint.url() <> "/terms"
},
LegalPages.terms_content()
}
end
end