From 11081cb5d82783d0edbad25ad959c41b8e444631 Mon Sep 17 00:00:00 2001 From: Hariom Balhara Date: Tue, 18 Jul 2023 22:16:35 +0530 Subject: [PATCH] fix: Embed - Non transparent background when color-scheme of embedding document and cal.com iframe don't match (#10033) ## What does this PR do? Fixes #10032 Before: https://www.loom.com/share/1890e4eebf41426aaf66d8b4909d0765 After: https://www.loom.com/share/8b00c41587f2467ab05ef48e4ed523ef ## Type of change - Bug fix (non-breaking change which fixes an issue) ## How should this be tested? - See loom ## Mandatory Tasks - [x] Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected. ## Checklist - I haven't added tests that prove my fix is effective or that my feature works --- apps/web/pages/_document.tsx | 7 +- packages/embeds/embed-core/index.html | 3 + packages/embeds/embed-core/playground.ts | 20 ++++ .../embeds/embed-core/src/embed-iframe.ts | 16 ++- packages/embeds/embed-core/src/embed.ts | 104 +++++++++++++++--- 5 files changed, 132 insertions(+), 18 deletions(-) diff --git a/apps/web/pages/_document.tsx b/apps/web/pages/_document.tsx index 42f5d49216..0d2ebc7389 100644 --- a/apps/web/pages/_document.tsx +++ b/apps/web/pages/_document.tsx @@ -28,17 +28,18 @@ class MyDocument extends Document { // Use a dummy URL as default so that URL parsing works for relative URLs as well. We care about searchParams and pathname only const parsedUrl = new URL(asPath, "https://dummyurl"); const isEmbed = parsedUrl.pathname.endsWith("/embed") || parsedUrl.searchParams.get("embedType") !== null; + const embedColorScheme = parsedUrl.searchParams.get("ui.color-scheme"); const initialProps = await Document.getInitialProps(ctx); - return { isEmbed, nonce, ...initialProps }; + return { isEmbed, embedColorScheme, nonce, ...initialProps }; } render() { const { locale } = this.props.__NEXT_DATA__; - const { isEmbed } = this.props; + const { isEmbed, embedColorScheme } = this.props; const nonceParsed = z.string().safeParse(this.props.nonce); const nonce = nonceParsed.success ? nonceParsed.data : ""; return ( - + diff --git a/packages/embeds/embed-core/index.html b/packages/embeds/embed-core/index.html index 3ea6a85498..d62d51ee2a 100644 --- a/packages/embeds/embed-core/index.html +++ b/packages/embeds/embed-core/index.html @@ -82,10 +82,13 @@ + With Dark Color Scheme for the Page Non responsive version of this page here Go to Pre-render test page only + +