Merge pull request #5071 from Simounet/fix/5064-auto-prefered-color-scheme

This commit is contained in:
Jérémy Benoist 2021-02-22 18:35:02 +01:00 committed by GitHub
commit 4aa818866b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 4 deletions

View file

@ -63,9 +63,10 @@ function darkTheme() {
};
const preferedColorScheme = {
choose() {
if (this.isAvailable() && themeCookie.exists() === 0) {
const themeCookieExists = themeCookie.exists();
if (this.isAvailable() && !themeCookieExists) {
const isPreferedColorSchemeDark = window.matchMedia('(prefers-color-scheme: dark)').matches === true;
if (themeCookie.exists() === 0) {
if (!themeCookieExists) {
themeDom[isPreferedColorSchemeDark ? 'addClass' : 'removeClass'](rootEl);
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long