import { PageChrome } from "@/client/components/ui/page-chrome";
import { Skeleton } from "@/client/components/ui/skeleton";
import type { PageKind } from "@/shared/types";
import {
CANVAS_PAGE_BODY_CENTERED_CLASS,
CANVAS_PAGE_BODY_STAGE_CLASS,
type CanvasStageLayout,
DOC_PAGE_MAIN_CLASS,
DOC_PAGE_RAIL_CLASS,
DOC_PAGE_RAIL_INNER_CLASS,
OUTLINE_RAIL_MEDIA_QUERY,
PAGE_CONTENT_COLUMN_CLASS,
PAGE_SHELL_CLASS,
PAGE_STAGE_CLASS,
PAGE_STAGE_TRACKS_CLASS,
PAGE_STAGE_WITH_TRACKS_CLASS,
} from "@/client/components/ui/page-layout";
import { useMediaQuery } from "@/client/hooks/use-media-query";
const OUTLINE_RAIL_ROWS = [
{ indent: 0, width: "w-4/5" },
{ indent: 0.875, width: "w-3/5" },
{ indent: 0.875, width: "w-2/3" },
{ indent: 1.75, width: "w-1/2" },
{ indent: 0, width: "w-3/4" },
];
type LoadingSkeletonKind = PageKind | "unknown";
type DocumentSkeletonLayout = "rail" | "inline";
function ChromeBreadcrumbSkeleton() {
return (
<>
>
);
}
function PageChromeSkeleton() {
return (
<>
}
breadcrumb={}
icon={}
/>
>
);
}
function RailSkeleton() {
return (
<>
{OUTLINE_RAIL_ROWS.map((row, i) => (
-
))}
>
);
}
function DocumentBodySkeleton() {
return (
);
}
function CanvasBodySkeleton() {
return ;
}
function UnknownBodySkeleton() {
return (
);
}
interface PageLoadingSkeletonProps {
canvasLayout?: CanvasStageLayout;
kind?: LoadingSkeletonKind;
documentLayout?: DocumentSkeletonLayout;
}
export function PageLoadingSkeleton({
canvasLayout = "centered",
kind = "doc",
documentLayout = "rail",
}: PageLoadingSkeletonProps) {
// Mirror DocumentPage: the rail layout is only realized in CSS at min-[1440px],
// so collapse to inline when the viewport can't host the side rail.
const railViewport = useMediaQuery(OUTLINE_RAIL_MEDIA_QUERY);
const effectiveDocumentLayout: DocumentSkeletonLayout = documentLayout === "rail" && railViewport ? "rail" : "inline";
if (kind === "canvas") {
return (
{canvasLayout === "stage" ? (
<>
>
) : (
)}
);
}
if (kind === "unknown") {
const reserveTracks = canvasLayout === "stage" || effectiveDocumentLayout === "rail";
if (reserveTracks) {
return (
);
}
return (
);
}
if (effectiveDocumentLayout === "inline") {
return (
);
}
return (
);
}