Skip to content

Commit

Permalink
fix: Hide EventTypeDetails when configured (calcom#9633)
Browse files Browse the repository at this point in the history
  • Loading branch information
hariombalhara authored Jun 21, 2023
1 parent 69c9f69 commit 5acb3a0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
6 changes: 5 additions & 1 deletion packages/features/bookings/Booker/Booker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useEffect, useRef, useMemo } from "react";
import StickyBox from "react-sticky-box";
import { shallow } from "zustand/shallow";

import { useEmbedUiConfig } from "@calcom/embed-core/embed-iframe";
import classNames from "@calcom/lib/classNames";
import useMediaQuery from "@calcom/lib/hooks/useMediaQuery";
import { BookerLayouts, defaultBookerLayoutSettings } from "@calcom/prisma/zod-utils";
Expand Down Expand Up @@ -103,6 +104,9 @@ const BookerComponent = ({
}
}, [layout]);

const embedUiConfig = useEmbedUiConfig();
const hideEventTypeDetails = isEmbed ? embedUiConfig.hideEventTypeDetails : false;

if (event.isSuccess && !event.data) {
return <NotFound />;
}
Expand All @@ -114,7 +118,7 @@ const BookerComponent = ({
ref={animationScope}
className={classNames(
// Sets booker size css variables for the size of all the columns.
...getBookerSizeClassNames(layout, bookerState),
...getBookerSizeClassNames(layout, bookerState, hideEventTypeDetails),
"bg-default dark:bg-muted grid max-w-full items-start dark:[color-scheme:dark] sm:transition-[width] sm:duration-300 sm:motion-reduce:transition-none md:flex-row",
layout === BookerLayouts.MONTH_VIEW && "border-subtle rounded-md border",
!isEmbed && "sm:transition-[width] sm:duration-300",
Expand Down
8 changes: 8 additions & 0 deletions packages/features/bookings/Booker/components/EventMeta.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { m } from "framer-motion";
import dynamic from "next/dynamic";

import { useEmbedUiConfig, useIsEmbed } from "@calcom/embed-core/embed-iframe";
import { EventDetails, EventMembers, EventMetaSkeleton, EventTitle } from "@calcom/features/bookings";
import { EventMetaBlock } from "@calcom/features/bookings/components/event-meta/Details";
import { useTimePreferences } from "@calcom/features/bookings/lib";
Expand All @@ -25,6 +26,13 @@ export const EventMeta = () => {
const rescheduleBooking = useBookerStore((state) => state.rescheduleBooking);
const { i18n, t } = useLocale();
const { data: event, isLoading } = useEvent();
const embedUiConfig = useEmbedUiConfig();
const isEmbed = useIsEmbed();
const hideEventTypeDetails = isEmbed ? embedUiConfig.hideEventTypeDetails : false;

if (hideEventTypeDetails) {
return null;
}

return (
<div className="relative z-10 p-6">
Expand Down
25 changes: 19 additions & 6 deletions packages/features/bookings/Booker/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,38 @@ export const resizeAnimationConfig: ResizeAnimationConfig = {
},
};

export const getBookerSizeClassNames = (layout: BookerLayout, bookerState: BookerState) => {
export const getBookerSizeClassNames = (
layout: BookerLayout,
bookerState: BookerState,
hideEventTypeDetails = false
) => {
const getBookerMetaClass = (className: string) => {
if (hideEventTypeDetails) {
return "";
}
return className;
};

return [
// Size settings are abstracted on their own lines purely for readbility.
// Size settings are abstracted on their own lines purely for readability.
// General sizes, used always
"[--booker-timeslots-width:240px] lg:[--booker-timeslots-width:280px]",
// Small calendar defaults
layout === BookerLayouts.MONTH_VIEW && "[--booker-meta-width:240px]",
layout === BookerLayouts.MONTH_VIEW && getBookerMetaClass("[--booker-meta-width:240px]"),
// Meta column get's wider in booking view to fit the full date on a single row in case
// of a multi occurance event. Also makes form less wide, which also looks better.
layout === BookerLayouts.MONTH_VIEW &&
bookerState === "booking" &&
"[--booker-main-width:420px] lg:[--booker-meta-width:340px]",
`[--booker-main-width:420px] ${getBookerMetaClass("lg:[--booker-meta-width:340px]")}`,
// Smaller meta when not in booking view.
layout === BookerLayouts.MONTH_VIEW &&
bookerState !== "booking" &&
"[--booker-main-width:480px] lg:[--booker-meta-width:280px]",
`[--booker-main-width:480px] ${getBookerMetaClass("lg:[--booker-meta-width:280px]")}`,
// Fullscreen view settings.
layout !== BookerLayouts.MONTH_VIEW &&
"[--booker-main-width:480px] [--booker-meta-width:340px] lg:[--booker-meta-width:424px]",
`[--booker-main-width:480px] [--booker-meta-width:340px] ${getBookerMetaClass(
"lg:[--booker-meta-width:424px]"
)}`,
];
};

Expand Down

0 comments on commit 5acb3a0

Please sign in to comment.