add image uploads to on-site theme editor and fix scroll on navigation
All checks were successful
deploy / deploy (push) Successful in 1m27s

Phase 4 of unified editing: image upload handling in hook context.
- Configure uploads in Shop.Page mount for logo, header, icon
- Add upload UI components to theme_editor compact_editor
- Pass uploads through page_renderer to theme editor
- Add cancel_upload handler to PageEditorHook

Also fixes scroll position not resetting on patch navigation:
- Push scroll-top event when path changes in handle_params
- JS listener scrolls window to top instantly

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-03-09 19:45:43 +00:00
parent 89c411e0fc
commit 378b3fdb6b
6 changed files with 543 additions and 8 deletions

View File

@@ -111,6 +111,11 @@ defmodule BerrypodWeb.PageRenderer do
theme_editor_active_preset={Map.get(assigns, :theme_editor_active_preset)}
theme_editor_presets={Map.get(assigns, :theme_editor_presets, [])}
theme_editor_customise_open={Map.get(assigns, :theme_editor_customise_open, false)}
theme_editor_logo_image={Map.get(assigns, :theme_editor_logo_image)}
theme_editor_header_image={Map.get(assigns, :theme_editor_header_image)}
theme_editor_icon_image={Map.get(assigns, :theme_editor_icon_image)}
theme_editor_contrast_warning={Map.get(assigns, :theme_editor_contrast_warning, :ok)}
uploads={Map.get(assigns, :uploads)}
site_name={Map.get(assigns, :site_name, "")}
product={assigns[:product]}
collection_title={assigns[:collection_title]}
@@ -143,6 +148,11 @@ defmodule BerrypodWeb.PageRenderer do
attr :theme_editor_active_preset, :atom, default: nil
attr :theme_editor_presets, :list, default: []
attr :theme_editor_customise_open, :boolean, default: false
attr :theme_editor_logo_image, :map, default: nil
attr :theme_editor_header_image, :map, default: nil
attr :theme_editor_icon_image, :map, default: nil
attr :theme_editor_contrast_warning, :atom, default: :ok
attr :uploads, :map, default: nil
attr :site_name, :string, default: ""
attr :product, :map, default: nil
attr :collection_title, :string, default: nil
@@ -179,6 +189,11 @@ defmodule BerrypodWeb.PageRenderer do
theme_editor_active_preset={@theme_editor_active_preset}
theme_editor_presets={@theme_editor_presets}
theme_editor_customise_open={@theme_editor_customise_open}
theme_editor_logo_image={@theme_editor_logo_image}
theme_editor_header_image={@theme_editor_header_image}
theme_editor_icon_image={@theme_editor_icon_image}
theme_editor_contrast_warning={@theme_editor_contrast_warning}
uploads={@uploads}
site_name={@site_name}
/>
"""
@@ -203,6 +218,11 @@ defmodule BerrypodWeb.PageRenderer do
attr :theme_editor_active_preset, :atom, default: nil
attr :theme_editor_presets, :list, default: []
attr :theme_editor_customise_open, :boolean, default: false
attr :theme_editor_logo_image, :map, default: nil
attr :theme_editor_header_image, :map, default: nil
attr :theme_editor_icon_image, :map, default: nil
attr :theme_editor_contrast_warning, :atom, default: :ok
attr :uploads, :map, default: nil
attr :site_name, :string, default: ""
defp theme_editor_content(assigns) do
@@ -213,6 +233,11 @@ defmodule BerrypodWeb.PageRenderer do
presets={@theme_editor_presets}
site_name={@site_name}
customise_open={@theme_editor_customise_open}
uploads={@uploads}
logo_image={@theme_editor_logo_image}
header_image={@theme_editor_header_image}
icon_image={@theme_editor_icon_image}
contrast_warning={@theme_editor_contrast_warning}
event_prefix="theme_"
/>
"""