From acf3a7c54e21355335b0a54bb2ac66fea951915e Mon Sep 17 00:00:00 2001 From: amrit Date: Tue, 22 Apr 2025 10:21:10 +0530 Subject: [PATCH] feat: add "React (Atom)" to embed generator and rename rest (#20618) * fix: trigger lingo.dev by removing duplicate value * feat: add support for React Atom embed options * fix: update locator for React code tab in embed code generator E2E tests * fix: update embed tab names to clarify iframe usage * fix failing test * fix: indentation and installation commands for atoms * fix: add note about iframe usage in Preview tab * refactor: replace Cal component with BookerEmbed in EmbedCodes * fix: Add EmbedConfig type import in Embed.tsx - Added missing EmbedConfig type to the existing types import - Resolves TypeScript error "Cannot find name 'EmbedConfig'" * fix: update BookerEmbed usage in EmbedCodes component * fix: enhance BookerEmbed implementation and update installation instructions in EmbedTabs * fix: improve comments in EmbedCodes for clarity on layout options and styling references * fix: streamline BookerEmbed usage in EmbedCodes with improved class handling and layout options * fix: embed type selection * fix: update layout selection in EmbedCodes to use dynamic configuration * fix: update embed configuration to use theme instead of layout * fix: conditionally render embed options based on if we are selecting atom * fix: use simple props instead of embed specific logic to fix the active embed bug * Fix double tabs activeness * Revert isCurrent change --------- Co-authored-by: Hariom Balhara --- packages/features/embed/Embed.tsx | 226 +++++++++++---------- packages/features/embed/lib/EmbedCodes.tsx | 206 +++++++++++++++---- packages/features/embed/lib/EmbedTabs.tsx | 71 ++++++- packages/features/embed/types/index.d.ts | 2 +- 4 files changed, 349 insertions(+), 156 deletions(-) diff --git a/packages/features/embed/Embed.tsx b/packages/features/embed/Embed.tsx index 8988c348c4..7c875d6e27 100644 --- a/packages/features/embed/Embed.tsx +++ b/packages/features/embed/Embed.tsx @@ -37,12 +37,13 @@ import { HorizontalTabs } from "@calcom/ui/components/navigation"; import { showToast } from "@calcom/ui/components/toast"; import { useBookerTime } from "../bookings/Booker/components/hooks/useBookerTime"; +import { EmbedTabName } from "./lib/EmbedTabs"; import { buildCssVarsPerTheme } from "./lib/buildCssVarsPerTheme"; import { EmbedTheme } from "./lib/constants"; import { getDimension } from "./lib/getDimension"; import { useEmbedDialogCtx } from "./lib/hooks/useEmbedDialogCtx"; import { useEmbedParams } from "./lib/hooks/useEmbedParams"; -import type { EmbedTabs, EmbedType, EmbedTypes, PreviewState } from "./types"; +import type { EmbedTabs, EmbedType, EmbedTypes, PreviewState, EmbedConfig } from "./types"; type EventType = RouterOutputs["viewer"]["eventTypes"]["get"]["eventType"] | undefined; type EmbedDialogProps = { @@ -932,55 +933,58 @@ const EmbedTypeCodeAndPreviewDialogContent = ({ open={isEmbedCustomizationOpen} onOpenChange={() => setIsEmbedCustomizationOpen((val) => !val)}> -
- {/*TODO: Add Auto/Fixed toggle from Figma */} -
Window sizing
-
-
+ {/* Conditionally render Window Sizing only if inline embed AND NOT React Atom */} + {embedType === "inline" && embedParams.embedTabName !== EmbedTabName.ATOM_REACT && ( +
+ {/*TODO: Add Auto/Fixed toggle from Figma */} +
Window sizing
+
+
+ { + setPreviewState((previewState) => { + const width = e.target.value || "100%"; + + return { + ...previewState, + inline: { + ...previewState.inline, + width, + }, + }; + }); + }} + addOnLeading={<>W} + /> +
+ { - setPreviewState((previewState) => { - const width = e.target.value || "100%"; + const height = e.target.value || "100%"; + setPreviewState((previewState) => { return { ...previewState, inline: { ...previewState.inline, - width, + height, }, }; }); }} - addOnLeading={<>W} + addOnLeading={<>H} />
- - { - const height = e.target.value || "100%"; - - setPreviewState((previewState) => { - return { - ...previewState, - inline: { - ...previewState.inline, - height, - }, - }; - }); - }} - addOnLeading={<>H} - />
-
+ )}
setIsBookingCustomizationOpen((val) => !val)}>
- - {!eventTypeHideOptionDisabled ? ( + // Keep updating top-level theme for preview iframe + theme: option.value, + }; + }); + }} + options={ThemeOptions} + /> + + )} + {/* Conditionally render Hide Details Switch only if NOT Atom embed AND not disabled by prop */} + {!eventTypeHideOptionDisabled && + embedParams.embedTabName !== EmbedTabName.ATOM_REACT ? (
{t("hide_eventtype_details")}
) : null} - {[ - { name: "brandColor", title: "light_brand_color" }, - { name: "darkBrandColor", title: "dark_brand_color" }, - // { name: "lightColor", title: "Light Color" }, - // { name: "lighterColor", title: "Lighter Color" }, - // { name: "lightestColor", title: "Lightest Color" }, - // { name: "highlightColor", title: "Highlight Color" }, - // { name: "medianColor", title: "Median Color" }, - ].map((palette) => ( - - ))} + {/* Conditionally render Brand Colors only if NOT React Atom */} + {embedParams.embedTabName !== EmbedTabName.ATOM_REACT && + [ + { name: "brandColor", title: "light_brand_color" }, + { name: "darkBrandColor", title: "dark_brand_color" }, + // { name: "lightColor", title: "Light Color" }, + // { name: "lighterColor", title: "Lighter Color" }, + // { name: "lightestColor", title: "Lightest Color" }, + // { name: "highlightColor", title: "Highlight Color" }, + // { name: "medianColor", title: "Median Color" }, + ].map((palette) => ( + + ))}