Skip to content

Open source CapCut alternative.

TypeScript

fix(site): su pages hand off to one loading stand-in

David Le582262f91c72
diff --git a/site/src/app/su/SuStandIn.tsx b/site/src/app/su/SuStandIn.tsx
new file mode 100644
index 00000000..04dc65bd
--- /dev/null
+++ b/site/src/app/su/SuStandIn.tsx
@@ -0,0 +1,16 @@
+import { Skeleton } from "@/components/ui/skeleton";
+
+// What a page's slot shows until its data is on screen. The route fallback
+// (loading.tsx) and every page's pending branch draw this same stand-in, so
+// the handoff from one to the other paints the same pixels: a page arriving
+// before its query resolves is invisible.
+export function SuStandIn() {
+ return (
+ <div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
+ {Array.from({ length: 3 }, (_, i) => (
+ <Skeleton key={i} className="h-[104px] rounded-xl" />
+ ))}
+ <Skeleton className="h-96 rounded-xl sm:col-span-2 lg:col-span-3" />
+ </div>
+ );
+}
diff --git a/site/src/app/su/analytics/product/page.tsx b/site/src/app/su/analytics/product/page.tsx
index 18950c60..26c8a767 100644
--- a/site/src/app/su/analytics/product/page.tsx
+++ b/site/src/app/su/analytics/product/page.tsx
@@ -23,7 +23,6 @@ import {
ChartTooltipContent,
type ChartConfig,
} from "@/components/ui/chart";
-import { Skeleton } from "@/components/ui/skeleton";
import type {
AnalyticsBilling,
AnalyticsReferrals,
@@ -34,6 +33,7 @@ import { REFERRAL_SOURCES } from "@/lib/onboarding/sequence";
import { useLocalPref } from "@/cut/lib/uiState";
import { cn } from "@/lib/utils";
import { DragBlock, useReorder } from "@/app/su/analytics/Reorder";
+import { SuStandIn } from "@/app/su/SuStandIn";
import { useRowWindow } from "@/app/su/analytics/rowWindow";
import { useAnalyticsRollup } from "@/queries/analytics";
import { ApiError } from "@/queries/apiClient";
@@ -862,24 +862,7 @@ export default function SuAnalyticsPage() {
const tiles = useReorder("su-analytics-tile-order", TILE_IDS);
const cards = useReorder("su-analytics-card-order", CARD_IDS);
- if (rollup.isPending) {
- return (
- <div className="space-y-6 pb-9">
- <div className="grid gap-4 sm:grid-cols-2 xl:grid-cols-4">
- {Array.from({ length: 8 }, (_, i) => (
- <Skeleton key={i} className="h-[104px] rounded-xl" />
- ))}
- </div>
- <div className="grid gap-6 xl:grid-cols-2">
- <Skeleton className="h-96 rounded-xl" />
- <Skeleton className="h-96 rounded-xl" />
- <Skeleton className="h-96 rounded-xl" />
- <Skeleton className="h-96 rounded-xl" />
- </div>
- <Skeleton className="h-80 rounded-xl" />
- </div>
- );
- }
+ if (rollup.isPending) return <SuStandIn />;
if (rollup.error || !view || !rollup.data) {
const noData = rollup.error instanceof ApiError && rollup.error.status === 404;
diff --git a/site/src/app/su/experiments/list/page.tsx b/site/src/app/su/experiments/list/page.tsx
index c6e338a9..70c77c7d 100644
--- a/site/src/app/su/experiments/list/page.tsx
+++ b/site/src/app/su/experiments/list/page.tsx
@@ -7,7 +7,7 @@ import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
-import { Skeleton } from "@/components/ui/skeleton";
+import { SuStandIn } from "@/app/su/SuStandIn";
import { describeAudience } from "@donkeycut/abexp";
import type { ExperimentStatus } from "@/lib/config/experiment";
import type { MetricResult, VerdictState } from "@donkeycut/abexp";
@@ -58,7 +58,7 @@ export default function SuExperimentsListPage() {
setDialogOpen(true);
};
- if (!experiments.data) return <Skeleton className="h-40 w-full" />;
+ if (!experiments.data) return <SuStandIn />;
return (
<div className="space-y-6 pb-9">
diff --git a/site/src/app/su/experiments/settings/page.tsx b/site/src/app/su/experiments/settings/page.tsx
index 93ec653e..89cc2fa4 100644
--- a/site/src/app/su/experiments/settings/page.tsx
+++ b/site/src/app/su/experiments/settings/page.tsx
@@ -12,7 +12,7 @@ import {
CardHeader,
CardTitle,
} from "@/components/ui/card";
-import { Skeleton } from "@/components/ui/skeleton";
+import { SuStandIn } from "@/app/su/SuStandIn";
import { useResetSetting, useSaveSetting, useSettings, type SettingRow } from "@/queries/settings";
// Every registered setting, editable. The value on screen is what the product
@@ -21,7 +21,7 @@ import { useResetSetting, useSaveSetting, useSettings, type SettingRow } from "@
export default function SuSettingsPage() {
const settings = useSettings();
if (!settings.data) {
- return <Skeleton className="h-40 w-full max-w-2xl" />;
+ return <SuStandIn />;
}
if (settings.data.settings.length === 0) {
return (
diff --git a/site/src/app/su/loading.tsx b/site/src/app/su/loading.tsx
index 84da2da6..73a7946d 100644
--- a/site/src/app/su/loading.tsx
+++ b/site/src/app/su/loading.tsx
@@ -1,15 +1,6 @@
-import { Skeleton } from "@/components/ui/skeleton";
+import { SuStandIn } from "@/app/su/SuStandIn";
-// What a page's slot shows from the moment a rail link is clicked until the
-// page arrives. Every surface opens on cards, so the stand-in is a row of
-// them; the page's own skeletons take over once it mounts.
+// Shown from the moment a rail link is clicked until the page arrives.
export default function SuLoading() {
- return (
- <div className="grid gap-4 pt-1 sm:grid-cols-2 lg:grid-cols-3">
- {Array.from({ length: 3 }, (_, i) => (
- <Skeleton key={i} className="h-[104px] rounded-xl" />
- ))}
- <Skeleton className="h-96 rounded-xl sm:col-span-2 lg:col-span-3" />
- </div>
- );
+ return <SuStandIn />;
}