Fix #5808 auto dark theme detection flickering

This commit is contained in:
Simounet 2023-05-29 15:08:31 +02:00
parent ccd03f3151
commit b0a53a44ae
No known key found for this signature in database
GPG key ID: 77D3B7DC794EB770
3 changed files with 38 additions and 32 deletions

View file

@ -19,7 +19,7 @@ import './css/index.scss';
const mobileMaxWidth = 993;
function darkTheme() {
(function darkTheme() {
const rootEl = document.querySelector('html');
const themeDom = {
darkClass: 'dark-theme',
@ -87,7 +87,9 @@ function darkTheme() {
return true;
},
};
preferedColorScheme.init();
const addDarkThemeListeners = () => {
$(document).ready(() => {
const lightThemeButtons = document.querySelectorAll('.js-theme-toggle[data-theme="light"]');
[...lightThemeButtons].map((lightThemeButton) => {
lightThemeButton.addEventListener('click', (e) => {
@ -115,7 +117,12 @@ function darkTheme() {
});
return true;
});
}
});
};
preferedColorScheme.init();
addDarkThemeListeners();
}());
const stickyNav = () => {
const nav = $('.js-entry-nav-top');
@ -150,7 +157,6 @@ const articleScroll = () => {
$(document).ready(() => {
// sideNav
$('.button-collapse').sideNav();
darkTheme();
$('select').material_select();
$('.collapsible').collapsible({
accordion: false,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long