From 933cc739bd9fb9ad5c8ba96cb221df141a844d09 Mon Sep 17 00:00:00 2001 From: Hariom Balhara Date: Sat, 20 May 2023 01:40:19 +0530 Subject: [PATCH] Add config support in floatingButton api (#8986) Co-authored-by: alannnc --- packages/embeds/embed-core/playground.ts | 12 +++++++++++- .../embed-core/src/FloatingButton/FloatingButton.ts | 1 + packages/embeds/embed-core/src/embed.ts | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/embeds/embed-core/playground.ts b/packages/embeds/embed-core/playground.ts index 4295396420..c490f25967 100644 --- a/packages/embeds/embed-core/playground.ts +++ b/packages/embeds/embed-core/playground.ts @@ -333,6 +333,16 @@ Cal("init", "routingFormDark", { if (only === "all" || only == "ns:floatingButton") { Cal.ns.floatingButton("floatingButton", { - calLink: "pro", + calLink: "pro/30min", + config: { + iframeAttrs: { + id: "floatingtest", + }, + name: "John", + email: "johndoe@gmail.com", + notes: "Test Meeting", + guests: ["janedoe@example.com", "test@example.com"], + theme: "dark", + }, }); } diff --git a/packages/embeds/embed-core/src/FloatingButton/FloatingButton.ts b/packages/embeds/embed-core/src/FloatingButton/FloatingButton.ts index 64dcb55f2a..b5e8168a10 100644 --- a/packages/embeds/embed-core/src/FloatingButton/FloatingButton.ts +++ b/packages/embeds/embed-core/src/FloatingButton/FloatingButton.ts @@ -4,6 +4,7 @@ type ModalTargetDatasetProps = { calLink: string; calNamespace: string; calOrigin: string; + calConfig: string; }; type CamelCase = T extends `${infer U}${infer V}` ? `${Uppercase}${V}` : T; diff --git a/packages/embeds/embed-core/src/embed.ts b/packages/embeds/embed-core/src/embed.ts index 87bf77f703..28dcd02f40 100644 --- a/packages/embeds/embed-core/src/embed.ts +++ b/packages/embeds/embed-core/src/embed.ts @@ -435,6 +435,7 @@ class CalApi { buttonColor = "rgb(0, 0, 0)", buttonTextColor = "rgb(255, 255, 255)", calOrigin, + config, }: { calLink: string; buttonText?: string; @@ -444,6 +445,7 @@ class CalApi { buttonColor?: string; buttonTextColor?: string; calOrigin?: string; + config?: PrefillAndIframeAttrsConfig; }) { // validate(arguments[0], { // required: true, @@ -466,6 +468,10 @@ class CalApi { el.dataset.calLink = calLink; el.dataset.calNamespace = this.cal.namespace; el.dataset.calOrigin = calOrigin ?? ""; + if (config) { + el.dataset.calConfig = JSON.stringify(config); + } + if (attributes?.id) { el.id = attributes.id; }