extract site_name and site_description from theme settings into standalone settings

site_name and site_description are shop identity, not theme concerns.
They now live in the Settings table as first-class settings with their
own assigns (@site_name, @site_description) piped through hooks and
plugs. The setup wizard writes site_name on account creation, and the
theme editor reads/writes via Settings.put_setting. Removed the
"configure your shop" checklist item since currency/country aren't
built yet. Also adds shop name field to setup wizard step 1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-03-03 14:52:31 +00:00
parent 8ea77e5992
commit 5b41f3fedf
25 changed files with 464 additions and 255 deletions

View File

@@ -7,8 +7,8 @@
<meta
name="description"
content={
assigns[:page_description] || @theme_settings.site_description ||
"Welcome to #{@theme_settings.site_name}"
assigns[:page_description] || @site_description ||
"Welcome to #{@site_name}"
}
/>
<!-- Favicon & PWA -->
@@ -17,19 +17,19 @@
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<link rel="manifest" href="/site.webmanifest" />
<meta name="theme-color" content={@theme_settings.accent_color || "#000000"} />
<.live_title suffix={" · #{@theme_settings.site_name}"}>
<.live_title suffix={" · #{@site_name}"}>
{assigns[:page_title]}
</.live_title>
<% og_title =
if assigns[:page_title],
do: "#{assigns[:page_title]} · #{@theme_settings.site_name}",
else: @theme_settings.site_name
do: "#{assigns[:page_title]} · #{@site_name}",
else: @site_name
og_description =
assigns[:page_description] ||
@theme_settings.site_description ||
"Welcome to #{@theme_settings.site_name}" %>
<meta property="og:site_name" content={@theme_settings.site_name} />
@site_description ||
"Welcome to #{@site_name}" %>
<meta property="og:site_name" content={@site_name} />
<meta property="og:title" content={og_title} />
<meta property="og:description" content={og_description} />
<meta property="og:type" content={assigns[:og_type] || "website"} />

View File

