You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2025/06/24 20:49:53 UTC
(superset) 03/03: adjust the ThemeController
This is an automated email from the ASF dual-hosted git repository.
maximebeauchemin pushed a commit to branch theme_dark
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 7ace5f17374af125d941eabb9b81c4fa1acb6cfc
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Tue Jun 24 13:49:26 2025 -0700
adjust the ThemeController
---
superset-frontend/src/theme/ThemeController.tsx | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/superset-frontend/src/theme/ThemeController.tsx b/superset-frontend/src/theme/ThemeController.tsx
index fce09ff6bd..3fbcfff29d 100644
--- a/superset-frontend/src/theme/ThemeController.tsx
+++ b/superset-frontend/src/theme/ThemeController.tsx
@@ -66,7 +66,7 @@ export class ThemeController {
private mediaQuery: MediaQueryList;
- constructor(options: ThemeControllerOptions = {}) {
+ constructor(options: ThemeControllerOptions = { themeObject }) {
this.storage = options.storage || new LocalStorageAdapter();
this.storageKey = options.storageKey || 'superset-theme';
this.modeStorageKey = options.modeStorageKey || `${this.storageKey}-mode`;
@@ -152,6 +152,10 @@ export class ThemeController {
return this.currentMode;
}
+ /**
+ * Sets new theme customizations (e.g., from a JSON editor).
+ * This method updates the theme's appearance but preserves the current mode.
+ */
public setTheme(newCustomizations: AnyThemeConfig): void {
if (!this.canUpdateTheme()) {
throw new Error('User does not have permission to update the theme');
@@ -170,6 +174,10 @@ export class ThemeController {
this.notifyListeners();
}
+ /**
+ * Changes the theme mode (light, dark, or system).
+ * This is for the mode switch.
+ */
public changeThemeMode(newMode: ThemeMode): void {
if (!this.canUpdateMode()) {
throw new Error('User does not have permission to update the theme mode');
@@ -208,6 +216,9 @@ export class ThemeController {
}
};
+ /**
+ * Centralized method to apply the current customizations and mode.
+ */
private applyTheme(): void {
const newConfig = { ...this.customizations };