diff --git a/src/lib/components/ColorPicker.svelte b/src/lib/components/ColorPicker.svelte index eeb1b2d..992c866 100644 --- a/src/lib/components/ColorPicker.svelte +++ b/src/lib/components/ColorPicker.svelte @@ -3,11 +3,13 @@ label, value = $bindable(''), gradient = false, + defaultValue = '', onchange }: { label: string; value: string; gradient?: boolean; + defaultValue?: string; onchange?: (value: string) => void; } = $props(); @@ -49,7 +51,11 @@ function switchMode(newMode: 'color' | 'gradient') { mode = newMode; - // Don't emit — let the user pick values first + if (newMode === 'color') { + emitColor(); + } else { + emitGradient(); + } } function clear() { @@ -63,6 +69,8 @@ {#if value} + {:else if defaultValue} + Default {/if} @@ -134,5 +142,7 @@ {#if value && mode === 'color'}
+ {:else if !value && defaultValue} +
{/if} diff --git a/src/lib/utils/theme-persist.ts b/src/lib/utils/theme-persist.ts index 4ab1f7a..28b4183 100644 --- a/src/lib/utils/theme-persist.ts +++ b/src/lib/utils/theme-persist.ts @@ -74,6 +74,21 @@ export function persistThemeCSS(theme: TenantThemeData) { if (theme.darkCardOpacity < 1) darkVars.push(` --card-backdrop-blur: blur(8px);`); } + // Handle background images + const extraRules: string[] = []; + if (theme.lightPageBgImage) { + extraRules.push(`.layout-page-bg { background-image: url('${theme.lightPageBgImage}'); }`); + } + if (theme.lightNavBgImage) { + extraRules.push(`.layout-nav-bg { background-image: url('${theme.lightNavBgImage}'); }`); + } + if (theme.darkPageBgImage) { + extraRules.push(`html.dark .layout-page-bg { background-image: url('${theme.darkPageBgImage}'); }`); + } + if (theme.darkNavBgImage) { + extraRules.push(`html.dark .layout-nav-bg { background-image: url('${theme.darkNavBgImage}'); }`); + } + let css = ''; if (lightVars.length > 0) { css += `:root {\n${lightVars.join('\n')}\n}\n`; @@ -81,6 +96,9 @@ export function persistThemeCSS(theme: TenantThemeData) { if (darkVars.length > 0) { css += `html.dark {\n${darkVars.join('\n')}\n}\n`; } + if (extraRules.length > 0) { + css += extraRules.join('\n') + '\n'; + } // Find or create the