Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Example covers load under their own placeholder

Adarshd842770287a8
diff --git a/src/components/studio/example-row.tsx b/src/components/studio/example-row.tsx
index 54c73b35..3b055463 100644
--- a/src/components/studio/example-row.tsx
+++ b/src/components/studio/example-row.tsx
@@ -1,13 +1,33 @@
"use client";
import dynamic from "next/dynamic";
-import { useId } from "react";
+import { Suspense, useId } from "react";
import type { StudioExampleRow } from "@/lib/studio-examples";
import { cn } from "@/lib/utils";
/** The covers are their own chunk, as in the studios (studio-page.tsx): only a page that shows the row loads them. */
const ShowcaseTile = dynamic(() => import("@/components/home/showcase-tile").then((m) => m.ShowcaseTile));
+/**
+ * The row's tiles while their chunk loads (a page reached by a tap, whose covers weren't loaded yet): the same grid of
+ * empty covers, so the rest of the page draws at once instead of waiting for the row, and nothing moves when it lands.
+ */
+export function ExampleTilesSuspense({ count, children }: { count: number; children: React.ReactNode }) {
+ return (
+ <Suspense
+ fallback={
+ <div aria-hidden className="grid grid-cols-2 gap-3 sm:grid-cols-4">
+ {Array.from({ length: count }, (_, i) => (
+ <div key={i} className={cn("aspect-[4/3] rounded-xl bg-muted", i >= 4 && "max-sm:hidden md:max-lg:hidden")} />
+ ))}
+ </div>
+ }
+ >
+ {children}
+ </Suspense>
+ );
+}
+
/** A tile's width: half a phone, else a quarter of the row (1000 px at most). */
const SIZES = "(min-width: 640px) 240px, 50vw";
diff --git a/src/components/studio/studio-page.tsx b/src/components/studio/studio-page.tsx
index 2ed3c5c6..39b9494b 100644
--- a/src/components/studio/studio-page.tsx
+++ b/src/components/studio/studio-page.tsx
@@ -41,6 +41,7 @@ import { ComposerBridgeCtx, useComposerBridge, type ComposerBridge } from "./att
import { CatalogProvider, useCatalog } from "./catalog";
import { Composer } from "./composer";
import { EngineSwitch } from "./engine-switch";
+import { ExampleTilesSuspense } from "./example-row";
import { HubHeaderExtras, useInHub } from "./hub-chrome";
import { Feed } from "./feed";
import type { SlotValue } from "./media-slot";
@@ -380,7 +381,9 @@ function StudioExamples({ row }: { row: StudioExampleRow }) {
<h2 id={heading} className="mb-2 text-center text-[12.5px] font-medium text-muted-foreground">
{row.heading}
</h2>
- <ExampleTiles tiles={row.tiles} />
+ <ExampleTilesSuspense count={row.tiles.length}>
+ <ExampleTiles tiles={row.tiles} />
+ </ExampleTilesSuspense>
</section>
);
}