fix(webui): show route-aligned skeletons from first paint (#6303)
This commit is contained in:
1 parent
af68da3280
commit
5d886fbb20
43 files changed
+1592
-213
No files matched your search
@@ -24,6 +24,7 @@ export function FilePreviewPanelView({ path, state, imageOpen, onImageOpenChange
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [mode, setMode] = useState<"preview" | "source">("preview");
|
||||
const previewKind = fileKindForPath(path);
|
||||
const markdown = state.status === "ready" && state.payload.kind !== "image"
|
||||
&& state.payload.language === "markdown";
|
||||
const displayPath = state.status === "ready" ? state.payload.display_path : path;
|
||||
@@ -50,12 +51,29 @@ export function FilePreviewPanelView({ path, state, imageOpen, onImageOpenChange
|
||||
className="min-h-0 flex-1 overflow-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/60">
|
||||
{state.status === "loading" ? (
|
||||
<div role="status" aria-label={t("filePreview.loading", { defaultValue: "Loading preview..." })}
|
||||
className="flex h-full flex-col justify-center gap-3 p-6" aria-busy="true">
|
||||
className="h-full" aria-busy="true">
|
||||
<span className="sr-only">{t("filePreview.loading", { defaultValue: "Loading preview..." })}</span>
|
||||
<div aria-hidden className="mx-auto w-full max-w-sm space-y-3 animate-pulse [animation-duration:900ms] motion-reduce:animate-none">
|
||||
{fileKindForPath(path) === "image" ? <div className="aspect-[8/5] rounded-compact bg-muted/40" />
|
||||
: <>{["w-2/3", "w-full", "w-5/6", "w-3/4"].map((width) =>
|
||||
<div key={width} className={`h-1.5 rounded-full bg-muted/40 ${width}`} />)}</>}
|
||||
<div aria-hidden className="h-full animate-pulse [animation-duration:900ms] motion-reduce:animate-none">
|
||||
{previewKind === "image" ? <div className="flex h-full items-center justify-center p-4">
|
||||
<div className="aspect-[8/5] w-full max-w-sm rounded-compact bg-muted/40" />
|
||||
</div> : <>
|
||||
{previewKind === "markdown" ? <div className="flex justify-end px-4 py-2">
|
||||
<div className="inline-flex min-h-8 items-center gap-1 rounded-full bg-muted/40 p-1 text-[12px] font-medium">
|
||||
{[t("filePreview.preview"), t("filePreview.source")].map((label) => <span key={label} className="invisible px-3 py-1 [@media(pointer:coarse)]:min-h-9">{label}</span>)}
|
||||
</div>
|
||||
</div> : null}
|
||||
{previewKind === "markdown" && mode === "preview" ? <div className="px-5 pb-6 pt-1 text-sm sm:px-6">
|
||||
<div className="flex h-7 items-center"><div className="h-5 w-2/3 rounded bg-muted/40" /></div>
|
||||
{["w-full", "w-5/6", "w-3/4"].map((width) => <div key={width} className="mt-4 flex h-[1.625em] items-center">
|
||||
<div className={`h-3 rounded bg-muted/40 ${width}`} />
|
||||
</div>)}
|
||||
</div> : <div className="px-4 py-3 font-mono text-[13px] leading-[1.55]">
|
||||
{["w-2/3", "w-full", "w-5/6", "w-3/4", "w-1/2", "w-3/5"].map((width) => <div key={width} className="flex h-[1.55em] items-center">
|
||||
<div className="w-[4.25em] shrink-0 pr-[1.15rem]"><div className="ml-auto h-3 w-2 rounded bg-muted/40" /></div>
|
||||
<div className={`h-3 max-w-[calc(100%-4.25em)] rounded bg-muted/40 ${width}`} />
|
||||
</div>)}
|
||||
</div>}
|
||||
</>}
|
||||
</div>
|
||||
</div>
|
||||
) : state.status === "error" ? (
|
||||
|
||||
Reference in new issue
Block a user