From 7b1b81c45ad6c6f1bc6935cad9b253cb02bad3ca Mon Sep 17 00:00:00 2001 From: XShine555 Date: Sun, 20 Sep 2026 22:26:37 +0200 Subject: [PATCH] web-player: single source of truth for theme, no light-mode flash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the duplication of the ~18 per-hue dynamic tokens between theme.css and buildThemeTokens(): theme.css now only defines fixed neutrals, surfaces, layout and z-index; hue/mode-dependent values come solely from tokens.ts, injected via SSR as an inline doesn't interpolate in Svelte (it compiles as component-scoped CSS) — the SSR block is injected with {@html ``} since the content is fully generated (no user input). Verified in the browser: --mf-accent/--mf-bg resolve correctly during SSR, data-theme='light' applies before the first render with no flash. --- web-player/docs/frontend-refactor-plan.md | 2 +- web-player/src/app.html | 7 +++ web-player/src/lib/theme/theme.css | 73 +++-------------------- web-player/src/lib/theme/tokens.ts | 6 ++ web-player/src/routes/+layout.svelte | 26 ++++---- web-player/src/routes/layout.css | 29 +++++++++ 6 files changed, 60 insertions(+), 83 deletions(-) diff --git a/web-player/docs/frontend-refactor-plan.md b/web-player/docs/frontend-refactor-plan.md index 289498e..8dc5a0c 100644 --- a/web-player/docs/frontend-refactor-plan.md +++ b/web-player/docs/frontend-refactor-plan.md @@ -774,7 +774,7 @@ Tareas: | ----- | ------ | ------ | -------------------------- | | P0 | ✅ | (pendiente) | Button primary/secondary se mantienen iguales (decisión del usuario) | | P1 | ✅ | (pendiente) | Verificado con `build` (Tailwind compila `@apply sm:` dentro de `@utility`); sin QA visual autenticada (Docker no disponible en esta sesión) | -| P2 | ⬜ | | | +| P2 | ✅ | (pendiente) | `` no interpola en Svelte (se trata como CSS del componente); solución: `{@html \`\`}` | | P3 | ⬜ | | | | P4 | ⬜ | | | | P5 | ⬜ | | | diff --git a/web-player/src/app.html b/web-player/src/app.html index 04bc5f9..4d12503 100644 --- a/web-player/src/app.html +++ b/web-player/src/app.html @@ -3,6 +3,13 @@ + %sveltekit.head% diff --git a/web-player/src/lib/theme/theme.css b/web-player/src/lib/theme/theme.css index d170552..f8fbc85 100644 --- a/web-player/src/lib/theme/theme.css +++ b/web-player/src/lib/theme/theme.css @@ -1,55 +1,17 @@ :root { - /* Dynamic tokens: overwritten at runtime from the playing track's hue. - These are the fallback values for the default accent (hue 145) so the - page never flashes unstyled before hydration. See theme/tokens.ts. */ - --mf-bg: oklch(0.068 0.008 145); - --mf-elevated: oklch(0.11 0.012 145); - --mf-panel-bg: oklch(0.09 0.01 145 / 0.28); - --mf-bar-bg: oklch(0.105 0.012 145 / 0.9); - --mf-hairline: oklch(0.62 0.03 145 / 0.08); - --mf-ambient: - radial-gradient(52% 38% at 14% 0%, oklch(0.2611 0.0913 145 / 0.26), transparent 54%), - radial-gradient(46% 34% at 78% 0%, oklch(0.2347 0.085 145 / 0.2), transparent 56%); - --mf-hero-bg: linear-gradient( - 105deg, - oklch(0.2295 0.0838 145 / 0.34) 0%, - oklch(0.1558 0.0663 145 / 0.11) 37%, - oklch(0.1084 0.055 145 / 0.03) 65%, - rgba(6, 6, 9, 0) 92% - ); - --mf-spotlight-bg: linear-gradient( - 100deg, - oklch(0.2189 0.0813 145 / 0.28) 0%, - oklch(0.1453 0.0638 145 / 0.1) 40%, - oklch(0.1084 0.055 145 / 0.03) 69%, - rgba(6, 6, 9, 0) 96% - ); - --mf-modal-glow: linear-gradient( - 135deg, - oklch(0.2295 0.0838 145 / 0.34) 0%, - oklch(0.1558 0.0663 145 / 0.11) 28%, - oklch(0.1084 0.055 145 / 0.03) 50%, - rgba(6, 6, 9, 0) 70% - ); - --mf-logo-grad: linear-gradient(140deg, oklch(0.78 0.15 145), oklch(0.62 0.13 185) 92%); - --mf-cover-grad: linear-gradient(150deg, oklch(0.5 0.13 145), oklch(0.16 0.035 145)); + /* Hue-based tokens (--mf-accent*, --mf-bg/elevated/panel-bg/bar-bg/hairline, + --mf-ambient, --mf-hero-bg/spotlight-bg/modal-glow, --mf-logo-grad, + --mf-cover-grad) are NOT defined here: they come only from + buildThemeTokens() in theme/tokens.ts, inlined as SSR `} + {#if isAuthPage || (!data.user && !data.allowAnonymousListening)}
@@ -91,14 +96,8 @@
{:else}
-
-
+
+
@@ -106,12 +105,7 @@
-
+
{#key page.url.pathname}
{@render children()}
{/key} diff --git a/web-player/src/routes/layout.css b/web-player/src/routes/layout.css index 7f5f769..0e7ac84 100644 --- a/web-player/src/routes/layout.css +++ b/web-player/src/routes/layout.css @@ -168,6 +168,35 @@ grid-template-columns: repeat(auto-fill, minmax(16.5rem, 1fr)); } +@utility app-backdrop { + pointer-events: none; + position: fixed; + inset: 0; + z-index: -10; + background-color: var(--mf-bg); + background-image: var(--mf-ambient); +} +@utility app-vignette { + pointer-events: none; + position: fixed; + inset: 0; + z-index: -10; + background: radial-gradient( + 130% 85% at 50% 118%, + color-mix(in oklch, var(--mf-scrim) 80%, transparent), + transparent 62% + ); +} +@utility app-main { + --mf-dock-h: 0px; + padding-bottom: calc(var(--mf-nav-h) + var(--mf-safe-b) + var(--mf-dock-h)); + transition: padding 0.3s; + + &[data-has-track] { + --mf-dock-h: var(--mf-player-h); + } +} + @layer base { svg.lucide { stroke-width: 1.8;