import type { ReactNode } from "react";
import { cn } from "./cn";
/** A placeholder for one piece of content that is loading. A soft light sweeps across it. */
export function Shimmer({ className }: { className?: string }) {
return ;
}
/** The shapes a page can take while it loads. The skeleton shows the layout to come, never fake content. */
export type SkeletonKind = "overview" | "list" | "detail" | "code" | "form" | "section";
const WIDTHS = ["w-[62%]", "w-[48%]", "w-[71%]", "w-[55%]", "w-[66%]", "w-[43%]", "w-[58%]", "w-[51%]"];
function Card({ children, className }: { children: ReactNode; className?: string }) {
return
{children}
;
}
function CardHeader() {
return (
);
}
function Rows({ count, icon = false }: { count: number; icon?: boolean }) {
return Array.from({ length: count }, (_, index) => (
));
}
function Title({ meta = false }: { meta?: boolean }) {
return (
{meta && }
);
}
function Toolbar() {
return (
);
}
function Shape({ kind }: { kind: SkeletonKind }) {
if (kind === "overview") {
return (
);
}
if (kind === "list") {
return (
);
}
if (kind === "detail") {
return (
{[0, 1, 2].map((index) => (
))}
);
}
if (kind === "code") {
return (
{Array.from({ length: 10 }, (_, index) => (
))}
);
}
if (kind === "form") {
return (
{[0, 1, 2].map((index) => (
))}
);
}
return (
);
}
/**
* The shape of a page while it loads. `title` adds the page heading, for a whole page; leave it out when the
* heading above stays on screen.
*/
export function PageSkeleton({ kind, title = false }: { kind: SkeletonKind; title?: boolean }) {
return (
{(title || kind === "detail") &&
}
);
}