diff --git a/frontend/src/App/App.jsx b/frontend/src/App/App.jsx
index 20f54e3f54..e7a5b21f11 100644
--- a/frontend/src/App/App.jsx
+++ b/frontend/src/App/App.jsx
@@ -113,6 +113,7 @@ class AppComponent extends React.Component {
const featureAccess = await licenseService.getFeatureAccess();
const isBasicPlan = !featureAccess?.licenseStatus?.isLicenseValid || featureAccess?.licenseStatus?.isExpired;
this.setState({ showBanner: isBasicPlan });
+ this.updateColorScheme();
}
// check if its getting routed from editor
checkPreviousRoute = (route) => {
@@ -122,7 +123,7 @@ class AppComponent extends React.Component {
return false;
};
- componentDidUpdate(prevProps) {
+ componentDidUpdate(prevProps, prevState) {
// Check if the current location is the dashboard (homepage)
if (
this.props.location.pathname === `/${getWorkspaceIdOrSlugFromURL()}` &&
@@ -135,18 +136,24 @@ class AppComponent extends React.Component {
}
// Update margin when showBanner changes
this.updateMargin();
+ // Update color scheme if darkMode changed
+ if (prevState.darkMode !== this.state.darkMode) {
+ this.updateColorScheme();
+ }
}
switchDarkMode = (newMode) => {
this.setState({ darkMode: newMode });
this.props.updateIsTJDarkMode(newMode);
localStorage.setItem('darkMode', newMode);
+ this.updateColorScheme(newMode);
};
isEditorOrViewerFromPath = () => {
const pathname = this.props.location.pathname;
if (pathname.includes('/apps/')) {
return 'editor';
- } else if (pathname.includes('/applications/') || pathname.includes('/embed-apps/')) {
+ }
+ if (pathname.includes('/applications/') || pathname.includes('/embed-apps/')) {
return 'viewer';
}
return '';
@@ -157,6 +164,14 @@ class AppComponent extends React.Component {
isExistingPlanUser = (date) => {
return new Date(date) < new Date('2025-04-24'); //show banner if user created before 2 april (24 for testing)
};
+ updateColorScheme = (darkModeValue) => {
+ const isDark = darkModeValue !== undefined ? darkModeValue : this.state.darkMode;
+ if (isDark) {
+ document.documentElement.style.setProperty('color-scheme', 'dark');
+ } else {
+ document.documentElement.style.removeProperty('color-scheme');
+ }
+ };
render() {
const { updateAvailable, darkMode, isEditorOrViewer, showBanner } = this.state;
const mergedProps = {
@@ -290,22 +305,19 @@ class AppComponent extends React.Component {
}
/>
)}
-
+
{pathname}
{routesWithTags(pathname) && ( @@ -117,7 +117,7 @@ function Header({