[themes] use system color's scheme by default

This commit is contained in:
Maxim Kadushkin 2021-05-21 15:48:50 +03:00
parent 790685b93c
commit fb35bd107c

View file

@ -45,6 +45,12 @@ if ( !!params.uitheme && !localStorage.getItem("ui-theme") ) {
}
var ui_theme_name = localStorage.getItem("ui-theme");
if ( !ui_theme_name ) {
if ( window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ) {
ui_theme_name = 'theme-dark';
localStorage.setItem("ui-theme", ui_theme_name);
}
}
if ( !!ui_theme_name ) {
document.body.classList.add(ui_theme_name);
}