fix whitescreen when switching pages.
This commit is contained in:
1 parent
2533fc5f2a
commit
34c55fccb9
3 files changed
+25
-6
No files matched your search
@@ -217,6 +217,8 @@ html {
|
|||||||
position: relative;
|
position: relative;
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
scroll-behavior: smooth;
|
scroll-behavior: smooth;
|
||||||
|
background-color: var(--bg-body);
|
||||||
|
transition: background-color 0.25s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
|||||||
@@ -140,6 +140,11 @@
|
|||||||
function apply(theme) {
|
function apply(theme) {
|
||||||
root.setAttribute('data-theme', theme);
|
root.setAttribute('data-theme', theme);
|
||||||
try { localStorage.setItem(STORAGE_KEY, theme); } catch (e) {}
|
try { localStorage.setItem(STORAGE_KEY, theme); } catch (e) {}
|
||||||
|
// Keep the inline html background/color-scheme in sync (set early
|
||||||
|
// in head.php to prevent a white flash between page loads).
|
||||||
|
var bg = window.BLOWDIT_THEME_BG || {};
|
||||||
|
if (bg[theme]) { root.style.backgroundColor = bg[theme]; }
|
||||||
|
root.style.colorScheme = (theme === 'light') ? 'light' : 'dark';
|
||||||
syncIcon(theme);
|
syncIcon(theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+18
-6
@@ -2,17 +2,29 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<meta name="generator" content="Bludit">
|
<meta name="generator" content="Bludit">
|
||||||
|
|
||||||
<!-- Set the colour theme as early as possible to avoid a flash -->
|
<!-- Set the colour theme as early as possible to avoid a white flash.
|
||||||
|
Sets data-theme AND paints the html background/color-scheme inline, so the
|
||||||
|
very first frame (before style.css loads) already uses the theme colour. -->
|
||||||
<script>
|
<script>
|
||||||
|
window.BLOWDIT_THEME_BG = {
|
||||||
|
light: '#ffffff',
|
||||||
|
dark: '#171717',
|
||||||
|
nord: '#2e3440',
|
||||||
|
dracula: '#282a36',
|
||||||
|
catppuccin: '#1e1e2e'
|
||||||
|
};
|
||||||
(function () {
|
(function () {
|
||||||
try {
|
try {
|
||||||
|
var bg = window.BLOWDIT_THEME_BG;
|
||||||
var stored = localStorage.getItem('blowdit-theme');
|
var stored = localStorage.getItem('blowdit-theme');
|
||||||
var prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
if (!bg[stored]) {
|
||||||
var theme = stored || (prefersDark ? 'dark' : 'light');
|
stored = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
||||||
document.documentElement.setAttribute('data-theme', theme);
|
|
||||||
} catch (e) {
|
|
||||||
document.documentElement.setAttribute('data-theme', 'light');
|
|
||||||
}
|
}
|
||||||
|
var root = document.documentElement;
|
||||||
|
root.setAttribute('data-theme', stored);
|
||||||
|
root.style.colorScheme = (stored === 'light') ? 'light' : 'dark';
|
||||||
|
root.style.backgroundColor = bg[stored];
|
||||||
|
} catch (e) {}
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user