fix(ssr): inject derived gradients and migrate component SCSS to CSS vars
CI Pipeline / backend-test (push) Successful in 9m52s
CI Pipeline / frontend-test (push) Successful in 24s
CI Pipeline / frontend-build (push) Successful in 30s
CI Pipeline / backend-lint (push) Successful in 9s
CI Pipeline / backend-test (pull_request) Successful in 9m59s
CI Pipeline / frontend-test (pull_request) Successful in 23s
CI Pipeline / frontend-build (pull_request) Successful in 31s
CI Pipeline / backend-lint (pull_request) Successful in 8s
CI Pipeline / quality-gate (push) Successful in 2s
CI Pipeline / quality-gate (pull_request) Successful in 2s
CI Pipeline / backend-test (push) Successful in 9m52s
CI Pipeline / frontend-test (push) Successful in 24s
CI Pipeline / frontend-build (push) Successful in 30s
CI Pipeline / backend-lint (push) Successful in 9s
CI Pipeline / backend-test (pull_request) Successful in 9m59s
CI Pipeline / frontend-test (pull_request) Successful in 23s
CI Pipeline / frontend-build (pull_request) Successful in 31s
CI Pipeline / backend-lint (pull_request) Successful in 8s
CI Pipeline / quality-gate (push) Successful in 2s
CI Pipeline / quality-gate (pull_request) Successful in 2s
The server-injected inline <style> was missing the three derived gradient variables (--sky-gradient, --sunset-gradient, --mixed-gradient) that components reference via var(). Without them, components fell back to SCSS build-time defaults on the first paint, causing a visible flash before ThemeService.apply() corrected the values. Additionally, migrate three component SCSS files from hardcoded SCSS color variables to CSS custom properties so the first paint uses the server-injected runtime colors: - login.component.scss: backgrounds, text colors, borders, focus rings - events.component.scss: event date card background gradient - about.component.scss: donation CTA background gradient
This commit is contained in:
1 parent
e78a725839
commit
bb45e8d6ae
4 files changed
+28
-10
No files matched your search
@@ -129,10 +129,19 @@ function buildConfigScript(config: StationConfig): string {
|
||||
return `<script>window.__STATION_CONFIG=${json};</script>`;
|
||||
}
|
||||
|
||||
/** Build a gradient CSS value from three color stops. */
|
||||
function gradient(from: string, mid: string, to: string): string {
|
||||
return `linear-gradient(135deg, ${from} 0%, ${mid} 40%, ${to} 100%)`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build inline CSS custom properties on `:root` so the first paint carries
|
||||
* the correct color scheme — eliminates the color flash that occurs when
|
||||
* ThemeService.apply() runs asynchronously after the API call.
|
||||
*
|
||||
* Includes both flat color properties AND derived gradient variables
|
||||
* (--sky-gradient, --sunset-gradient, --mixed-gradient) so components
|
||||
* using var() for backgrounds render correctly on the very first paint.
|
||||
*/
|
||||
function buildThemeStyle(config: StationConfig): string {
|
||||
const props: string[] = [];
|
||||
@@ -144,6 +153,15 @@ function buildThemeStyle(config: StationConfig): string {
|
||||
}
|
||||
}
|
||||
|
||||
// Derived gradients — mirror the same formulas ThemeService.apply() uses.
|
||||
// These must be injected server-side; otherwise components referencing
|
||||
// var(--sky-gradient) etc. fall back to their SCSS build-time defaults
|
||||
// on first paint, causing a visible color flash.
|
||||
const cp = (field: keyof StationConfig): string => (config as any)[field] || '';
|
||||
props.push(`--sky-gradient: ${gradient(cp('color_primary_dark'), cp('color_primary'), cp('color_primary_light'))}`);
|
||||
props.push(`--sunset-gradient: ${gradient(cp('color_accent_dark'), cp('color_accent'), cp('color_accent_light'))}`);
|
||||
props.push(`--mixed-gradient: linear-gradient(135deg, ${cp('color_primary_dark')} 0%, ${cp('color_primary')} 50%, ${cp('color_accent')} 100%)`);
|
||||
|
||||
if (props.length === 0) return '';
|
||||
|
||||
const css = `:root{${props.join(';')}}`;
|
||||
|
||||
Reference in new issue
Block a user