import { cn } from "@suphark/ui/lib/utils"; import { type ReactNode, Suspense } from "react"; import { PageBreadcrumb, type PageBreadcrumbItem } from "../navigation/page-breadcrumb"; interface PageShellProps { title?: string; description?: string; breadcrumb?: PageBreadcrumbItem[]; actions?: ReactNode; /** เมนูใต้หัวหน้า (แท็บย่อยของหมวด ฯลฯ) — render พร้อมหัวหน้า นอก Suspense */ subNav?: ReactNode; children: ReactNode; fallback: ReactNode; className?: string; } /** * PageShell - A standard template for implementing the Parallel Shell & Static Header Pattern. * It renders the static header (title, description, breadcrumbs) immediately to the browser * while wrapping the dynamic children in a Suspense boundary for non-blocking streaming. */ export function PageShell({ title, description, breadcrumb, actions, subNav, children, fallback, className, }: PageShellProps) { return (
{/* STATIC HEADER (Rendered Immediately) This part ensures the user sees the page title and context right away. */}
{breadcrumb && } {(title || actions) && ( // ห่อบรรทัดบนจอแคบ — ปุ่มด้านขวาลงไปอยู่ใต้หัวข้อแทนการล้นจอ
{title &&

{title}

} {description &&

{description}

}
{actions &&
{actions}
}
)} {subNav}
{/* DYNAMIC CONTENT (Streamed) The children are wrapped in Suspense to prevent data waterfalls from blocking the entire page render. */} {children}
); }