feat: Embed - Show skeleton loader when pageType is provided (#20646)

* mvp done

* wip

* fix ts errors and other code improvements

* fix ts errors

* ensure mobile layout support

* Make skeleton responsive on screen resize

* refactor

* Add test for EmbedElement

* make skeleton closer to pixel perfect

* Address PR feedback

* Remove PR_TODO

---------

Co-authored-by: Benny Joo <[email protected]>
Co-authored-by: amrit <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-04-16 13:40:51 +00:00
1 parent 15aaf7f51b
commit 9bc703a437
23 files changed
+1646 -269

No files matched your search

+11 -1
View File
@@ -38,10 +38,18 @@ import { useIsQuickAvailabilityCheckFeatureEnabled } from "./components/hooks/us
import { fadeInLeft, getBookerSizeClassNames, useBookerResizeAnimation } from "./config";
import framerFeatures from "./framer-features";
import { useBookerStore } from "./store";
import type { BookerProps, WrappedBookerProps } from "./types";
import type { BookerProps, WrappedBookerProps, BookerState } from "./types";
import { isBookingDryRun } from "./utils/isBookingDryRun";
import { isTimeSlotAvailable } from "./utils/isTimeslotAvailable";
function updateEmbedBookerState({ bookerState }: { bookerState: BookerState }) {
// Ensure that only after the bookerState is reflected, we update the embedIsBookerReady
if (typeof window !== "undefined") {
(window as Window & { _embedBookerState?: "initializing" | "done" })._embedBookerState =
bookerState && bookerState !== "loading" ? "done" : "initializing";
}
}
const BookerComponent = ({
username,
eventSlug,
@@ -178,6 +186,8 @@ const BookerComponent = ({
(bookerState === "booking" || (bookerState === "selecting_time" && skipConfirmStep))
);
updateEmbedBookerState({ bookerState });
useEffect(() => {
if (event.isPending) return setBookerState("loading");
if (!selectedDate) return setBookerState("selecting_date");