diff --git a/packages/embeds/embed-core/embed-iframe-init.ts b/packages/embeds/embed-core/embed-iframe-init.ts index e5b0d3d89d..e46f49f0a3 100644 --- a/packages/embeds/embed-core/embed-iframe-init.ts +++ b/packages/embeds/embed-core/embed-iframe-init.ts @@ -39,17 +39,23 @@ export default function EmbedInitIframe() { for (const [themeName, cssVars] of Object.entries(cssVarsPerTheme)) { cssVarsStyle.push(`.${themeName} {`); for (const [cssVarName, value] of Object.entries(cssVars)) { - cssVarsStyle.push(`--${cssVarName}: ${value};`); + // The styles are applied inline on .light/.dark elements by the codebase(useCalcomTheme). So, to make sure embed styles take precedence, we add !important + cssVarsStyle.push(`--${cssVarName}: ${value} !important;`); } cssVarsStyle.push(`}`); } } + + const existingStyleEl = document.head.querySelector("#embed-css-vars") as HTMLStyleElement; + if (existingStyleEl) { + console.warn("Existing embed CSS Vars are being reset"); + existingStyleEl.innerText = cssVarsStyle.join("\n"); + return; + } + const style = document.createElement("style"); style.id = "embed-css-vars"; style.innerText = cssVarsStyle.join("\n"); - if (document.head.querySelector("#embed-css-vars")) { - return; - } document.head.appendChild(style); }; } diff --git a/packages/embeds/embed-core/index.html b/packages/embeds/embed-core/index.html index 67559d77a5..f674a8f8c2 100644 --- a/packages/embeds/embed-core/index.html +++ b/packages/embeds/embed-core/index.html @@ -180,6 +180,10 @@ onclick="(function () {Cal.ns.second('ui', {cssVarsPerTheme:{light:{'cal-border-booker':'green', 'cal-border-booker-width':'20px'},dark:{'cal-border-booker':'red', 'cal-border-booker-width':'5px'}}})})()"> Change booker border for dark and light themes +