@@ -48,7 +48,7 @@ defmodule BerrypodWeb.ShopComponents.Layout do
# Keys accepted by shop_layout — used by layout_assigns/1 so page templates
# can spread assigns without listing each one explicitly.
@layout_keys ~w(theme_settings logo_image header_image mode cart_items cart_count
@layout_keys ~w(theme_settings site_name logo_image header_image mode cart_items cart_count
cart_subtotal cart_total cart_drawer_open cart_status active_page error_page is_admin
search_query search_results search_open categories shipping_estimate
country_code available_countries editing editor_current_path editor_sidebar_open
@@ -75,6 +75,7 @@ defmodule BerrypodWeb.ShopComponents.Layout do
The `error_page` flag disables the CartPersist hook and mobile bottom nav.
"""
attr :theme_settings, :map, required: true
attr :site_name, :string, required: true
attr :logo_image, :any, required: true
attr :header_image, :any, required: true
attr :mode, :atom, required: true
@@ -119,6 +120,7 @@ defmodule BerrypodWeb.ShopComponents.Layout do
<.shop_header
theme_settings={@theme_settings}
site_name={@site_name}
logo_image={@logo_image}
header_image={@header_image}
active_page={@active_page}
@@ -135,6 +137,7 @@ defmodule BerrypodWeb.ShopComponents.Layout do
<.shop_footer
theme_settings={@theme_settings}
site_name={@site_name}
mode={@mode}
categories={assigns[:categories] || []}
footer_nav_items={@footer_nav_items}
@@ -513,7 +516,7 @@ defmodule BerrypodWeb.ShopComponents.Layout do
## Attributes
* `theme_settings` - Required. The theme settings map containing site_name.
* `theme_settings` - Required. The theme settings map.
* `mode` - Optional. Either `:live` (default) for real navigation or
`:preview` for theme preview mode with phx-click handlers.
@@ -523,6 +526,7 @@ defmodule BerrypodWeb.ShopComponents.Layout do
<.shop_footer theme_settings={@theme_settings} mode={:preview} />
"""
attr :theme_settings, :map, required: true
attr :site_name, :string, required: true
attr :mode, :atom, default: :live
attr :categories, :list, default: []
attr :footer_nav_items, :list, default: []
@@ -622,7 +626,7 @@ defmodule BerrypodWeb.ShopComponents.Layout do
<!-- Bottom Bar -->
<div class="footer-bottom">
<p class="footer-copyright">
© {@current_year} {@theme_settings.site_name}
© {@current_year} {@site_name}
</p>
<.social_links />
</div>
@@ -649,6 +653,7 @@ defmodule BerrypodWeb.ShopComponents.Layout do
<.shop_header theme_settings={@theme_settings} mode={:preview} cart_count={2} />
"""
attr :theme_settings, :map, required: true
attr :site_name, :string, required: true
attr :logo_image, :map, default: nil
attr :header_image, :map, default: nil
attr :active_page, :string, default: nil
@@ -670,6 +675,7 @@ defmodule BerrypodWeb.ShopComponents.Layout do
<div class="shop-logo">
<.logo_content
theme_settings={@theme_settings}
site_name={@site_name}
logo_image={@logo_image}
active_page={@active_page}
mode={@mode}
@@ -790,6 +796,7 @@ defmodule BerrypodWeb.ShopComponents.Layout do
# Logo content that links to home, except when already on home page.
# This follows accessibility best practices - current page should not be a link.
attr :theme_settings, :map, required: true
attr :site_name, :string, required: true
attr :logo_image, :map, default: nil
attr :active_page, :string, default: nil
attr :mode, :atom, default: :live
@@ -800,7 +807,7 @@ defmodule BerrypodWeb.ShopComponents.Layout do
~H"""
<%= if @is_home do %>
<.logo_inner theme_settings={@theme_settings} logo_image={@logo_image} />
<.logo_inner theme_settings={@theme_settings} site_name={@site_name} logo_image={@logo_image} />
<% else %>
<%= if @mode == :preview do %>
<a
@@ -809,11 +816,19 @@ defmodule BerrypodWeb.ShopComponents.Layout do
phx-value-page="home"
class="shop-logo-link"
>
<.logo_inner theme_settings={@theme_settings} logo_image={@logo_image} />
<.logo_inner
theme_settings={@theme_settings}
site_name={@site_name}
logo_image={@logo_image}
/>
</a>
<% else %>
<.link navigate="/" class="shop-logo-link">
<.logo_inner theme_settings={@theme_settings} logo_image={@logo_image} />
<.logo_inner
theme_settings={@theme_settings}
site_name={@site_name}
logo_image={@logo_image}
/>
</.link>
<% end %>
<% end %>
@@ -821,6 +836,7 @@ defmodule BerrypodWeb.ShopComponents.Layout do
end
attr :theme_settings, :map, required: true
attr :site_name, :string, required: true
attr :logo_image, :map, default: nil
defp logo_inner(assigns) do
@@ -828,36 +844,36 @@ defmodule BerrypodWeb.ShopComponents.Layout do
<%= case @theme_settings.logo_mode do %>
<% "text-only" -> %>
<span class="shop-logo-text">
{@theme_settings.site_name}
{@site_name}
</span>
<% "logo-text" -> %>
<%= if @logo_image do %>
<img
src={logo_url(@logo_image, @theme_settings)}
alt={@theme_settings.site_name}
alt={@site_name}
class="shop-logo-img"
style={"height: #{@theme_settings.logo_size}px;"}
/>
<% end %>
<span class="shop-logo-text">
{@theme_settings.site_name}
{@site_name}
</span>
<% "logo-only" -> %>
<%= if @logo_image do %>
<img
src={logo_url(@logo_image, @theme_settings)}
alt={@theme_settings.site_name}
alt={@site_name}
class="shop-logo-img"
style={"height: #{@theme_settings.logo_size}px;"}
/>
<% else %>
<span class="shop-logo-text">
{@theme_settings.site_name}
{@site_name}
</span>
<% end %>
<% _ -> %>
<span class="shop-logo-text">
{@theme_settings.site_name}
{@site_name}
</span>
<% end %>
"""