mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-10-15 09:57:12 +00:00
update theme to match new site
This commit is contained in:
Vendored
+655
-2281
File diff suppressed because it is too large
Load Diff
Vendored
+44
@@ -0,0 +1,44 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
(() => {
|
||||
'use strict';
|
||||
|
||||
const initialise = () => {
|
||||
const picker = document.getElementById('theme-picker');
|
||||
const preference = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
|
||||
if (picker instanceof HTMLSelectElement) {
|
||||
const applyTheme = () => {
|
||||
const dark = picker.value === 'dark'
|
||||
|| (picker.value === 'system' && preference.matches);
|
||||
document.documentElement.dataset.theme = dark ? 'dark' : 'light';
|
||||
document.querySelectorAll('meta[name="theme-color"]').forEach((meta) => {
|
||||
meta.setAttribute('content', dark ? '#111416' : '#ffffff');
|
||||
});
|
||||
};
|
||||
|
||||
// Follow the OS on every visit, including browser back/forward navigation.
|
||||
const resetTheme = () => {
|
||||
picker.value = 'system';
|
||||
applyTheme();
|
||||
};
|
||||
picker.addEventListener('change', applyTheme);
|
||||
preference.addEventListener('change', applyTheme);
|
||||
window.addEventListener('pageshow', resetTheme);
|
||||
resetTheme();
|
||||
}
|
||||
|
||||
const navigation = document.getElementById('docs-navigation');
|
||||
const compact = window.matchMedia('(max-width: 760px)');
|
||||
if (navigation instanceof HTMLDetailsElement) {
|
||||
const fitNavigation = () => { navigation.open = !compact.matches; };
|
||||
compact.addEventListener('change', fitNavigation);
|
||||
fitNavigation();
|
||||
}
|
||||
};
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', initialise, { once: true });
|
||||
} else {
|
||||
initialise();
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user