move branding settings from Theme tab to Site tab
Some checks failed
deploy / deploy (push) Failing after 10m13s
Some checks failed
deploy / deploy (push) Failing after 10m13s
- Add branding_editor component to site_editor.ex with: - Shop name input - Show shop name / Show logo toggles - Logo upload (size slider, SVG recolor, color picker) - Header background toggle and upload (zoom, position sliders) - Add site_ prefixed event handlers in page_editor_hook.ex: - site_update_branding, site_toggle_branding, site_update_color - site_remove_logo and site_remove_header (delegate to theme handlers) - Remove branding sections from theme_editor.ex: - Deleted shop_name_input, branding_section, logo/header upload sections - Theme tab now shows only: preset grid, accent colours, customise accordion Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1127,6 +1127,63 @@ defmodule BerrypodWeb.PageEditorHook do
|
||||
{:halt, socket}
|
||||
end
|
||||
|
||||
# ── Site branding events (route to theme state) ─────────────────────
|
||||
|
||||
# Handle shop name and theme branding settings from Site tab
|
||||
defp handle_site_action("update_branding", %{"field" => "site_name"} = params, socket) do
|
||||
# Site name updates Settings immediately (same as theme tab)
|
||||
value = params["site_name"]
|
||||
|
||||
if value do
|
||||
Settings.put_setting("site_name", value, "string")
|
||||
{:halt, assign(socket, :site_name, value)}
|
||||
else
|
||||
{:halt, socket}
|
||||
end
|
||||
end
|
||||
|
||||
defp handle_site_action("update_branding", %{"field" => field} = params, socket) do
|
||||
# Route branding setting changes to theme state
|
||||
value = params[field] || params["setting_value"]
|
||||
|
||||
if value do
|
||||
field_atom = String.to_existing_atom(field)
|
||||
update_theme_setting(socket, %{field_atom => value}, field)
|
||||
else
|
||||
{:halt, socket}
|
||||
end
|
||||
end
|
||||
|
||||
defp handle_site_action("toggle_branding", %{"field" => field}, socket) do
|
||||
# Route toggle to theme state (same logic as theme_toggle_setting)
|
||||
field_atom = String.to_existing_atom(field)
|
||||
current_value = Map.get(socket.assigns.theme_editor_settings, field_atom)
|
||||
new_value = !current_value
|
||||
|
||||
# Prevent turning off show_site_name when there's no logo
|
||||
if field_atom == :show_site_name && new_value == false && !has_valid_logo?(socket) do
|
||||
{:halt, socket}
|
||||
else
|
||||
update_theme_setting(socket, %{field_atom => new_value}, field)
|
||||
end
|
||||
end
|
||||
|
||||
defp handle_site_action("update_color", %{"field" => field, "value" => value}, socket) do
|
||||
# Route color updates to theme state
|
||||
field_atom = String.to_existing_atom(field)
|
||||
update_theme_setting(socket, %{field_atom => value}, field)
|
||||
end
|
||||
|
||||
defp handle_site_action("remove_logo", _params, socket) do
|
||||
# Delegate to theme action handler
|
||||
handle_theme_action("remove_logo", %{}, socket)
|
||||
end
|
||||
|
||||
defp handle_site_action("remove_header", _params, socket) do
|
||||
# Delegate to theme action handler
|
||||
handle_theme_action("remove_header", %{}, socket)
|
||||
end
|
||||
|
||||
# Catch-all for unknown site actions
|
||||
defp handle_site_action(_action, _params, socket), do: {:halt, socket}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user