"use client"; import { useIsMobile } from "@/utils"; import { useHeaderRootLabel } from "../../contexts/HeaderChildrenContext"; import { useSharedContext } from "../../contexts/SharedContext"; import { SidebarTrigger } from "../../shadcnui"; import { BreadcrumbNavigation } from "./Breadcrumb"; type HeaderProps = { children?: React.ReactNode; /** Widgets kept on mobile, where there is no room for the full `children` set. */ mobileChildren?: React.ReactNode; leftContent?: React.ReactNode; /** Rendered before everything else, on mobile only — where the sidebar (and its logo) is off-canvas. */ logo?: React.ReactNode; className?: string; }; export function Header({ children, mobileChildren, leftContent, logo, className }: HeaderProps) { const { breadcrumbs } = useSharedContext(); const rootLabel = useHeaderRootLabel(); const isMobile = useIsMobile(); return ( // Outer element owns the safe-area inset; the inner row keeps h-12 so the // content height is unchanged and only the notch padding is added above. // bg-sidebar: the outer element has no background of its own, and a padded // transparent strip would show scrolled content behind the status bar. // The fallback is MANDATORY in this package: other consumers (neural-erp) // never define --app-header-h, and a var() referencing an undefined // property invalidates the whole declaration. The fallback MUST include the // safe-area inset, because the padding below is unconditional: a consumer // that never defines the variable but does set viewportFit: "cover" would // otherwise get 3rem of height plus inset padding, squeezing the inner // h-12 row. (Tailwind arbitrary values need _ for spaces; CSS calc needs // whitespace around the +.)
{isMobile && logo &&
{logo}
} {leftContent}
{isMobile ? mobileChildren && (
{mobileChildren}
) : children && ( // No fixed width: the widget slot sizes to its content and the // breadcrumb (w-full, above) takes the rest. A `w-64` cap here // clipped consumers whose widget set outgrew 256px.
{children}
)}
); }