From ee31633e2b032223a811abc05a714c182604b899 Mon Sep 17 00:00:00 2001 From: Benny Joo Date: Mon, 27 Jan 2025 11:08:47 +0000 Subject: [PATCH] perf: layout persistence and reduced bundle size (#18889) * create /(main-nav)/layout.tsx file that uses Shell * Add ShellMainAppDir that clones ShellMain but with client/server separation * event-types, availability, bookings * update pagesAndRewritePaths logic * fix --------- Co-authored-by: Peer Richelsen --- .../(main-nav)/ShellMainAppDir.tsx | 65 ++++++++++++++++ .../(main-nav)/ShellMainAppDirBackButton.tsx | 22 ++++++ .../{ => (main-nav)}/availability/page.tsx | 16 ++-- .../bookings/[status]/page.tsx | 12 ++- .../{ => (main-nav)}/event-types/page.tsx | 16 +++- .../(use-page-wrapper)/(main-nav)/layout.tsx | 11 +++ .../(use-page-wrapper)/bookings/layout.tsx | 21 ----- .../availability/availability-view.tsx | 77 ++++++++++--------- .../views/event-types-listing-view.tsx | 67 ++++++++-------- apps/web/pagesAndRewritePaths.js | 8 +- 10 files changed, 213 insertions(+), 102 deletions(-) create mode 100644 apps/web/app/(use-page-wrapper)/(main-nav)/ShellMainAppDir.tsx create mode 100644 apps/web/app/(use-page-wrapper)/(main-nav)/ShellMainAppDirBackButton.tsx rename apps/web/app/(use-page-wrapper)/{ => (main-nav)}/availability/page.tsx (68%) rename apps/web/app/(use-page-wrapper)/{ => (main-nav)}/bookings/[status]/page.tsx (59%) rename apps/web/app/(use-page-wrapper)/{ => (main-nav)}/event-types/page.tsx (62%) create mode 100644 apps/web/app/(use-page-wrapper)/(main-nav)/layout.tsx delete mode 100644 apps/web/app/(use-page-wrapper)/bookings/layout.tsx diff --git a/apps/web/app/(use-page-wrapper)/(main-nav)/ShellMainAppDir.tsx b/apps/web/app/(use-page-wrapper)/(main-nav)/ShellMainAppDir.tsx new file mode 100644 index 0000000000..8aedfe510b --- /dev/null +++ b/apps/web/app/(use-page-wrapper)/(main-nav)/ShellMainAppDir.tsx @@ -0,0 +1,65 @@ +import { ShellMainAppDirBackButton } from "app/(use-page-wrapper)/(main-nav)/ShellMainAppDirBackButton"; +import classNames from "classnames"; + +import type { LayoutProps } from "@calcom/features/shell/Shell"; + +// Copied from `ShellMain` but with a different `ShellMainAppDirBackButton` import +// for client/server component separation +export function ShellMainAppDir(props: LayoutProps) { + return ( + <> + {(props.heading || !!props.backPath) && ( +
+ {!!props.backPath && } + {props.heading && ( +
+ {props.HeadingLeftIcon &&
{props.HeadingLeftIcon}
} +
+ {props.heading && ( +

+ {props.heading} +

+ )} + {props.subtitle && ( +

+ {props.subtitle} +

+ )} +
+ {props.beforeCTAactions} + {props.CTA && ( +
+ {props.CTA} +
+ )} + {props.actions && props.actions} +
+ )} +
+ )} + {props.afterHeading && <>{props.afterHeading}} + +
+ {props.children} +
+ + ); +} diff --git a/apps/web/app/(use-page-wrapper)/(main-nav)/ShellMainAppDirBackButton.tsx b/apps/web/app/(use-page-wrapper)/(main-nav)/ShellMainAppDirBackButton.tsx new file mode 100644 index 0000000000..2be728fbd9 --- /dev/null +++ b/apps/web/app/(use-page-wrapper)/(main-nav)/ShellMainAppDirBackButton.tsx @@ -0,0 +1,22 @@ +"use client"; + +import { useRouter } from "next/navigation"; + +import type { LayoutProps } from "@calcom/features/shell/Shell"; +import { Button } from "@calcom/ui"; + +export const ShellMainAppDirBackButton = ({ backPath }: { backPath: LayoutProps["backPath"] }) => { + const router = useRouter(); + return ( +