Embed Improvements: Add auto-scroll support back, reduce CLS, remove loader for Routing Form embed (#4819)

* Add back auto-scroll fix with proper check of visibilith

* Do improvement in CLS and dont show "Loading" text

* Improve experience with routing forms embed

Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
Hariom BalharaandAlex van Andel authored and GitHub committed 2022-10-14 10:10:54 +00:00
1 parent 88cad2e15f
commit 8583d9b2e6
7 files changed
+63 -22

No files matched your search

+11
View File
@@ -4,6 +4,17 @@ Embed Cal Link as a React Component
To know how to use it, follow the steps at <https://developer.cal.com/embed/install-with-react>
## Development
Following command starts a hot reloading server
`yarn dev`
If you are working with embed on website, don't forget to do `yarn build` after every change.
## Running Tests
Runs tests and updates the snapshots. Right now we don't care about snapshots
`yarn embed-tests-quick --update-snapshots`
TODO
- Playwright tests.
+11 -8
View File
@@ -6,12 +6,16 @@ import useEmbed from "./useEmbed";
type CalProps = {
calOrigin?: string;
calLink: string;
initConfig?: {
debug?: boolean;
uiDebug?: boolean;
};
config?: any;
embedJsUrl?: string;
} & React.HTMLAttributes<HTMLDivElement>;
const Cal = function Cal(props: CalProps) {
const { calLink, calOrigin, config, embedJsUrl, ...restProps } = props;
const { calLink, calOrigin, config, initConfig = {}, embedJsUrl, ...restProps } = props;
if (!calLink) {
throw new Error("calLink is required");
}
@@ -24,20 +28,19 @@ const Cal = function Cal(props: CalProps) {
}
initializedRef.current = true;
const element = ref.current;
let initConfig = {};
if (calOrigin) {
(initConfig as any).origin = calOrigin;
}
Cal("init", initConfig);
Cal("init", {
...initConfig,
origin: calOrigin,
});
Cal("inline", {
elementOrSelector: element,
calLink,
config,
});
}, [Cal, calLink, config, calOrigin]);
}, [Cal, calLink, config, calOrigin, initConfig]);
if (!Cal) {
return <div {...restProps}>Loading {calLink} </div>;
return null;
}
return <div ref={ref} {...restProps} />;
+3 -2
View File
@@ -45,9 +45,10 @@ function App() {
notes: "Test Meeting",
guests: ["[email protected]"],
theme: "dark",
}}></Cal>
}}
/>
<button data-cal-link="pro">Popup</button>
</>
);
}
ReactDom.render(<App></App>, document.getElementById("root"));
ReactDom.render(<App />, document.getElementById("root"));