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 picture sizes follow the row's own width
Adarsh1c44ddd166b9
diff --git a/src/components/examples/example-cards.tsx b/src/components/examples/example-cards.tsxindex 7b843ff5..a3b7a2cf 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_GRID, ROW_HEADING, rowColumns, rowSection, rowWidth, type ExampleAspect, type RowLayout } from "./example-row-frame";+import { ROW_GAP, ROW_GRID, ROW_HEADING, rowColumns, rowSection, rowSizes, rowWidth, type ExampleAspect, type RowLayout } from "./example-row-frame";import { staggered } from "@/lib/preview-playback";import { cn } from "@/lib/utils";@@ -225,17 +225,10 @@ export function ExampleCardView({);}-/** How wide a grid's card shows (its picture's `sizes`), by how many cards it has: as the grid below lays them out. */-function gridSizes(n: number): string {- if (n === 1) return "(min-width: 392px) 360px, calc(100vw - 32px)";- if (n === 2) return "(min-width: 640px) 252px, 50vw";- if (n === 3) return "(min-width: 640px) 245px, 50vw";- return "(min-width: 1032px) 240px, (min-width: 640px) 25vw, 50vw";-}-/*** Cards in a grid: two across a phone, up to four across a desktop. On its own (the Examples sheet) one to three cards- * stay centred at a card's width; inside a row (`bare`) the row's frame sets the width, so its heading lines up with it.+ * stay centred at a card's width; inside a row (`bare`) the row's frame sets the width, so its heading lines up with it,+ * and the row gives the cards' `sizes` (how wide they show) for that width.*/export function ExampleGrid({cards,@@ -244,6 +237,7 @@ export function ExampleGrid({aspect,bare = false,maxColumns,+ sizes,className,}: {cards: ExampleCard[];@@ -252,12 +246,14 @@ export function ExampleGrid({aspect?: ExampleAspect;bare?: boolean;maxColumns?: 2 | 4;+ sizes?: string;className?: string;}) {+ const shown = sizes ?? rowSizes(cards.length, { maxColumns });return (<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)} />+ <ExampleCardView key={c.id} card={c} index={i} active={!!activeId && exampleKey(c) === activeId} onPick={onPick} aspect={aspect} sizes={shown} />))}</div>);@@ -274,6 +270,7 @@ export function ExampleRow({aspect,layout = "centred",maxColumns,+ maxWidth,className,}: {row: ExampleRowData;@@ -285,19 +282,23 @@ export function ExampleRow({layout?: RowLayout;/** 2 keeps two cards across: a row in a narrow box. */maxColumns?: 2 | 4;+ /** A column row's widest, in px: the box it lines up with (a studio's composer, a page's upload box). Left out, it+ * fills its page's column. */+ maxWidth?: number;className?: string;}) {const heading = useId();const [looking, setLooking] = useState<ExampleCard | null>(null);if (!row.cards.length) return null;const pick: ExamplePick = (c) => (c.load.via === "look" || !onPick ? setLooking(c) : onPick(c));+ const sizes = rowSizes(row.cards.length, { layout, cap: maxWidth, maxColumns });return (- <section aria-labelledby={heading} data-examples className={cn(rowSection(layout), className)}>+ <section aria-labelledby={heading} data-examples className={cn(rowSection(layout), maxWidth && "mx-auto", className)} style={maxWidth ? { maxWidth } : undefined}><div className={rowWidth(row.cards.length, layout)}><h2 id={heading} className={ROW_HEADING}>{row.heading}</h2>- <ExampleGrid cards={row.cards} activeId={activeId} onPick={pick} aspect={aspect} maxColumns={maxColumns} bare />+ <ExampleGrid cards={row.cards} activeId={activeId} onPick={pick} aspect={aspect} maxColumns={maxColumns} sizes={sizes} 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 d0de2568..71537422 100644--- a/src/components/examples/example-row-frame.tsx+++ b/src/components/examples/example-row-frame.tsx@@ -46,6 +46,21 @@ export function rowWidth(count: number, layout: RowLayout = "centred"): string |/** The row's own box: a centred row is at most 1000 px across its page; a column row takes its column's width. */export const rowSection = (layout: RowLayout = "centred") => cn("w-full", layout === "centred" && "mx-auto max-w-[1000px]");+/**+ * How wide a card shows (its picture's `sizes`), as the grid lays the cards out: `cap` is the widest the cards' box+ * gets (left out: a centred row's own cap; a column row with no cap of its own fills its page). Page gutters are 24 px a+ * side from 640 px (16 px on a phone), gaps 16 px (12 px on a phone).+ */+export function rowSizes(count: number, { layout = "centred", cap, maxColumns = 4 }: { layout?: RowLayout; cap?: number; maxColumns?: 2 | 4 } = {}): string {+ if (count === 1) return "(min-width: 392px) 360px, calc(100vw - 32px)";+ const cols = maxColumns === 2 ? 2 : Math.min(count, 4);+ const box = cap ?? (layout === "centred" ? (count === 2 ? 520 : count === 3 ? 760 : 1000) : undefined);+ const phone = "calc((100vw - 44px) / 2)";+ const fluid = `calc((100vw - ${48 + 16 * (cols - 1)}px) / ${cols})`;+ if (!box) return `(min-width: 640px) ${fluid}, ${phone}`;+ return `(min-width: ${box + 48}px) ${Math.round((box - 16 * (cols - 1)) / cols)}px, (min-width: 640px) ${fluid}, ${phone}`;+}+/** The row's heading ("Start from an example", "More to try"): a section title on the cards' left edge. */export const ROW_HEADING = "mb-4 text-left text-[15px] leading-6 font-medium text-foreground";diff --git a/src/components/genjutsu/genjutsu-studio.tsx b/src/components/genjutsu/genjutsu-studio.tsxindex 6b53fdc7..c7a3caeb 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} layout="column" maxColumns={2} className="mx-auto mt-12 max-w-[640px]" />}+ {examples && !clip && !run && (visitor || (history.isSuccess && !history.data.length)) && <ExampleRow row={examples} layout="column" maxColumns={2} maxWidth={640} className="mt-12" />}{run && (<RunPaneldiff --git a/src/components/layers/projects-view.tsx b/src/components/layers/projects-view.tsxindex a255848b..3c46949a 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} layout="column" className="mx-auto mt-12 max-w-[820px]" />}+ {examples && (visitor || (projects.isSuccess && !items.length)) && <ExampleRow row={examples} layout="column" maxWidth={820} className="mt-12" />}<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 2c33b3f4..91fe049e 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} layout="column" className="mx-auto mt-12 max-w-[880px]" />}+ {examples && (visitor || (results.isSuccess && !items.length)) && <ExampleRow row={examples} layout="column" maxWidth={880} className="mt-12" />}<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/studio/example-row.tsx b/src/components/studio/example-row.tsxindex 9ac3f5d0..541907ff 100644--- a/src/components/studio/example-row.tsx+++ b/src/components/studio/example-row.tsx@@ -8,9 +8,9 @@ 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. 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.+ * above the row (an upload box) gives the row that box's width (`layout="column"` and `maxWidth`), so the heading and+ * the cards line up with the box.*/-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} />;+export function ExampleRow(props: { row: ExampleRowData; layout?: RowLayout; maxColumns?: 2 | 4; maxWidth?: number; className?: string }) {+ return <Row {...props} />;}diff --git a/src/components/studio/studio-page.tsx b/src/components/studio/studio-page.tsxindex 6cc114df..4db58766 100644--- a/src/components/studio/studio-page.tsx+++ b/src/components/studio/studio-page.tsx@@ -377,6 +377,9 @@ 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";+/** The empty composer's width (its column's max-w-[760px]): the row's cards show at that width's share. */+const COMPOSER_WIDTH = 760;+/*** 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.@@ -411,7 +414,7 @@ function StudioExamples({ row, ready }: { row: ExampleRowData; ready: boolean })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} />+ <ExampleRow row={row} activeId={loader?.activeId} onPick={(c) => loader?.use(c)} layout="column" maxWidth={COMPOSER_WIDTH} className={UNDER_COMPOSER} /></Suspense>);}