Improve announcement rendering and theme assets

This commit is contained in:
2026-08-26 01:08:59 +01:00
parent a7d867dd6f
commit 9097d45d6a
16 changed files with 97 additions and 32 deletions
+17 -16
View File
@@ -2,25 +2,26 @@
(function () {
var storageKey = 'lte-theme';
var theme = 'dark';
function getPreferredTheme() {
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
return 'dark';
}
return 'light';
}
var root = document.documentElement;
var authoredTheme = root.getAttribute('data-bs-theme');
var theme = authoredTheme === 'light' || authoredTheme === 'dark' ? authoredTheme : 'dark';
var storedTheme = null;
try {
var storedTheme = window.localStorage.getItem(storageKey);
if (storedTheme === 'dark' || storedTheme === 'light' || storedTheme === 'auto') {
theme = storedTheme === 'auto' ? getPreferredTheme() : storedTheme;
}
storedTheme = window.localStorage.getItem(storageKey);
} catch (error) {
theme = 'dark';
storedTheme = null;
}
document.documentElement.dataset.bsTheme = theme;
document.documentElement.style.colorScheme = theme;
if (storedTheme === 'light' || storedTheme === 'dark') {
theme = storedTheme;
} else if (storedTheme === 'auto' || (authoredTheme !== 'light' && authoredTheme !== 'dark')) {
theme = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}
root.setAttribute('data-bs-theme', theme);
root.style.colorScheme = theme;
if (theme !== authoredTheme) {
root.setAttribute('data-lte-theme-resolved', '');
}
}());