import { useTranslation } from '../../i18n'; /** * Grey stand-ins in the shape of what is loading, where a native app shows the * list before its content rather than a spinner in an empty screen: rows for a * list, cards for a feed, a cover and lines for a detail page, a plain surface * for a map. They pulse softly, and not at all with reduced motion. Announced * once as "Loading" for a screen reader; the shapes themselves are hidden from it. */ type MSkeletonVariant = 'rows' | 'cards' | 'detail' | 'map'; interface MSkeletonProps { variant: MSkeletonVariant; /** How many rows or cards (rows, cards). */ count?: number; /** Rows as cards of their own (default), or as lines inside a card that already frames them. */ framed?: boolean; className?: string; } const BLOCK = 'bg-[color:var(--m-ic)]'; // Lines of different lengths read as text; equal ones read as a table. const WIDTHS = ['w-2/3', 'w-1/2', 'w-3/4', 'w-3/5']; function Row({ i, framed }: { i: number; framed: boolean }) { const frame = framed ? 'mb-2 rounded-[14px] border border-[color:var(--m-rowbr)] px-3 py-[10px]' : 'border-b border-[color:var(--m-rowbr)] py-3 last:border-b-0'; return (
); } function Card({ i }: { i: number }) { return (
); } function Detail() { return (
{WIDTHS.map((w) => ( ))}
); } export default function MSkeleton({ variant, count = 4, framed = true, className = '' }: MSkeletonProps) { const { t } = useTranslation(); const items = Array.from({ length: count }, (_, i) => i); return (
); }