From 09068b39e6f1976a6f9617c7fb4eb903d3898898 Mon Sep 17 00:00:00 2001 From: Leo Giovanetti Date: Tue, 18 Jul 2023 18:18:08 -0300 Subject: [PATCH] perf: Event-type config page (#10238) --- apps/web/components/Embed.tsx | 14 ++-- .../eventtype/EventTypeSingleLayout.tsx | 4 +- .../_components/AppCategoryNavigation.tsx | 9 +-- packages/features/shell/Shell.tsx | 67 ++++++++++--------- .../navigation/tabs/HorizontalTabItem.tsx | 16 +++-- .../navigation/tabs/HorizontalTabs.tsx | 13 +++- .../navigation/tabs/VerticalTabItem.tsx | 10 +-- .../navigation/tabs/VerticalTabs.tsx | 9 ++- 8 files changed, 82 insertions(+), 60 deletions(-) diff --git a/apps/web/components/Embed.tsx b/apps/web/components/Embed.tsx index 88c5cf48c2..6a0923ab1f 100644 --- a/apps/web/components/Embed.tsx +++ b/apps/web/components/Embed.tsx @@ -191,8 +191,8 @@ export default function MyApp() { ${uiInstructionCode} })(); }, []) - return Click me; };`; }, @@ -292,10 +292,10 @@ ${uiInstructionCode}`; }) => { return code` // Important: Please add following attributes to the element you want to open Cal on click -// \`data-cal-link="${calLink}"\` +// \`data-cal-link="${calLink}"\` // \`data-cal-config='${JSON.stringify({ layout: previewState.layout, - })}'\` + })}'\` ${uiInstructionCode}`; }, @@ -1182,7 +1182,7 @@ const EmbedTypeCodeAndPreviewDialogContent = ({
- + {tabs.map((tab) => { return (
- +
- +
- +
{children} diff --git a/packages/features/shell/Shell.tsx b/packages/features/shell/Shell.tsx index 278b010fe5..9761ba15ae 100644 --- a/packages/features/shell/Shell.tsx +++ b/packages/features/shell/Shell.tsx @@ -136,6 +136,41 @@ function useRedirectToLoginIfUnauthenticated(isPublic = false) { }; } +function AppTop({ setBannersHeight }: { setBannersHeight: Dispatch> }) { + const router = useRouter(); + const bannerRef = useRef(null); + + useIsomorphicLayoutEffect(() => { + const resizeObserver = new ResizeObserver((entries) => { + const { offsetHeight } = entries[0].target as HTMLElement; + setBannersHeight(offsetHeight); + }); + + const currentBannerRef = bannerRef.current; + + if (currentBannerRef) { + resizeObserver.observe(currentBannerRef); + } + + return () => { + if (currentBannerRef) { + resizeObserver.unobserve(currentBannerRef); + } + }; + }, [bannerRef]); + + return ( +
+ + + + + + +
+ ); +} + function useRedirectToOnboardingIfNeeded() { const router = useRouter(); const query = useMeQuery(); @@ -163,29 +198,8 @@ function useRedirectToOnboardingIfNeeded() { } const Layout = (props: LayoutProps) => { - const router = useRouter(); - const pageTitle = typeof props.heading === "string" && !props.title ? props.heading : props.title; - const bannerRef = useRef(null); const [bannersHeight, setBannersHeight] = useState(0); - - useIsomorphicLayoutEffect(() => { - const resizeObserver = new ResizeObserver((entries) => { - const { offsetHeight } = entries[0].target as HTMLElement; - setBannersHeight(offsetHeight); - }); - - const currentBannerRef = bannerRef.current; - - if (currentBannerRef) { - resizeObserver.observe(currentBannerRef); - } - - return () => { - if (currentBannerRef) { - resizeObserver.unobserve(currentBannerRef); - } - }; - }, [bannerRef]); + const pageTitle = typeof props.heading === "string" && !props.title ? props.heading : props.title; return ( <> @@ -202,14 +216,7 @@ const Layout = (props: LayoutProps) => { {/* todo: only run this if timezone is different */}
-
- - - - - - -
+
{props.SidebarContainer || }
diff --git a/packages/ui/components/navigation/tabs/HorizontalTabItem.tsx b/packages/ui/components/navigation/tabs/HorizontalTabItem.tsx index 8473b8ee2f..cbdcf4ba2d 100644 --- a/packages/ui/components/navigation/tabs/HorizontalTabItem.tsx +++ b/packages/ui/components/navigation/tabs/HorizontalTabItem.tsx @@ -1,6 +1,5 @@ import Link from "next/link"; import { useRouter } from "next/router"; -import type { ComponentProps } from "react"; import classNames from "@calcom/lib/classNames"; import { useLocale } from "@calcom/lib/hooks/useLocale"; @@ -14,12 +13,20 @@ export type HorizontalTabItemProps = { disabled?: boolean; className?: string; href: string; - linkProps?: Omit, "href">; + linkShallow?: boolean; + linkScroll?: boolean; icon?: SVGComponent; avatar?: string; }; -const HorizontalTabItem = function ({ name, href, linkProps, avatar, ...props }: HorizontalTabItemProps) { +const HorizontalTabItem = function ({ + name, + href, + linkShallow, + linkScroll, + avatar, + ...props +}: HorizontalTabItemProps) { const { t, isLocaleReady } = useLocale(); const { asPath } = useRouter(); @@ -29,7 +36,8 @@ const HorizontalTabItem = function ({ name, href, linkProps, avatar, ...props }: {actions && actions} diff --git a/packages/ui/components/navigation/tabs/VerticalTabItem.tsx b/packages/ui/components/navigation/tabs/VerticalTabItem.tsx index f3a98a9c75..642157300a 100644 --- a/packages/ui/components/navigation/tabs/VerticalTabItem.tsx +++ b/packages/ui/components/navigation/tabs/VerticalTabItem.tsx @@ -1,6 +1,5 @@ import Link from "next/link"; import { useRouter } from "next/router"; -import type { ComponentProps } from "react"; import { Fragment } from "react"; import classNames from "@calcom/lib/classNames"; @@ -23,7 +22,8 @@ export type VerticalTabItemProps = { disableChevron?: boolean; href: string; isExternalLink?: boolean; - linkProps?: Omit, "href">; + linkShallow?: boolean; + linkScroll?: boolean; avatar?: string; iconClassName?: string; }; @@ -34,7 +34,8 @@ const VerticalTabItem = ({ info, isChild, disableChevron, - linkProps, + linkShallow, + linkScroll, ...props }: VerticalTabItemProps) => { const { t } = useLocale(); @@ -47,7 +48,8 @@ const VerticalTabItem = ({