From fb35bd107cd9412f39bfa497544353afe4c9e5aa Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Fri, 21 May 2021 15:48:50 +0300 Subject: [PATCH] [themes] use system color's scheme by default --- apps/common/main/lib/util/htmlutils.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/common/main/lib/util/htmlutils.js b/apps/common/main/lib/util/htmlutils.js index 37bff2dbf7..7d5b0161b0 100644 --- a/apps/common/main/lib/util/htmlutils.js +++ b/apps/common/main/lib/util/htmlutils.js @@ -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); }