Prevent flash of wrong theme on startup (web) (#9577)

* prevent flash of wrong theme on startup

* move bg color to #root

* Update and use existing system

* Darken slightly, better contrast

---------

Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
Samuel Newman
2026-01-15 04:41:59 +02:00
committed by GitHub
parent 8f82ad66df
commit 10aa46aa9e
4 changed files with 88 additions and 60 deletions
+1
View File
@@ -51,6 +51,7 @@ function updateDocument(theme: ThemeName) {
html.classList.add(`theme--${theme}`)
// set color to 'theme-color' meta tag
meta?.setAttribute('content', getBackgroundColor(theme))
window.localStorage.setItem('ALF_THEME', theme)
}
}
-34
View File
@@ -11,40 +11,6 @@
*
* HTML & BODY STYLES IN `web/index.html` and `bskyweb/templates/base.html`
*/
:root {
--text: black;
--background: white;
--backgroundLight: #f9fafb;
}
@media (prefers-color-scheme: dark) {
:root {
color-scheme: dark;
--text: white;
--background: black;
--backgroundLight: #111822;
}
}
html.theme--light {
--text: black;
--background: white;
--backgroundLight: #f9fafb;
background-color: white;
}
html.theme--dark {
color-scheme: dark;
background-color: black;
--text: white;
--background: black;
--backgroundLight: #111822;
}
html.theme--dim {
color-scheme: dark;
background-color: #151d28;
--text: white;
--background: #151d28;
--backgroundLight: #1c2736;
}
/* Buttons and inputs have a font set by UA, so we'll have to reset that */
button,