feat: add shop storefront with optimized theme CSS
- Create LoadTheme plug for loading theme settings - Add shop layout with inline CSS injection (~400 bytes vs 17KB full) - Create ShopLive.Home at / using shared ShopComponents - Wire up CSS cache invalidation when theme settings change - Replace Phoenix welcome page with themed shop home page The shop layout injects only the active theme CSS variables inline, achieving a 97% reduction compared to the full variants file used by the theme editor. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
30
lib/simpleshop_theme_web/components/layouts/shop.html.heex
Normal file
30
lib/simpleshop_theme_web/components/layouts/shop.html.heex
Normal file
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="h-full">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="csrf-token" content={get_csrf_token()} />
|
||||
<.live_title><%= assigns[:page_title] || @theme_settings.site_name %></.live_title>
|
||||
<link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} />
|
||||
<script defer phx-track-static type="text/javascript" src={~p"/assets/app.js"}>
|
||||
</script>
|
||||
<!-- Generated theme CSS (only active values, not all variants) -->
|
||||
<style id="theme-css"><%= Phoenix.HTML.raw(@generated_css) %></style>
|
||||
</head>
|
||||
<body class="h-full">
|
||||
<div
|
||||
class="shop-root h-full"
|
||||
data-mood={@theme_settings.mood}
|
||||
data-typography={@theme_settings.typography}
|
||||
data-shape={@theme_settings.shape}
|
||||
data-density={@theme_settings.density}
|
||||
data-grid={@theme_settings.grid_columns}
|
||||
data-header={@theme_settings.header_layout}
|
||||
data-sticky={to_string(@theme_settings.sticky_header)}
|
||||
data-layout={@theme_settings.layout_width}
|
||||
data-shadow={@theme_settings.card_shadow}
|
||||
>
|
||||
<%= @inner_content %>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user