From 4355bb8406f00bc5350a7610f41af7496ae958d3 Mon Sep 17 00:00:00 2001 From: Daniel S Date: Sun, 9 Aug 2026 23:02:21 +0200 Subject: [PATCH] feat(theme): dynamic CSS custom properties for presets, light/dark mode and individual color overrides --- src/layouts/Layout.astro | 8 ++++++-- src/pages/admin/index.astro | 36 +++++++++++++++++++++++++++++++++--- src/utils/configLoader.ts | 4 ++++ 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 1f8dca4..7fe1663 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -20,7 +20,10 @@ interface Props { const { siteConfig, themeConfig } = loadWaasConfigs(Astro.request.headers.get('user-agent') ?? ''); const activePreset = THEME_PRESETS[themeConfig.activePreset] || THEME_PRESETS.corporateDark; -const colors = activePreset.colors; +const colors = { + ...activePreset.colors, + ...(themeConfig.customColors || {}) +}; const { title, description = "Professionelles Webdesign & moderne Websites.", ogImage } = Astro.props; @@ -54,10 +57,11 @@ const { title, description = "Professionelles Webdesign & moderne Websites.", og html.light { --theme-bg: #F8FAFC; - --theme-card-bg: rgba(255, 255, 255, 0.7); + --theme-card-bg: rgba(255, 255, 255, 0.85); --theme-text: #0F172A; --theme-border: rgba(0, 0, 0, 0.1); } + diff --git a/src/pages/admin/index.astro b/src/pages/admin/index.astro index 6203775..5248c58 100644 --- a/src/pages/admin/index.astro +++ b/src/pages/admin/index.astro @@ -154,12 +154,12 @@ const presets = Object.values(THEME_PRESETS);
- +

Theme Preset (10 Styles)

-
+
{presets.map((p) => (
+

@@ -258,8 +281,15 @@ const presets = Object.values(THEME_PRESETS); themeConfig: { - activePreset: selectedPreset + activePreset: selectedPreset, + customColors: { + bg: getVal('customColorBg'), + accent: getVal('customColorAccent'), + text: getVal('customColorText'), + border: getVal('customColorBorder') + } }, + smtpConfig: { host: getVal('smtpHost'), port: getNum('smtpPort'), diff --git a/src/utils/configLoader.ts b/src/utils/configLoader.ts index 66a7081..4eb1a8d 100644 --- a/src/utils/configLoader.ts +++ b/src/utils/configLoader.ts @@ -100,10 +100,14 @@ export interface ThemeConfig { glassBorderRadius?: string; // 'rounded-lg' | 'rounded-xl' | 'rounded-2xl' customColors?: { bg?: string; + cardBg?: string; + text?: string; accent?: string; + border?: string; }; } + export interface SmtpConfig { host: string; port: number;