From ebd911201df0e6fce95b408935fb35580851170e Mon Sep 17 00:00:00 2001
From: Kuuuube <61125188+Kuuuube@users.noreply.github.com>
Date: Tue, 18 Jun 2024 14:00:52 -0400
Subject: Add full dark mode support (#1079)
* Add full dark mode support
* Fix welcome, permissions, and quick start scrollbars
* Fix action popup dark mode on mobile
* Add theme to info page
* Reduce flashbang
* Move position of settingsDisplayController to not break things
* Fix dictionary import drag drop theming
* Make dark shadow color less bad
* Prepare themeController to avoid not being able to set browser theme
---
ext/js/pages/settings/settings-display-controller.js | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
(limited to 'ext/js/pages/settings/settings-display-controller.js')
diff --git a/ext/js/pages/settings/settings-display-controller.js b/ext/js/pages/settings/settings-display-controller.js
index f732f1ef..49f7192c 100644
--- a/ext/js/pages/settings/settings-display-controller.js
+++ b/ext/js/pages/settings/settings-display-controller.js
@@ -16,6 +16,7 @@
* along with this program. If not, see .
*/
+import {ThemeController} from '../../app/theme-controller.js';
import {isInputElementFocused} from '../../dom/document-util.js';
import {PopupMenu} from '../../dom/popup-menu.js';
import {querySelectorNotNull} from '../../dom/query-selector.js';
@@ -39,10 +40,16 @@ export class SettingsDisplayController {
this._onMoreToggleClickBind = this._onMoreToggleClick.bind(this);
/** @type {(event: MouseEvent) => void} */
this._onMenuButtonClickBind = this._onMenuButtonClick.bind(this);
+ /** @type {ThemeController} */
+ this._themeController = new ThemeController(document.documentElement);
}
/** */
prepare() {
+ this._themeController.siteTheme = 'light';
+ this._themeController.prepare();
+ void this._updateTheme();
+
const onFabButtonClick = this._onFabButtonClick.bind(this);
for (const fabButton of /** @type {NodeListOf} */ (document.querySelectorAll('.fab-button'))) {
fabButton.addEventListener('click', onFabButtonClick, false);
@@ -84,6 +91,18 @@ export class SettingsDisplayController {
window.addEventListener('keydown', this._onKeyDown.bind(this), false);
window.addEventListener('popstate', this._onPopState.bind(this), false);
this._updateScrollTarget();
+
+ const themeDropdown = document.querySelector('[data-setting="general.popupTheme"]');
+ if (themeDropdown) {
+ themeDropdown.addEventListener('change', this._updateTheme.bind(this), false);
+ }
+ }
+
+ /** */
+ async _updateTheme() {
+ const options = await this._settingsController.getOptions();
+ this._themeController.theme = options.general.popupTheme;
+ this._themeController.updateTheme();
}
// Private
--
cgit v1.2.3