Add CC dark theme option
This commit adds an option to enable a dark theme in the Community
Console. It can be enabled manually with a switch which is injected in
the CC or automatically by syncing it with the OS dark mode setting.
Change-Id: I7506e80a409c5b0190d942c9de88354b6c0cce10
diff --git a/src/options.js b/src/options.js
index 47cecf6..4d37a19 100644
--- a/src/options.js
+++ b/src/options.js
@@ -24,6 +24,14 @@
options[opt] = document.getElementById(opt).value || 12;
break;
+ case 'ccdarktheme_mode':
+ options[opt] = document.getElementById(opt).value || 'switch';
+ break;
+
+ // This option is controlled directly in the Community Console.
+ case 'ccdarktheme_switch_enabled':
+ break;
+
default:
console.warn('Unrecognized option: ' + opt);
break;
@@ -79,6 +87,28 @@
.appendChild(input);
break;
+ case 'ccdarktheme_mode':
+ var select = document.createElement('select');
+ select.id = 'ccdarktheme_mode';
+
+ const modes = ['switch', 'system'];
+ for (const mode of modes) {
+ var modeOption = document.createElement('option');
+ modeOption.value = mode;
+ modeOption.textContent =
+ chrome.i18n.getMessage('options_ccdarktheme_mode_' + mode);
+ if (items.ccdarktheme_mode == mode) modeOption.selected = true;
+ select.appendChild(modeOption);
+ }
+
+ document.getElementById('ccdarktheme_mode--container')
+ .appendChild(select);
+ break;
+
+ // This option is controlled directly in the Community Console.
+ case 'ccdarktheme_switch_enabled':
+ break;
+
default:
console.warn('Unrecognized option: ' + opt);
break;