import { lazy, type ReactNode, Suspense, useState } from 'react'; import { assignInlineVars } from '@vanilla-extract/dynamic'; import { clsx } from 'clsx'; import { useBreakpoints, useLayoutBreakpoints } from '#/lib/hooks/use-breakpoints'; import { useSession } from '#/state/session'; import * as css from '#/components/Shell/Shell.css'; const DesktopLeftNav = lazy(() => import('#/components/Shell/desktop/LeftNav').then((m) => ({ default: m.DesktopLeftNav })), ); const DesktopRightNav = lazy(() => import('#/components/Shell/desktop/RightNav').then((m) => ({ default: m.DesktopRightNav })), ); const BottomBar = lazy(() => import('#/components/Shell/BottomBar').then((m) => ({ default: m.BottomBar }))); const Drawer = lazy(() => import('#/components/Shell/Drawer').then((m) => ({ default: m.Drawer }))); export type ShellProps = { /** whether the route asks for the bottom bar, from its `bottomBar` meta. */ bottomBar: boolean; children: ReactNode; routeName: string; }; /** the app shell. */ export function Shell({ bottomBar, children, routeName }: ShellProps) { const { hasSession } = useSession(); const { gtMobile } = useBreakpoints(); const { leftNavMinimal, rightNavVisible } = useLayoutBreakpoints(); const showLeftNav = hasSession ? gtMobile : !leftNavMinimal; const showBottomBar = !showLeftNav && (!hasSession || bottomBar); const isSplitView = routeName.startsWith('Messages') && rightNavVisible; const fixedViewport = isSplitView || (routeName === 'MessagesConversation' && !rightNavVisible); const showRightNav = rightNavVisible && !routeName.startsWith('Messages'); const [barHeight, setBarHeight] = useState(0); const bottomBarHeight = showBottomBar ? `${barHeight}px` : 'env(safe-area-inset-bottom, 0px)'; return (