Vervangt rood/paars door tokens per variant en modus, voegt ModeToggle en icoon-knop VariantToggle toe, VariantRenderer met lazy E-chunk, dither-overgang (uit bij minder beweging), theme-init.js tegen themaflits en tests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
24 lines
846 B
JavaScript
24 lines
846 B
JavaScript
/*
|
|
* Runs (blocking, same origin, no inline script) before first paint so the page never flashes the
|
|
* wrong theme. Mirrors resolveInitialMode() in src/theme/tokens.ts (BR-U1-2, BR-U1-5):
|
|
* variant is always "b"; mode = valid stored mode, else the system preference.
|
|
*/
|
|
(function () {
|
|
var mode = 'light';
|
|
try {
|
|
var stored = window.localStorage.getItem('slp-software-mode');
|
|
if (stored === 'light' || stored === 'dark') {
|
|
mode = stored;
|
|
} else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
mode = 'dark';
|
|
}
|
|
} catch (e) {
|
|
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
mode = 'dark';
|
|
}
|
|
}
|
|
var root = document.documentElement;
|
|
root.setAttribute('data-variant', 'b');
|
|
root.setAttribute('data-mode', mode);
|
|
})();
|