From 555fcc21f2dba60fa5dae89899a7a7c9ec488a72 Mon Sep 17 00:00:00 2001 From: Hariom Balhara Date: Wed, 12 Apr 2023 16:46:59 +0530 Subject: [PATCH] Revert color-scheme for embed (#8229) --- apps/web/lib/app-providers.tsx | 24 +++++++++++++++++------- apps/web/styles/globals.css | 2 -- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/apps/web/lib/app-providers.tsx b/apps/web/lib/app-providers.tsx index 1df9e377b9..b793123e7e 100644 --- a/apps/web/lib/app-providers.tsx +++ b/apps/web/lib/app-providers.tsx @@ -84,14 +84,14 @@ const CalcomThemeProvider = ( // One such example is our Embeds Demo and Testing page at http://localhost:3100 // Having `getEmbedNamespace` defined on window before react initializes the app, ensures that embedNamespace is available on the first mount and can be used as part of storageKey const embedNamespace = typeof window !== "undefined" ? window.getEmbedNamespace() : null; + const isEmbedMode = typeof embedNamespace === "string"; // If embedNamespace is not defined, we use the default storageKey -> The default storage key changs based on if we force light mode or not // This is done to ensure that the default theme is light when we force light mode and as soon as you navigate to a page that is dark we dont need a hard refresh to change - const storageKey = - typeof embedNamespace === "string" - ? `embed-theme-${embedNamespace}` - : !isThemeSupported - ? "cal-light" - : "theme"; + const storageKey = isEmbedMode + ? `embed-theme-${embedNamespace}` + : !isThemeSupported + ? "cal-light" + : "theme"; return ( + {/* Embed Mode can be detected reliably only on client side here as there can be static generated pages as well which can't determine if it's embed mode at backend */} + {/* color-scheme makes background:transparent not work in iframe which is required by embed. */} + {typeof window !== "undefined" && !isEmbedMode && ( + + )} {props.children} ); @@ -121,7 +132,6 @@ const AppProviders = (props: AppPropsWithChildren) => { - {/* color-scheme makes background:transparent not work which is required by embed. We need to ensure next-theme adds color-scheme to `body` instead of `html`(https://github.com/pacocoursey/next-themes/blob/main/src/index.tsx#L74). Once that's done we can enable color-scheme support */} diff --git a/apps/web/styles/globals.css b/apps/web/styles/globals.css index 04558d4ac1..7290c1e523 100644 --- a/apps/web/styles/globals.css +++ b/apps/web/styles/globals.css @@ -44,8 +44,6 @@ --cal-brand-text: white; } .dark { - color-scheme: dark; - /* background */ --cal-bg-emphasis: #2b2b2b;