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.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Example rows: card pictures share one top, and section rows match the box above
Adarsh772c41b7619e
diff --git a/src/components/ads/ads-home.tsx b/src/components/ads/ads-home.tsxindex 801a4448..8c6cab3e 100644--- a/src/components/ads/ads-home.tsx+++ b/src/components/ads/ads-home.tsx@@ -136,7 +136,7 @@ export function AdsHome({ examples, starters: given = [] }: { examples?: Example{!brands.isLoading && !hasBrands && <StarterSection surface="ads" starters={given} className="mt-12" />}- {!!moreToTry?.cards.length && (visitor || (brands.isSuccess && !brands.data.length)) && <ExampleRow row={moreToTry} className="mt-12" />}+ {!!moreToTry?.cards.length && (visitor || (brands.isSuccess && !brands.data.length)) && <ExampleRow row={moreToTry} layout="column" className="mx-auto mt-12 max-w-[720px]" />}{(brands.isLoading || hasBrands || !readyShown) && (<section className="mt-14">diff --git a/src/components/cinema/projects-view.tsx b/src/components/cinema/projects-view.tsxindex c08177ca..d57cc38f 100644--- a/src/components/cinema/projects-view.tsx+++ b/src/components/cinema/projects-view.tsx@@ -229,7 +229,8 @@ export function CinemaProjects({ examples, starters: given = [] }: { examples?:) : (<EmptyProjects onCreate={onCreate} />)}- {examples && <ExampleRow row={examples} className="mt-12" />}+ {/* On the page's own width: its heading sits under the page's title. */}+ {examples && <ExampleRow row={examples} layout="column" className="mt-12" />}</div>) : (<div key="cards" className={GRID}>diff --git a/src/components/examples/example-cards.tsx b/src/components/examples/example-cards.tsxindex ea8f692d..7b843ff5 100644--- a/src/components/examples/example-cards.tsx+++ b/src/components/examples/example-cards.tsx@@ -10,7 +10,7 @@ import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "import { useIsMobile } from "@/hooks/use-mobile";import { exampleKey, type ExampleCard, type ExampleInput, type ExampleMedia, type ExampleRowData } from "@/lib/examples/types";import { hasHdStill } from "@/lib/preset-hd";-import { ROW_GAP, ROW_HEADING, rowColumns, rowSection, rowWidth, type ExampleAspect, type RowLayout } from "./example-row-frame";+import { ROW_GAP, ROW_GRID, ROW_HEADING, rowColumns, rowSection, rowWidth, type ExampleAspect, type RowLayout } from "./example-row-frame";import { staggered } from "@/lib/preview-playback";import { cn } from "@/lib/utils";@@ -243,6 +243,7 @@ export function ExampleGrid({onPick,aspect,bare = false,+ maxColumns,className,}: {cards: ExampleCard[];@@ -250,10 +251,11 @@ export function ExampleGrid({onPick: ExamplePick;aspect?: ExampleAspect;bare?: boolean;+ maxColumns?: 2 | 4;className?: string;}) {return (- <div data-example-grid className={cn("grid", ROW_GAP, rowColumns(cards.length), !bare && rowWidth(cards.length), className)}>+ <div data-example-grid className={cn(ROW_GRID, ROW_GAP, rowColumns(cards.length, maxColumns), !bare && rowWidth(cards.length), className)}>{cards.map((c, i) => (<ExampleCardView key={c.id} card={c} index={i} active={!!activeId && exampleKey(c) === activeId} onPick={onPick} aspect={aspect} sizes={gridSizes(cards.length)} />))}@@ -271,6 +273,7 @@ export function ExampleRow({onPick,aspect,layout = "centred",+ maxColumns,className,}: {row: ExampleRowData;@@ -280,6 +283,8 @@ export function ExampleRow({aspect?: ExampleAspect;/** "column" under a studio's composer (the row fills the composer's column), "centred" as a section of its own. */layout?: RowLayout;+ /** 2 keeps two cards across: a row in a narrow box. */+ maxColumns?: 2 | 4;className?: string;}) {const heading = useId();@@ -292,7 +297,7 @@ export function ExampleRow({<h2 id={heading} className={ROW_HEADING}>{row.heading}</h2>- <ExampleGrid cards={row.cards} activeId={activeId} onPick={pick} aspect={aspect} bare />+ <ExampleGrid cards={row.cards} activeId={activeId} onPick={pick} aspect={aspect} maxColumns={maxColumns} bare /></div><ExampleSheet card={looking} onOpenChange={(o) => !o && setLooking(null)} /></section>diff --git a/src/components/examples/example-row-frame.tsx b/src/components/examples/example-row-frame.tsxindex 51e08368..d0de2568 100644--- a/src/components/examples/example-row-frame.tsx+++ b/src/components/examples/example-row-frame.tsx@@ -18,12 +18,22 @@ export type RowLayout = "column" | "centred";/** A card's shape: 4:3, or 3:4 on the vertical studios. */export type ExampleAspect = "4/3" | "3/4";-/** The cards' columns: two across a phone, up to four across a larger screen. */-export function rowColumns(count: number): string {+/**+ * The cards' columns: two across a phone, up to four across a larger screen (`max` 2 keeps two across: a row in a+ * narrow box, where four would leave each card too small).+ */+export function rowColumns(count: number, max: 2 | 4 = 4): string {if (count === 1) return "grid-cols-1";+ if (max === 2) return "grid-cols-2";return cn("grid-cols-2", count === 3 ? "sm:grid-cols-3" : count > 3 && "sm:grid-cols-4");}+/**+ * The cards' grid. Their tops line up: each card keeps its own height (a one-line caption is shorter) and is never+ * stretched to the row's, where a button would centre its picture lower than its neighbour's.+ */+export const ROW_GRID = "grid items-start";+/** The cards' width: one card is never wider than 360 px; a centred row of two or three keeps them card-sized. */export function rowWidth(count: number, layout: RowLayout = "centred"): string | undefined {if (count === 1) return cn("max-w-[360px]", layout === "centred" && "mx-auto");@@ -97,7 +107,7 @@ export function ExampleRowSkeleton({<p aria-hidden className={ROW_HEADING}>{row.heading}</p>- <div aria-hidden className={cn("grid", ROW_GAP, rowColumns(n))}>+ <div aria-hidden className={cn(ROW_GRID, ROW_GAP, rowColumns(n))}>{row.cards.map((c) => (<CardSkeleton key={c.id} card={c} aspect={aspect} />))}diff --git a/src/components/genjutsu/genjutsu-studio.tsx b/src/components/genjutsu/genjutsu-studio.tsxindex ae6d3d2f..6b53fdc7 100644--- a/src/components/genjutsu/genjutsu-studio.tsx+++ b/src/components/genjutsu/genjutsu-studio.tsx@@ -1077,7 +1077,7 @@ export function GenjutsuStudio({ examples, live }: { examples?: ExampleRowData |)}</div>- {examples && !clip && !run && (visitor || (history.isSuccess && !history.data.length)) && <ExampleRow row={examples} className="mt-12" />}+ {examples && !clip && !run && (visitor || (history.isSuccess && !history.data.length)) && <ExampleRow row={examples} layout="column" maxColumns={2} className="mx-auto mt-12 max-w-[640px]" />}{run && (<RunPaneldiff --git a/src/components/layers/projects-view.tsx b/src/components/layers/projects-view.tsxindex 92952413..a255848b 100644--- a/src/components/layers/projects-view.tsx+++ b/src/components/layers/projects-view.tsx@@ -311,7 +311,7 @@ function ProjectsInner({ examples }: { examples?: ExampleRowData | null }) {</section>{/* What it makes, while there are no projects of one's own to show (a guest or an account never has any). */}- {examples && (visitor || (projects.isSuccess && !items.length)) && <ExampleRow row={examples} className="mt-12" />}+ {examples && (visitor || (projects.isSuccess && !items.length)) && <ExampleRow row={examples} layout="column" className="mx-auto mt-12 max-w-[820px]" />}<section className={cn("mt-14", visitor && "hidden")} aria-labelledby="my-projects"><h2 id="my-projects" className="font-heading text-[24px]">diff --git a/src/components/model3d/model3d-studio.tsx b/src/components/model3d/model3d-studio.tsxindex a3578fe2..2c33b3f4 100644--- a/src/components/model3d/model3d-studio.tsx+++ b/src/components/model3d/model3d-studio.tsx@@ -433,7 +433,7 @@ export function Model3dStudio({ info, examples }: { info: Record<string, Model3d)}</Panel></div>- {examples && (visitor || (results.isSuccess && !items.length)) && <ExampleRow row={examples} className="mt-12" />}+ {examples && (visitor || (results.isSuccess && !items.length)) && <ExampleRow row={examples} layout="column" className="mx-auto mt-12 max-w-[880px]" />}<section id="your-3d-models" className="mx-auto mt-12 max-w-[880px] scroll-mt-6" aria-labelledby="models3d">{(results.isLoading || items.length > 0) && (<h3 id="models3d" className="mb-3 font-heading text-[22px]">diff --git a/src/components/moodboards/soul-preset-cards.tsx b/src/components/moodboards/soul-preset-cards.tsxindex 30e21d43..cf8688f2 100644--- a/src/components/moodboards/soul-preset-cards.tsx+++ b/src/components/moodboards/soul-preset-cards.tsx@@ -3,7 +3,7 @@import { Images, UserRoundPlus } from "lucide-react";import Link from "next/link";import { useStudio } from "@/components/studio/studio-context";-import { ROW_HEADING } from "@/components/examples/example-row-frame";+import { ROW_GAP, ROW_HEADING } from "@/components/examples/example-row-frame";import { SOUL_MODEL_IDS } from "@/lib/catalog/soul-cards";import { cn } from "@/lib/utils";@@ -24,7 +24,7 @@ export function SoulPresetCards({ className }: { className?: string }) {return (<section aria-label="Make your own Soul look" className={cn("w-full", className)}><p className={ROW_HEADING}>Make your own Soul look</p>- <div className="grid gap-2 sm:grid-cols-2">+ <div className={cn("grid sm:grid-cols-2", ROW_GAP)}><Link href="/character-sheet" className={card}><span className="grid size-10 shrink-0 place-items-center rounded-xl bg-brand-faint text-brand-text"><UserRoundPlus className="size-5" />diff --git a/src/components/studio/example-row.tsx b/src/components/studio/example-row.tsxindex 34177f02..9ac3f5d0 100644--- a/src/components/studio/example-row.tsx+++ b/src/components/studio/example-row.tsx@@ -1,13 +1,16 @@"use client";import { ExampleRow as Row } from "@/components/examples/example-cards";+import type { RowLayout } from "@/components/examples/example-row-frame";import type { ExampleRowData } from "@/lib/examples/types";/*** A tool's or a project list's examples (Layers, Genjutsu, Katana, Cinema, Ads Studio…), from the page's exampleRow()* (src/lib/examples/catalog.ts): until the tool has examples of its own, "More to try", covers that each open their own- * page; an example of the tool's own opens a sheet with what went in and what came out.+ * page; an example of the tool's own opens a sheet with what went in and what came out. A page with a box of its own+ * above the row (an upload box, a hero) gives the row that box's width (`layout="column"` and the box's max-w in+ * `className`), so the heading and the cards line up with the box.*/-export function ExampleRow({ row, className }: { row: ExampleRowData; className?: string }) {- return <Row row={row} className={className} />;+export function ExampleRow({ row, layout, maxColumns, className }: { row: ExampleRowData; layout?: RowLayout; maxColumns?: 2 | 4; className?: string }) {+ return <Row row={row} layout={layout} maxColumns={maxColumns} className={className} />;}diff --git a/src/components/studio/studio-page.tsx b/src/components/studio/studio-page.tsxindex e6b226de..6cc114df 100644--- a/src/components/studio/studio-page.tsx+++ b/src/components/studio/studio-page.tsx@@ -377,29 +377,38 @@ function PromptSuggestions({ suggestions }: { suggestions: string[] }) {/** The space between the composer (or what sits right under it) and each section below it. */const UNDER_COMPOSER = "mt-10 sm:mt-12";-/** How long the row waits for the feed's answer before it shows its cards anyway: a slow feed never leaves grey tiles. */+/**+ * How long a guest's row waits for the feed's answer before it shows its cards anyway: a slow feed never leaves grey+ * tiles. A guest has no results of their own, so the cards stay.+ */const FEED_WAIT_MS = 3000;+/** The cards' code, fetched as soon as the row's skeleton draws: the feed and the code load side by side. */+const preloadExampleCards = () => void import("@/components/examples/example-cards").catch(() => {});+/*** "Start from an example" under the empty composer (src/lib/examples): each card loads its own files, words and settings* into this composer. Hidden while a motion or effect is picked: its own examples are in its card above the composer.* The row fills the composer's column, so its heading and cards line up with the composer. Until the feed has answered- * (`ready`, or FEED_WAIT_MS at most) and while the cards' code loads, its skeleton holds the same place.+ * (`ready`; for a guest FEED_WAIT_MS at most) and while the cards' code loads, its skeleton holds the same place. A+ * signed-in viewer waits for the feed: with results of their own, the cards (and their covers) are never fetched.*/function StudioExamples({ row, ready }: { row: ExampleRowData; ready: boolean }) {const { draft, config } = useStudio();const loader = useContext(ExamplesCtx);+ const guest = useIsGuest();const [waited, setWaited] = useState(false);+ useEffect(preloadExampleCards, []);useEffect(() => {- if (ready) return;+ if (ready || !guest) return;const timer = setTimeout(() => setWaited(true), FEED_WAIT_MS);return () => clearTimeout(timer);- }, [ready]);+ }, [ready, guest]);if (draft.presetId && draft.presetId !== config.preset?.id) return null;// An app's page shows its examples in its card above the composer.if (config.preset && row.cards.some((c) => c.load.via !== "look")) return null;const skeleton = <ExampleRowSkeleton row={row} layout="column" className={UNDER_COMPOSER} />;- if (!ready && !waited) return skeleton;+ if (!ready && !(guest && waited)) return skeleton;return (<Suspense fallback={skeleton}><ExampleRow row={row} activeId={loader?.activeId} onPick={(c) => loader?.use(c)} layout="column" className={UNDER_COMPOSER} />@@ -635,9 +644,10 @@ function StudioBody({ header, tabs, examples }: { header?: React.ReactNode; tabs</div>{/* What sits under the empty composer, in the composer's own column: its suggestions right under it, then each- section a clear step below. Hidden, not unmounted, while Live is on: the page around the panel keeps its state. */}- <div className={cn("px-4 pb-10 sm:px-6 sm:pb-16", (live || hasItems) && "hidden")}>- <div data-under-composer className="mx-auto flex w-full max-w-[760px] min-w-0 flex-col">+ section a clear step below; the space under them only when there is something. Hidden, not unmounted, while Live+ is on: the page around the panel keeps its state. */}+ <div className={cn("px-4 sm:px-6", (live || hasItems) && "hidden")}>+ <div data-under-composer className="mx-auto flex w-full max-w-[760px] min-w-0 flex-col pb-10 empty:hidden sm:pb-16">{/* Examples that load into the composer take the suggestions' place: they come first on a phone. */}{!hasItems && config.suggestions && !examples?.cards.some((c) => c.load.via !== "look") && <PromptSuggestions suggestions={config.suggestions} />}{!hasItems && config.signature && <SoulPresetCards className={UNDER_COMPOSER} />}diff --git a/tests/e2e/composer-rows.mjs b/tests/e2e/composer-rows.mjsindex 18dfef86..9708773c 100644--- a/tests/e2e/composer-rows.mjs+++ b/tests/e2e/composer-rows.mjs@@ -2,8 +2,10 @@// a row, at 390, 768 and 1440 px, in light and dark, the row sits a fixed step below the composer (or the suggestions// right under it), its heading is on the cards' left edge with a fixed step to the cards, and the row lines up with the// composer's column. On the pages where the row is a section of its own (Genjutsu, Katana, Ads Studio…) the heading is-// on the cards' edge and the row stays inside the page. After load no card is grey or empty and no skeleton is left; while-// the cards' code loads, the skeleton has the row's heading and the cards' place, so nothing moves when they arrive.+// on the cards' edge, the row stays inside the page and lines up with the box above it (Cinema: with the page's title).+// The cards' pictures in a line of the grid share one top. After load no card is grey or empty and no skeleton is left;+// while the cards' code loads (on /image, and on /video whose captions wrap to different lengths), the skeleton has the+// row's heading and the cards' place and pictures, so nothing moves when they arrive.// Usage: node tests/e2e/composer-rows.mjs <appUrl> [--shots <dir>] [--account] [--owner <password>] [--engine webkit]// (--account signs up a new account first: the app needs FUOBE_PUBLIC_SIGNUP=1; --owner signs in with the password;// --engine runs it in WebKit, Safari's engine, or Firefox instead of Chromium.)@@ -54,6 +56,12 @@ const STUDIOS = [];/** Pages whose row is a section of its own under an upload box or a project list. */const SECTIONS = ["/genjutsu", "/katana", "/image-to-3d", "/layers", "/cinema", "/ads", "/ads/multiplier", "/character-swap"];+/** Section pages whose row takes the width of the box right above it (an upload box, a hero). */+const BOXED = new Set(["/genjutsu", "/image-to-3d", "/layers", "/ads"]);+/** Section pages whose row takes the page's own width: its edge is the page title's. */+const TITLED = new Set(["/cinema"]);+/** Pages whose loading state is checked: every card the same lines (/image), and captions of different lengths (/video). */+const LOADING = ["/image", "/video"];const SIZES = [{ name: "390", viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true },{ name: "768", viewport: { width: 768, height: 1024 } },@@ -116,7 +124,20 @@ function measure() {}}const firstCard = grid?.firstElementChild;+ // Each card's picture top (its first child: the card's picture, or the skeleton's), and whether the pictures in each+ // line of the grid share one top.+ const cards = grid ? [...grid.children] : [];+ const pictures = cards.map((c) => box(c.firstElementChild)?.t ?? null);+ const lines = new Map();+ cards.forEach((c, i) => {+ const key = Math.round(box(c).t);+ lines.set(key, [...(lines.get(key) ?? []), pictures[i]]);+ });+ const misaligned = [...lines.values()].filter((tops) => Math.max(...tops) - Math.min(...tops) > 1.5).map((tops) => tops.map(Math.round).join("/"));return {+ pictures,+ misaligned,+ title: box(document.querySelector("h1")),loading: !!section?.hasAttribute("data-examples-loading"),headingText: heading?.textContent?.trim() ?? "",headingAlign: heading ? getComputedStyle(heading).textAlign : "",@@ -187,8 +208,17 @@ for (const size of SIZES) {} else {check(`${label}: clear space above the row`, m.previous && m.heading.t - m.previous.b >= 32, m.previous ? `${Math.round(m.heading.t - m.previous.b)} px` : "nothing above");check(`${label}: the row stays inside the page`, m.grid.l >= 15 && m.grid.r <= m.page.w - 15, `${m.grid.l}-${m.grid.r}`);+ if (BOXED.has(url))+ check(+ `${label}: the row lines up with the box above it`,+ m.previous && near(m.grid.l, m.previous.l) && near(m.grid.r, m.previous.r),+ m.previous ? `row ${Math.round(m.grid.l)}-${Math.round(m.grid.r)}, box ${Math.round(m.previous.l)}-${Math.round(m.previous.r)}` : "nothing above",+ );+ if (TITLED.has(url)) check(`${label}: the row starts at the page title's edge`, near(m.grid.l, m.title?.l), `${m.grid.l} vs ${m.title?.l}`);}const filled = await cardsFilled(page);+ const lined = await page.evaluate(measure);+ check(`${label}: the pictures in each line of cards share one top`, !lined.misaligned.length, lined.misaligned.join(", ") || "");check(`${label}: no grey or empty card after load`, filled.cards > 0 && !filled.empty.length && !filled.skeletons, `${filled.cards} cards, empty ${filled.empty.join(",") || "none"}, skeletons ${filled.skeletons}`);if (shots && (url === "/image" || url === "/genjutsu")) {await page.evaluate(() => {@@ -200,10 +230,10 @@ for (const size of SIZES) {}}- // The loading state on /image: hold every script that starts after the feed answers (the cards' code among them),- // once, until the skeleton is measured.- {- const label = `/image loading (${size.name}, ${scheme})`;+ // The loading state on /image and /video: hold every script that starts after the feed answers (the cards' code among+ // them), once, until the skeleton is measured.+ for (const url of LOADING) {+ const label = `${url} loading (${size.name}, ${scheme})`;const held = await context.newPage();let hold = false;let fed = false;@@ -220,7 +250,7 @@ for (const size of SIZES) {if (!released) hold = true;});// Not "load": when the feed answers first, the held scripts can be ones the load event waits for.- await held.goto(`${app}/image`, { waitUntil: "commit", timeout: 60_000 });+ await held.goto(`${app}${url}`, { waitUntil: "commit", timeout: 60_000 });await held.locator("[data-examples-loading], [data-examples]").first().waitFor({ timeout: 30_000 }).catch(() => {});for (let waited = 0; !fed && waited < 15_000; waited += 250) await held.waitForTimeout(250);await held.waitForTimeout(1500);@@ -229,7 +259,7 @@ for (const size of SIZES) {if (!before.heading) console.log(`skip ${label}: no row (results shown)`);else {check(`${label}: the skeleton has the row's heading`, loading ? before.headingText.length > 0 : true, before.headingText);- if (shots && loading) await held.screenshot({ path: path.join(shots, `image-loading-${tag}-${size.name}-${scheme}.png`) });+ if (shots && loading) await held.screenshot({ path: path.join(shots, `${url.slice(1)}-loading-${tag}-${size.name}-${scheme}.png`) });hold = false;released = true;waiting.splice(0).forEach((r) => r());@@ -242,6 +272,12 @@ for (const size of SIZES) {near(before.heading.t, after.heading.t) && near(before.grid.t, after.grid.t) && near(before.grid.l, after.grid.l) && near(before.grid.r, after.grid.r) && near(before.firstCard?.w, after.firstCard?.w),`heading ${Math.round(before.heading.t)}->${Math.round(after.heading.t)}, grid ${Math.round(before.grid.l)}-${Math.round(before.grid.r)} -> ${Math.round(after.grid.l)}-${Math.round(after.grid.r)}`,);+ if (loading)+ check(+ `${label}: each card's picture stays where its skeleton was`,+ before.pictures.length === after.pictures.length && before.pictures.every((t, i) => near(t, after.pictures[i])),+ `${before.pictures.map(Math.round).join("/")} -> ${after.pictures.map(Math.round).join("/")}`,+ );if (!loading) console.log(`note ${label}: the cards were already there (no skeleton seen)`);}hold = false;