Fix booker top margin embed (#10357)
This commit is contained in:
1 parent
10bd332405
commit
47739a7636
6 files changed
+53
-26
No files matched your search
@@ -6,17 +6,20 @@ test.describe("Embed Pages", () => {
|
||||
test("Event Type Page: should not have margin top on embed page", async ({ page }) => {
|
||||
await page.goto("http://localhost:3000/free/30min/embed");
|
||||
// Checks the margin from top by checking the distance between the div inside main from the viewport
|
||||
const marginFromTop = await page.evaluate(() => {
|
||||
const mainElement = document.querySelector("main");
|
||||
const divElement = mainElement?.querySelector("div");
|
||||
const marginFromTop = await page.evaluate(async () => {
|
||||
return await new Promise((resolve) => {
|
||||
(function tryGettingBoundingRect() {
|
||||
const mainElement = document.querySelector(".main");
|
||||
|
||||
if (mainElement && divElement) {
|
||||
// This returns the distance of the div element from the viewport
|
||||
const divRect = divElement.getBoundingClientRect();
|
||||
return divRect.top;
|
||||
}
|
||||
|
||||
return null;
|
||||
if (mainElement) {
|
||||
// This returns the distance of the div element from the viewport
|
||||
const mainElBoundingRect = mainElement.getBoundingClientRect();
|
||||
resolve(mainElBoundingRect.top);
|
||||
} else {
|
||||
setTimeout(tryGettingBoundingRect, 500);
|
||||
}
|
||||
})();
|
||||
});
|
||||
});
|
||||
|
||||
expect(marginFromTop).toBe(0);
|
||||
|
||||
@@ -183,9 +183,7 @@ const BookerComponent = ({
|
||||
(layout === BookerLayouts.MONTH_VIEW || isEmbed) && "border-subtle rounded-md border",
|
||||
!isEmbed && "sm:transition-[width] sm:duration-300",
|
||||
isEmbed && layout === BookerLayouts.MONTH_VIEW && "border-booker sm:border-booker-width",
|
||||
!isEmbed && layout === BookerLayouts.MONTH_VIEW && "border-subtle",
|
||||
// We don't want any margins for Embed. Any margin needed should be added by Embed user.
|
||||
layout === BookerLayouts.MONTH_VIEW && isEmbed && "mt-0"
|
||||
!isEmbed && layout === BookerLayouts.MONTH_VIEW && "border-subtle"
|
||||
)}>
|
||||
<AnimatePresence>
|
||||
<BookerSection
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import { classNames } from "@calcom/lib";
|
||||
|
||||
export function getBookerWrapperClasses({ isEmbed }: { isEmbed: boolean }) {
|
||||
// We don't want any margins for Embed. Any margin needed should be added by Embed user.
|
||||
return classNames("flex h-full items-center justify-center", !isEmbed && "min-h-[100dvh]");
|
||||
}
|
||||
Reference in new issue
Block a user