Feat: Support setting custom css variables through embed API. (#8169)
* Add booker border specific custom variables * Support configuring cssVars through embed API * Update apps/web/pages/booking/[uid].tsx Co-authored-by: sean-brydon <[email protected]> --------- Co-authored-by: sean-brydon <[email protected]>
This commit is contained in:
1 parent
17f48614ff
commit
0e22e92cab
11 files changed
+123
-61
No files matched your search
@@ -5,10 +5,14 @@ import { useState, useEffect } from "react";
|
||||
import type { Message } from "./embed";
|
||||
import { sdkActionManager } from "./sdk-event";
|
||||
|
||||
type Theme = "dark" | "light";
|
||||
|
||||
export type UiConfig = {
|
||||
hideEventTypeDetails?: boolean;
|
||||
theme?: "dark" | "light" | "auto";
|
||||
theme?: Theme | "auto";
|
||||
styles?: EmbedStyles & EmbedNonStylesConfig;
|
||||
//TODO: Extract from tailwind the list of all custom variables and support them in auto-completion as well as runtime validation. Followup with listing all variables in Embed Snippet Generator UI.
|
||||
cssVarsPerTheme?: Record<Theme, Record<string, string>>;
|
||||
};
|
||||
|
||||
type SetStyles = React.Dispatch<React.SetStateAction<EmbedStyles>>;
|
||||
@@ -279,6 +283,12 @@ const methods = {
|
||||
log("Method: ui called", uiConfig);
|
||||
const stylesConfig = uiConfig.styles;
|
||||
|
||||
if (stylesConfig) {
|
||||
console.warn(
|
||||
"Cal.com Embed: `styles` prop is deprecated. Use `cssVarsPerTheme` instead to achieve the same effect"
|
||||
);
|
||||
}
|
||||
|
||||
// body can't be styled using React state hook as it is generated by _document.tsx which doesn't support hooks.
|
||||
if (stylesConfig?.body?.background) {
|
||||
document.body.style.background = stylesConfig.body.background as string;
|
||||
|
||||
Reference in new issue
Block a user