Skip to content

Commit

Permalink
viliusle#333: dynamically change theme based on OS preferences (disab…
Browse files Browse the repository at this point in the history
…led)
  • Loading branch information
viliusle committed Jan 8, 2023
1 parent 62ca359 commit ddf97ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/js/core/base-gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ class Base_gui_class {
theme_name = theme_cookie;
}
else {
theme_name = config.themes[0];
theme_name = this.Tools_settings.get_setting('theme');
}
}

Expand Down
15 changes: 14 additions & 1 deletion src/js/modules/tools/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Tools_settings_class {
*/
get_setting(key) {
var default_values = {
'theme': config.themes[0],
'theme': null,
'transparency': false,
'snap': true,
'guides': true,
Expand All @@ -129,6 +129,19 @@ class Tools_settings_class {
//not allowed
value = 1;
}
if(key == 'theme' && value == null) {
value = config.themes[0];
/*if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
&& config.themes.includes('dark')) {
//dark mode
value = 'dark';
}
else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches
&& config.themes.includes('light')) {
//light mode
value = 'light';
}*/
}

//finalize values
if(value === 1){
Expand Down

0 comments on commit ddf97ca

Please sign in to comment.