refactor: extract shop_layout component to eliminate template boilerplate

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-02-08 12:10:08 +00:00
parent e6d4fce656
commit 8be1f90f2d
10 changed files with 173 additions and 320 deletions

View File

@@ -78,27 +78,18 @@ defmodule SimpleshopThemeWeb.ShopLive.Collection do
@impl true
def render(assigns) do
~H"""
<div
id="shop-container"
phx-hook="CartPersist"
class="shop-container min-h-screen pb-20 md:pb-0"
style="background-color: var(--t-surface-base); font-family: var(--t-font-body); color: var(--t-text-primary);"
<SimpleshopThemeWeb.ShopComponents.shop_layout
theme_settings={@theme_settings}
logo_image={@logo_image}
header_image={@header_image}
mode={@mode}
cart_items={@cart_items}
cart_count={@cart_count}
cart_subtotal={@cart_subtotal}
cart_drawer_open={@cart_drawer_open}
cart_status={assigns[:cart_status]}
active_page="collection"
>
<SimpleshopThemeWeb.ShopComponents.skip_link />
<%= if @theme_settings.announcement_bar do %>
<SimpleshopThemeWeb.ShopComponents.announcement_bar theme_settings={@theme_settings} />
<% end %>
<SimpleshopThemeWeb.ShopComponents.shop_header
theme_settings={@theme_settings}
logo_image={@logo_image}
header_image={@header_image}
active_page="collection"
mode={@mode}
cart_count={@cart_count}
/>
<main id="main-content">
<SimpleshopThemeWeb.ShopComponents.collection_header
title={@collection_title}
@@ -139,24 +130,7 @@ defmodule SimpleshopThemeWeb.ShopLive.Collection do
<% end %>
</div>
</main>
<SimpleshopThemeWeb.ShopComponents.shop_footer theme_settings={@theme_settings} mode={@mode} />
<SimpleshopThemeWeb.ShopComponents.cart_drawer
cart_items={@cart_items}
subtotal={@cart_subtotal}
cart_count={@cart_count}
mode={@mode}
open={@cart_drawer_open}
cart_status={assigns[:cart_status]}
/>
<SimpleshopThemeWeb.ShopComponents.search_modal hint_text={
~s(Try searching for "mountain", "forest", or "ocean")
} />
<SimpleshopThemeWeb.ShopComponents.mobile_bottom_nav active_page="collection" mode={@mode} />
</div>
</SimpleshopThemeWeb.ShopComponents.shop_layout>
"""
end