Skip to content

Commit

Permalink
Add config support in floatingButton api (#8986)
Browse files Browse the repository at this point in the history
Co-authored-by: alannnc <alannnc@gmail.com>
  • Loading branch information
hariombalhara and alannnc committed May 19, 2023
1 parent c7c75ff commit 933cc73
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/embeds/embed-core/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ type ModalTargetDatasetProps = {
calLink: string;
calNamespace: string;
calOrigin: string;
calConfig: string;
};

type CamelCase<T extends string> = T extends `${infer U}${infer V}` ? `${Uppercase<U>}${V}` : T;
Expand Down
6 changes: 6 additions & 0 deletions packages/embeds/embed-core/src/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ class CalApi {
buttonColor = "rgb(0, 0, 0)",
buttonTextColor = "rgb(255, 255, 255)",
calOrigin,
config,
}: {
calLink: string;
buttonText?: string;
Expand All @@ -444,6 +445,7 @@ class CalApi {
buttonColor?: string;
buttonTextColor?: string;
calOrigin?: string;
config?: PrefillAndIframeAttrsConfig;
}) {
// validate(arguments[0], {
// required: true,
Expand All @@ -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;
}
Expand Down

0 comments on commit 933cc73

Please sign in to comment.