refactor: extract announcement_bar to shared ShopComponents module
Move announcement_bar from ThemeLive.PreviewPages to a new shared SimpleshopThemeWeb.ShopComponents module. This establishes the pattern for Phase 9 storefront integration where components need to work in both the admin theme preview and public storefront pages. Changes: - Create lib/simpleshop_theme_web/components/shop_components.ex - Add optional message attribute (defaults to "Free delivery over £40") - Import ShopComponents in html_helpers for global availability - Import ShopComponents in PreviewPages for embedded template access - Update all 7 preview templates to use short-form <.announcement_bar> - Remove original announcement_bar/1 from PreviewPages (now unused) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
defmodule SimpleshopThemeWeb.ThemeLive.PreviewPages do
|
||||
use Phoenix.Component
|
||||
import SimpleshopThemeWeb.ShopComponents
|
||||
|
||||
embed_templates "preview_pages/*"
|
||||
|
||||
@@ -14,22 +15,6 @@ defmodule SimpleshopThemeWeb.ThemeLive.PreviewPages do
|
||||
"""
|
||||
end
|
||||
|
||||
@doc """
|
||||
Renders the announcement bar.
|
||||
"""
|
||||
attr :theme_settings, :map, required: true
|
||||
|
||||
def announcement_bar(assigns) do
|
||||
~H"""
|
||||
<div
|
||||
class="announcement-bar"
|
||||
style="background-color: hsl(var(--t-accent-h) var(--t-accent-s) var(--t-accent-l)); color: var(--t-text-inverse); text-align: center; padding: 0.5rem 1rem; font-size: var(--t-text-small);"
|
||||
>
|
||||
<p style="margin: 0;">Free delivery on orders over £40</p>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
@doc """
|
||||
Renders the shop header with logo based on logo_mode setting.
|
||||
"""
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<!-- Announcement Bar -->
|
||||
<%= if @theme_settings.announcement_bar do %>
|
||||
<SimpleshopThemeWeb.ThemeLive.PreviewPages.announcement_bar theme_settings={@theme_settings} />
|
||||
<.announcement_bar theme_settings={@theme_settings} />
|
||||
<% end %>
|
||||
|
||||
<!-- Header -->
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<!-- Announcement Bar -->
|
||||
<%= if @theme_settings.announcement_bar do %>
|
||||
<SimpleshopThemeWeb.ThemeLive.PreviewPages.announcement_bar theme_settings={@theme_settings} />
|
||||
<.announcement_bar theme_settings={@theme_settings} />
|
||||
<% end %>
|
||||
|
||||
<!-- Header -->
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<!-- Announcement Bar -->
|
||||
<%= if @theme_settings.announcement_bar do %>
|
||||
<SimpleshopThemeWeb.ThemeLive.PreviewPages.announcement_bar theme_settings={@theme_settings} />
|
||||
<.announcement_bar theme_settings={@theme_settings} />
|
||||
<% end %>
|
||||
|
||||
<!-- Header -->
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<!-- Announcement Bar -->
|
||||
<%= if @theme_settings.announcement_bar do %>
|
||||
<SimpleshopThemeWeb.ThemeLive.PreviewPages.announcement_bar theme_settings={@theme_settings} />
|
||||
<.announcement_bar theme_settings={@theme_settings} />
|
||||
<% end %>
|
||||
|
||||
<!-- Header -->
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<!-- Announcement Bar -->
|
||||
<%= if @theme_settings.announcement_bar do %>
|
||||
<SimpleshopThemeWeb.ThemeLive.PreviewPages.announcement_bar theme_settings={@theme_settings} />
|
||||
<.announcement_bar theme_settings={@theme_settings} />
|
||||
<% end %>
|
||||
|
||||
<!-- Header -->
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<!-- Announcement Bar -->
|
||||
<%= if @theme_settings.announcement_bar do %>
|
||||
<SimpleshopThemeWeb.ThemeLive.PreviewPages.announcement_bar theme_settings={@theme_settings} />
|
||||
<.announcement_bar theme_settings={@theme_settings} />
|
||||
<% end %>
|
||||
|
||||
<!-- Header -->
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<!-- Announcement Bar -->
|
||||
<%= if @theme_settings.announcement_bar do %>
|
||||
<SimpleshopThemeWeb.ThemeLive.PreviewPages.announcement_bar theme_settings={@theme_settings} />
|
||||
<.announcement_bar theme_settings={@theme_settings} />
|
||||
<% end %>
|
||||
|
||||
<!-- Header -->
|
||||
|
||||
Reference in New Issue
Block a user