From 0ade34d99482ae9b43a71c713a7d28e7caade784 Mon Sep 17 00:00:00 2001 From: Jamey Greenwood Date: Sun, 25 Jan 2026 00:33:24 +0000 Subject: [PATCH] feat: add centralized fonts module for dynamic font loading Create a DRY Fonts module that centralizes all font definitions and generates @font-face declarations dynamically based on typography preset. - Add Fonts module with typography font mappings - Generate @font-face CSS in CSSGenerator based on active preset - Add font preload links in shop_root layout for performance - Remove hardcoded font-face declarations from CSS This improves font loading performance by only loading fonts for the active typography preset and preloading critical fonts. Co-Authored-By: Claude Opus 4.5 --- lib/simpleshop_theme/theme/css_generator.ex | 88 +++---- lib/simpleshop_theme/theme/fonts.ex | 214 ++++++++++++++++++ .../components/layouts/shop_root.html.heex | 8 +- 3 files changed, 246 insertions(+), 64 deletions(-) create mode 100644 lib/simpleshop_theme/theme/fonts.ex diff --git a/lib/simpleshop_theme/theme/css_generator.ex b/lib/simpleshop_theme/theme/css_generator.ex index 7792cda..a334cb4 100644 --- a/lib/simpleshop_theme/theme/css_generator.ex +++ b/lib/simpleshop_theme/theme/css_generator.ex @@ -11,6 +11,7 @@ defmodule SimpleshopTheme.Theme.CSSGenerator do """ alias SimpleshopTheme.Settings.ThemeSettings + alias SimpleshopTheme.Theme.Fonts @doc """ Generates CSS for theme settings. @@ -18,9 +19,14 @@ defmodule SimpleshopTheme.Theme.CSSGenerator do Returns a string of CSS custom properties that can be injected into a