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
Studios: template and style tiles show their real cover when they have one
Adarsh08efe7797f9a
diff --git a/src/components/canvas/canvas-list.tsx b/src/components/canvas/canvas-list.tsxindex 60d7672c..87124dd4 100644--- a/src/components/canvas/canvas-list.tsx+++ b/src/components/canvas/canvas-list.tsx@@ -15,11 +15,13 @@ import { Skeleton } from "@/components/ui/skeleton";import { EngineSwitch } from "@/components/studio/engine-switch";import { PageShell } from "@/components/page-shell";import { SelfHostNote } from "@/components/self-host-note";+import { CoverArt, CoverImg, useCoverPlayback } from "@/components/template-cover";import { useEngine, useIsVisitor } from "@/lib/api";// Types only: the catalog (models, templates) stays on the server; the page passes slim template cards.import type { CanvasNodeType, CanvasSummary, Outline } from "@/lib/catalog/canvas";import type { Engine } from "@/lib/catalog/types";import { timeAgo } from "@/lib/format";+import { templateCover } from "@/lib/template-covers";import { cn } from "@/lib/utils";import { toastError } from "@/lib/refusals";import { NodeIcon } from "./canvas-context";@@ -153,16 +155,40 @@ const GROUP_NOTES: Record<string, (visitor: boolean) => string> = {};/** onUse: none for a guest or an account (a canvas is saved to the owner's library: the page says so once). */-function TemplateCard({ t, engine, onUse, busy }: { t: TemplateCardData; engine: Engine; onUse?: () => void; busy: boolean }) {+export function TemplateCard({ t, engine, onUse, busy }: { t: TemplateCardData; engine: Engine; onUse?: () => void; busy: boolean }) {const { outline, models } = t.byEngine[engine];+ // Its real cover when it has one (what it makes: a still, a clip, or its frames side by side), with the board in+ // miniature over a corner; else the board alone.+ const cover = templateCover("canvas", t.id);+ const { ref, playing, asked, handlers } = useCoverPlayback<HTMLElement>(`canvas/${t.id}`, cover);return (- <article className="flex min-w-0 flex-col overflow-hidden rounded-xl border bg-card">- <div className="relative aspect-[16/9] bg-muted/50" style={{ background: `linear-gradient(135deg, oklch(0.62 0.12 ${t.hue} / 0.14), transparent 70%)` }}>- <Schematic outline={outline} className="p-4" />- <span className="absolute top-3 left-3 grid size-8 place-items-center rounded-lg bg-background/90 text-foreground shadow-soft">- <NodeIcon name={t.icon} className="size-4" />- </span>- </div>+ <article ref={ref} {...handlers} className="flex min-w-0 flex-col overflow-hidden rounded-xl border bg-card">+ {cover ? (+ <div className="relative aspect-[16/9] overflow-hidden bg-muted">+ {cover.frames.length > 1 ? (+ <div className="absolute inset-0 grid auto-cols-fr grid-flow-col gap-0.5">+ {cover.frames.map((f) => (+ <CoverImg key={f.src} frame={f} sizes="(max-width: 640px) 34vw, 125px" />+ ))}+ </div>+ ) : (+ <CoverArt cover={cover} sizes="(max-width: 640px) 100vw, 370px" playing={playing} asked={asked} />+ )}+ <span className="pointer-events-none absolute right-2.5 bottom-2.5 h-[36%] w-[32%] overflow-hidden rounded-lg bg-background/80 shadow-soft backdrop-blur">+ <Schematic outline={outline} className="p-1.5" />+ </span>+ <span className="absolute top-3 left-3 grid size-8 place-items-center rounded-lg bg-background/90 text-foreground shadow-soft">+ <NodeIcon name={t.icon} className="size-4" />+ </span>+ </div>+ ) : (+ <div className="relative aspect-[16/9] bg-muted/50" style={{ background: `linear-gradient(135deg, oklch(0.62 0.12 ${t.hue} / 0.14), transparent 70%)` }}>+ <Schematic outline={outline} className="p-4" />+ <span className="absolute top-3 left-3 grid size-8 place-items-center rounded-lg bg-background/90 text-foreground shadow-soft">+ <NodeIcon name={t.icon} className="size-4" />+ </span>+ </div>+ )}<div className="flex flex-1 flex-col gap-2 p-3.5"><div><h3 className="text-[14px] font-medium">{t.name}</h3>diff --git a/src/components/content-factory/parts.tsx b/src/components/content-factory/parts.tsxindex 13915476..fe701da6 100644--- a/src/components/content-factory/parts.tsx+++ b/src/components/content-factory/parts.tsx@@ -9,6 +9,7 @@ import { Button } from "@/components/ui/button";import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog";import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";import { StyleArt } from "@/components/faceless/style-art";+import { CoverArt, useCoverPlayback } from "@/components/template-cover";import { usd } from "@/components/faceless/controls";import { radioKeys, radioTab } from "@/components/studio/radio-keys";import {@@ -26,6 +27,7 @@ import { formatLength } from "@/lib/catalog/faceless";import type { Engine } from "@/lib/catalog/types";import { useLikelyVisitor } from "@/lib/api";import { copyText } from "@/lib/clipboard";+import { templateCover } from "@/lib/template-covers";import { cn } from "@/lib/utils";import { claudePrompt, type SeriesAsk } from "./hooks";@@ -77,7 +79,7 @@ export function ReferenceCard({<video src={`${reference.url}#t=0.5`} muted playsInline preload="metadata" className="relative size-full object-cover" aria-hidden /></>) : (- <StyleArt styleId={styleId} />+ <StyleArt styleId={styleId} sizes="56px" />)}{reading && (<span className="absolute inset-0 grid place-items-center bg-black/35 text-white">@@ -227,44 +229,55 @@ export function PresetGrid({ value, onPick }: { value: string | null; onPick: (pconst picked = PRESETS.some((p) => p.id === value);return (<div role="radiogroup" aria-label="Preset styles" onKeyDown={radioKeys} className="grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4">- {PRESETS.map((p, i) => {- const on = value === p.id;- return (- <button- key={p.id}- type="button"- role="radio"- aria-checked={on}- tabIndex={radioTab(picked ? on : i === 0)}- onClick={() => onPick(p)}- className={cn(- "group/preset relative min-w-0 overflow-hidden rounded-2xl border bg-background text-left transition-[box-shadow,border-color] outline-none focus-visible:ring-2 focus-visible:ring-ring",- on ? "border-primary ring-2 ring-brand-faint" : "hover:border-border-strong",- )}- >- <div className="relative aspect-[4/3] w-full overflow-hidden">- <StyleArt styleId={p.brief.styleId} className="transition-transform duration-300 ease-move group-hover/preset:scale-[1.04]" />- <span className="absolute bottom-2 left-2 rounded-full bg-black/50 px-2 py-0.5 text-[11px] font-medium text-white backdrop-blur">{p.brief.aspect === "9:16" ? "Vertical" : "Horizontal"}</span>- {on && (- <span className="absolute top-2 right-2 grid size-6 place-items-center rounded-full bg-primary text-primary-foreground shadow-soft">- <Check className="size-3.5" />- </span>- )}- </div>- <div className="p-3">- <p className="line-clamp-2 text-[14px] leading-tight font-medium" title={p.name}>- {p.name}- </p>- <p className="mt-0.5 line-clamp-2 text-[12px] leading-snug text-muted-foreground">{p.tagline}</p>- <p className="mt-2 text-[12px] font-medium text-brand-text">{on ? "In use" : "Use as reference"}</p>- </div>- </button>- );- })}+ {PRESETS.map((p, i) => (+ <PresetTile key={p.id} p={p} on={value === p.id} tabStop={picked ? value === p.id : i === 0} onPick={onPick} />+ ))}</div>);}+/** A trending style: its real cover when it has one (a clip plays as the gallery cards' do), else its style's picture. */+export function PresetTile({ p, on, tabStop, onPick }: { p: StylePreset; on: boolean; tabStop: boolean; onPick: (p: StylePreset) => void }) {+ const cover = templateCover("content-factory", p.id);+ const { ref, playing, asked, handlers } = useCoverPlayback<HTMLButtonElement>(`content-factory/${p.id}`, cover);+ return (+ <button+ ref={ref}+ type="button"+ role="radio"+ aria-checked={on}+ tabIndex={radioTab(tabStop)}+ {...handlers}+ onClick={() => onPick(p)}+ className={cn(+ "group/preset relative min-w-0 overflow-hidden rounded-2xl border bg-background text-left transition-[box-shadow,border-color] outline-none focus-visible:ring-2 focus-visible:ring-ring",+ on ? "border-primary ring-2 ring-brand-faint" : "hover:border-border-strong",+ )}+ >+ <div className="relative aspect-[4/3] w-full overflow-hidden">+ {cover ? (+ <CoverArt cover={cover} sizes="(max-width: 640px) 50vw, 280px" playing={playing} asked={asked} />+ ) : (+ <StyleArt styleId={p.brief.styleId} className="transition-transform duration-300 ease-move group-hover/preset:scale-[1.04]" />+ )}+ <span className="absolute bottom-2 left-2 rounded-full bg-black/50 px-2 py-0.5 text-[11px] font-medium text-white backdrop-blur">{p.brief.aspect === "9:16" ? "Vertical" : "Horizontal"}</span>+ {on && (+ <span className="absolute top-2 right-2 grid size-6 place-items-center rounded-full bg-primary text-primary-foreground shadow-soft">+ <Check className="size-3.5" />+ </span>+ )}+ </div>+ <div className="p-3">+ <p className="line-clamp-2 text-[14px] leading-tight font-medium" title={p.name}>+ {p.name}+ </p>+ <p className="mt-0.5 line-clamp-2 text-[12px] leading-snug text-muted-foreground">{p.tagline}</p>+ <p className="mt-2 text-[12px] font-medium text-brand-text">{on ? "In use" : "Use as reference"}</p>+ </div>+ </button>+ );+}+// ---------------------------------------------------------------------------// The pricediff --git a/src/components/explainer/explainer-studio.tsx b/src/components/explainer/explainer-studio.tsxindex 505edc40..2a1d5aec 100644--- a/src/components/explainer/explainer-studio.tsx+++ b/src/components/explainer/explainer-studio.tsx@@ -272,7 +272,7 @@ export function ExplainerStudio({ picker }: { picker: PickerData }) {<p className="px-1 text-[11px] font-semibold tracking-[0.14em] text-muted-foreground uppercase">Fuobe Explainer</p><div className="mt-2 flex items-center gap-3 rounded-2xl bg-muted/60 p-2"><div className="h-14 w-24 shrink-0 overflow-hidden rounded-xl">- <StyleArt styleId={settings.styleId} />+ <StyleArt styleId={settings.styleId} sizes="96px" /></div><div className="min-w-0 flex-1"><p className="line-clamp-2 text-[14px] leading-tight font-medium" title={style.name}>diff --git a/src/components/faceless/style-art.tsx b/src/components/faceless/style-art.tsxindex 4ced0c33..35c36b4a 100644--- a/src/components/faceless/style-art.tsx+++ b/src/components/faceless/style-art.tsx@@ -3,13 +3,15 @@import { Check } from "lucide-react";import { memo, useId } from "react";import { radioKeys, radioTab } from "@/components/studio/radio-keys";+import { CoverImg } from "@/components/template-cover";import { getStyle, type VisualStyle } from "@/lib/catalog/faceless";+import { templateCover } from "@/lib/template-covers";import { cn } from "@/lib/utils";/**- * A small procedural picture of each visual style (no generated samples needed): a motif per family —- * cutouts and labels, line drawings, paper layers, 3D spheres, watercolour blooms, flat shapes, pixels,- * clay — tinted with the style's hue.+ * A small picture of each visual style: its real cover when it has one (templateCover, a frame made in that style),+ * else a procedural one (no generated samples needed): a motif per family — cutouts and labels, line drawings,+ * paper layers, 3D spheres, watercolour blooms, flat shapes, pixels, clay — tinted with the style's hue.*/type Motif = "graphics" | "lines" | "sketch" | "paper" | "collage" | "fold" | "solid3d" | "figure" | "mix" | "paint" | "flat" | "pixel" | "clay" | "toy" | "iso" | "poly";@@ -255,11 +257,14 @@ function Motif({ style, u }: { style: VisualStyle; u: string }) {}}-export const StyleArt = memo(function StyleArt({ styleId, className }: { styleId: string; className?: string }) {+/** `sizes`: how wide a real cover shows, so a small picture gets its 320 px copy. */+export const StyleArt = memo(function StyleArt({ styleId, className, sizes = "(max-width: 640px) 50vw, 280px" }: { styleId: string; className?: string; sizes?: string }) {const style = getStyle(styleId);const h = style.hue;// Gradient and filter ids are document-wide: each picture gets its own.const u = useId().replace(/[^a-zA-Z0-9_-]/g, "");+ const cover = templateCover("explainer", style.id);+ if (cover) return <CoverImg frame={cover.frames[0]} sizes={sizes} className={className} />;return (<svg viewBox="0 0 160 100" preserveAspectRatio="xMidYMid slice" className={cn("size-full", className)} aria-hidden><defs>diff --git a/src/components/fashion/template-preview.tsx b/src/components/fashion/template-preview.tsxindex 57b5b023..5c73b097 100644--- a/src/components/fashion/template-preview.tsx+++ b/src/components/fashion/template-preview.tsx@@ -2,7 +2,9 @@import { ChevronLeft, ChevronRight } from "lucide-react";import { useState } from "react";+import { CoverImg } from "@/components/template-cover";import type { FashionTemplate } from "@/lib/catalog/packs";+import { templateCover } from "@/lib/template-covers";import { cn } from "@/lib/utils";/** A fashion figure (long coat, legs, head) as one path in a 60×70 box; `pose` shifts the stance. */@@ -86,25 +88,41 @@ const SCENES: Record<string, (slide: number) => React.ReactNode> = {),};-/** A template's drawn preview: three framings in a carousel (arrows on hover, dots below). */+/**+ * A template's preview: three framings in a carousel (arrows on hover, dots below). The framings are its real cover's+ * slides when it has one (templateCover; only the slide in view loads), else drawn.+ */export function TemplatePreview({ t, className }: { t: Pick<FashionTemplate, "id" | "name">; className?: string }) {const [slide, setSlide] = useState(0);+ const cover = templateCover("fashion", t.id);+ const n = cover ? cover.frames.length : 3;+ const at = slide % n;const scene = SCENES[t.id] ?? SCENES["light-blue-studio"];const arrow = "absolute top-1/2 grid size-7 -translate-y-1/2 place-items-center rounded-full bg-background/85 text-foreground opacity-0 shadow-soft transition outline-none group-hover/tpl:opacity-100 focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/50";return (<span className={cn("group/tpl relative block overflow-hidden", className)}>- <svg viewBox="0 0 60 70" preserveAspectRatio="xMidYMid slice" role="img" aria-label={`${t.name} preview ${slide + 1} of 3`} className="size-full">- {scene(slide)}- </svg>- <button type="button" aria-label="Previous preview" onClick={(e) => (e.stopPropagation(), setSlide((s) => (s + 2) % 3))} className={cn(arrow, "left-1.5")}>- <ChevronLeft className="size-4" />- </button>- <button type="button" aria-label="Next preview" onClick={(e) => (e.stopPropagation(), setSlide((s) => (s + 1) % 3))} className={cn(arrow, "right-1.5")}>- <ChevronRight className="size-4" />- </button>- <span className="absolute inset-x-0 bottom-2 flex justify-center gap-1">- {[0, 1, 2].map((i) => (- <span key={i} className={cn("size-1.5 rounded-full bg-white/60", i === slide && "bg-white")} />+ {cover ? (+ <span role="img" aria-label={`${t.name} preview ${at + 1} of ${n}`} className="block size-full bg-muted">+ <CoverImg key={at} frame={cover.frames[at]} sizes="(max-width: 1024px) 50vw, 370px" />+ </span>+ ) : (+ <svg viewBox="0 0 60 70" preserveAspectRatio="xMidYMid slice" role="img" aria-label={`${t.name} preview ${at + 1} of 3`} className="size-full">+ {scene(at)}+ </svg>+ )}+ {n > 1 && (+ <>+ <button type="button" aria-label="Previous preview" onClick={(e) => (e.stopPropagation(), setSlide((s) => (s + n - 1) % n))} className={cn(arrow, "left-1.5")}>+ <ChevronLeft className="size-4" />+ </button>+ <button type="button" aria-label="Next preview" onClick={(e) => (e.stopPropagation(), setSlide((s) => (s + 1) % n))} className={cn(arrow, "right-1.5")}>+ <ChevronRight className="size-4" />+ </button>+ </>+ )}+ <span className={cn("absolute inset-x-0 bottom-2 flex justify-center gap-1", n < 2 && "hidden")}>+ {Array.from({ length: n }, (_, i) => (+ <span key={i} className={cn("size-1.5 rounded-full bg-white/60", i === at && "bg-white")} />))}</span></span>diff --git a/src/components/marketing/marketing-studio.tsx b/src/components/marketing/marketing-studio.tsxindex e99b7441..05347c44 100644--- a/src/components/marketing/marketing-studio.tsx+++ b/src/components/marketing/marketing-studio.tsx@@ -21,6 +21,7 @@ import { cn } from "@/lib/utils";import { addRuns, send, useBrands, useEstimate } from "./hooks";import type { MarketingRun } from "@/lib/catalog/marketing";import { toastError } from "@/lib/refusals";+import { templateCover } from "@/lib/template-covers";import type { ModelInfo } from "./model-info";import { AvatarSlot, HookPicker, ProductSlot, SettingPicker, VoiceControl, type ProductChoice } from "./pickers";import { RunsList } from "./runs";@@ -449,7 +450,7 @@ export function MarketingStudio({ models }: { models: Record<string, ModelInfo>{template && (<div className="relative flex h-14 shrink-0 items-center gap-2 rounded-xl bg-muted py-1 pr-7 pl-1"><div className="h-12 w-9 overflow-hidden rounded-lg">- <TemplatePreview id={template.id} look={template.look} />+ <TemplatePreview id={template.id} look={template.look} cover={templateCover("marketing", template.id)} sizes="36px" /></div><div className="min-w-0"><p className="max-w-32 truncate text-[12px] font-medium">{template.name}</p>diff --git a/src/components/marketing/template-gallery.tsx b/src/components/marketing/template-gallery.tsxindex d92e25dd..3e7ff8b3 100644--- a/src/components/marketing/template-gallery.tsx+++ b/src/components/marketing/template-gallery.tsx@@ -3,24 +3,31 @@import { Play, Search } from "lucide-react";import { useDeferredValue, useMemo, useState } from "react";import { useEdgeFade } from "@/components/studio/use-edge-fade";+import { useCoverPlayback } from "@/components/template-cover";import { CATEGORIES, FORMATS, interleaved, templatesFor, type MarketingCategory, type MarketingTemplate } from "@/lib/catalog/marketing";+import { templateCover } from "@/lib/template-covers";import { cn } from "@/lib/utils";import { TemplatePreview } from "./template-preview";export type MediaFilter = "all" | "image" | "video";-function TemplateCard({ t, selected, onPick }: { t: MarketingTemplate; selected: boolean; onPick: (t: MarketingTemplate) => void }) {+export function TemplateCard({ t, selected, onPick }: { t: MarketingTemplate; selected: boolean; onPick: (t: MarketingTemplate) => void }) {const f = FORMATS[t.format];const video = f.kind === "video";+ // Its real cover when it has one (a clip plays as the gallery cards' do), else its drawn preview.+ const cover = templateCover("marketing", t.id);+ const { ref, playing, asked, handlers } = useCoverPlayback<HTMLButtonElement>(`marketing/${t.id}`, cover);return (<button+ ref={ref}type="button"+ {...handlers}onClick={() => onPick(t)}aria-pressed={selected}className={cn("group/tpl min-w-0 rounded-2xl text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", selected && "ring-2 ring-primary ring-offset-2 ring-offset-background")}><div className="relative aspect-[3/4] overflow-hidden rounded-2xl bg-muted transition-transform duration-300 ease-move group-hover/tpl:scale-[1.015]">- <TemplatePreview id={t.id} look={t.look} video={video} />+ <TemplatePreview id={t.id} look={t.look} video={video} cover={cover} playing={playing} asked={asked} sizes="(max-width: 640px) 50vw, 220px" /><span className="absolute top-2 left-2 rounded-full bg-black/45 px-2 py-0.5 text-[11px] font-medium text-white backdrop-blur">{f.cardLabel}</span>{video && (<span className="absolute top-2 right-2 grid size-6 place-items-center rounded-full bg-black/45 text-white backdrop-blur" aria-hidden>diff --git a/src/components/marketing/template-preview.tsx b/src/components/marketing/template-preview.tsxindex 393e99cb..0010afad 100644--- a/src/components/marketing/template-preview.tsx+++ b/src/components/marketing/template-preview.tsx@@ -1,7 +1,9 @@"use client";import { memo } from "react";+import { CoverArt } from "@/components/template-cover";import type { PreviewScene, TemplateLook } from "@/lib/catalog/marketing";+import type { TemplateCover } from "@/lib/template-covers";import { cn } from "@/lib/utils";/**@@ -369,7 +371,36 @@ function Scene({ scene, id, look, W, H, video }: { scene: PreviewScene; id: stri}}-export const TemplatePreview = memo(function TemplatePreview({ id, look, video, className }: { id: string; look: TemplateLook; video?: boolean; className?: string }) {+/**+ * A template's preview: its real cover when it has one (`cover`, templateCover: `playing` runs its clip), else the+ * drawn one. `sizes` is how wide the cover shows, so a small tile gets the 320 px copy.+ */+export const TemplatePreview = memo(function TemplatePreview({+ id,+ look,+ video,+ className,+ cover,+ playing,+ asked,+ sizes = "220px",+}: {+ id: string;+ look: TemplateLook;+ video?: boolean;+ className?: string;+ cover?: TemplateCover;+ playing?: boolean;+ asked?: boolean;+ sizes?: string;+}) {+ if (cover) {+ return (+ <div className={cn("relative size-full overflow-hidden", className)}>+ <CoverArt cover={cover} sizes={sizes} playing={playing} asked={asked} />+ </div>+ );+ }const W = 240;const H = 320;const h1 = look.hue;diff --git a/src/components/photodump/covers.tsx b/src/components/photodump/covers.tsxindex 4690d123..2c5fdfc9 100644--- a/src/components/photodump/covers.tsx+++ b/src/components/photodump/covers.tsx@@ -1,6 +1,8 @@"use client";+import { CoverImg } from "@/components/template-cover";import { hueOf, type CoverTone } from "@/lib/catalog/packs";+import { templateCover } from "@/lib/template-covers";import { cn } from "@/lib/utils";/** A fine noise layer (film grain) drawn by the browser, no image file. */@@ -45,8 +47,8 @@ export function DrawnTile({ hue, tone, k = 0, className, children }: { hue: numb/*** A drawn pack cover (Fuobe ships no copies of Higgsfield's sample photos): a 2×2 contact sheet in the- * pack's own hue and treatment (flash, film, gels…), its name and photo count. User packs show their- * reference photos.+ * pack's own hue and treatment (flash, film, gels…), its name and photo count. A built-in pack with a+ * real cover (templateCover) shows its frames in the cells instead, and user packs their reference photos.*/export function PackCover({id,@@ -68,6 +70,7 @@ export function PackCover({tone?: CoverTone;}) {const h = hue ?? hueOf(id);+ const cells = refs ? undefined : templateCover("photodump", id)?.frames;return (<span className={cn("relative block overflow-hidden bg-muted", className)}><span className="grid size-full grid-cols-2 grid-rows-2 gap-0.5">@@ -75,6 +78,8 @@ export function PackCover({refs?.[i] ? (// eslint-disable-next-line @next/next/no-img-element<img key={i} src={refs[i]} alt="" loading="lazy" className="size-full object-cover" />+ ) : cells?.[i] ? (+ <CoverImg key={i} frame={cells[i]} sizes={bare ? "28px" : "(max-width: 640px) 25vw, 110px"} />) : (<DrawnTile key={i} hue={(h + [0, 18, -16, 34][i] + 360) % 360} tone={tone} k={i} className="size-full" />),diff --git a/src/components/shorts/preset-card.tsx b/src/components/shorts/preset-card.tsxindex 3dbe3d9b..0a393c19 100644--- a/src/components/shorts/preset-card.tsx+++ b/src/components/shorts/preset-card.tsx@@ -3,13 +3,14 @@import { Check, Pencil, Plus } from "lucide-react";import { memo } from "react";import { PresetPreview, usePreviewPlayback } from "@/components/preset-preview";-import type { PresetPreview as Preview } from "@/lib/preset-cards";+import { isCover, type PresetPreview as Preview } from "@/lib/preset-cards";import { cn } from "@/lib/utils";import { LookMotif } from "./look-motif";/**- * A selectable look card (Shorts Studio and Mixed Media): the procedural preview from the- * galleries (plays on hover or focus; on phones, by itself while in view), name and one line.+ * A selectable look card (Shorts Studio and Mixed Media): the look's real cover when it has one (a still, or a+ * clip that plays as the galleries' do), else the procedural preview from the galleries (plays on hover or focus;+ * on phones, by itself while in view) with the look's motif, then its name and one line.*/export const LookCard = memo(function LookCard({id,@@ -30,7 +31,8 @@ export const LookCard = memo(function LookCard({onSelect: (id: string) => void;badge?: string;}) {- const { ref, playing, handlers } = usePreviewPlayback<HTMLButtonElement>(id, preview);+ const { ref, playing, asked, handlers } = usePreviewPlayback<HTMLButtonElement>(id, preview);+ const real = !!preview.video || isCover(preview);return (<buttonref={ref}@@ -45,9 +47,9 @@ export const LookCard = memo(function LookCard({)}><div className={cn("relative aspect-[4/5] w-full overflow-hidden rounded-lg bg-muted ring-offset-2 ring-offset-background transition-shadow", selected && "ring-2 ring-primary")}>- <PresetPreview preview={preview} hue={hue} playing={playing} />- {/* The preset's own motif (lettering, scribbles, paper, a grid…), so similar treatments read apart. */}- <LookMotif id={id} hue={hue} />+ <PresetPreview preview={preview} hue={hue} playing={playing} asked={asked} sizes={real ? "(max-width: 640px) 50vw, 210px" : undefined} />+ {/* The preset's own motif (lettering, scribbles, paper, a grid…), so similar treatments read apart; a real cover shows the look itself. */}+ {!real && <LookMotif id={id} hue={hue} />}<span className="pointer-events-none absolute inset-x-0 bottom-0 z-[7] h-12 bg-gradient-to-t from-black/40 to-transparent" />{badge && <span className="absolute top-1.5 left-1.5 z-[8] rounded-[4px] bg-black/45 px-1.5 text-[10px] font-medium text-white backdrop-blur">{badge}</span>}{selected && (diff --git a/src/components/template-cover.tsx b/src/components/template-cover.tsxnew file mode 100644index 00000000..7b741a11--- /dev/null+++ b/src/components/template-cover.tsx@@ -0,0 +1,43 @@+"use client";++import { memo, useMemo } from "react";+import { PresetPreview, usePreviewPlayback } from "@/components/preset-preview";+import { NO_COVER, templatePreview, type CoverFrame, type TemplateCover } from "@/lib/template-covers";+import { cn } from "@/lib/utils";++/**+ * A template tile's playback, as the gallery cards': spread `handlers` on the card and give it `ref`. A clip plays by+ * itself while in view (a few at once, never with reduced motion or Save-Data), and on hover, focus or tap. A tile+ * without a clip (a still, or its drawn art) never plays: the hooks run all the same.+ */+export function useCoverPlayback<T extends HTMLElement>(key: string, cover: TemplateCover | undefined) {+ const preview = useMemo(() => (cover ? templatePreview(cover) : NO_COVER), [cover]);+ return usePreviewPlayback<T>(`tpl:${key}`, preview);+}++/**+ * A tile's real cover, filling the tile (which is `relative` and sized): its poster, lazy, its 320 px copy where the+ * tile is small (`sizes`), and its clip over it while it plays.+ */+export const CoverArt = memo(function CoverArt({ cover, sizes, playing = false, asked = false }: { cover: TemplateCover; sizes: string; playing?: boolean; asked?: boolean }) {+ const preview = useMemo(() => templatePreview(cover), [cover]);+ return <PresetPreview preview={preview} hue={0} playing={playing} asked={asked} sizes={sizes} />;+});++/** One still of a cover (a slide, a contact sheet's cell): lazy, its 320 px copy where it shows small. */+export function CoverImg({ frame, sizes, className }: { frame: CoverFrame; sizes: string; className?: string }) {+ return (+ // eslint-disable-next-line @next/next/no-img-element+ <img+ src={frame.src}+ srcSet={`${frame.thumb} 320w, ${frame.src} 768w`}+ sizes={sizes}+ alt=""+ loading="lazy"+ decoding="async"+ draggable={false}+ className={cn("size-full object-cover", className)}+ aria-hidden+ />+ );+}diff --git a/src/lib/catalog/mixed-media.ts b/src/lib/catalog/mixed-media.tsindex e29d368c..16f77070 100644--- a/src/lib/catalog/mixed-media.ts+++ b/src/lib/catalog/mixed-media.ts@@ -15,6 +15,7 @@* Research: docs/research/higgsfield-studios.md §3, docs/research/fuobe-originals-recipes-5.md §8 mixed-media.*/import { scenePoster, type PresetPreview, type PreviewFx, type PreviewScene } from "../preset-cards";+import { templateCover, templatePreview } from "../template-covers";import { planShorts, SHORTS_ORIGINAL, type PlanStep, type ShortsLook } from "./shorts";import type { Engine, GenerationRequest, LoraRef } from "./types";@@ -363,8 +364,10 @@ export function getMixedPreset(id: string): MixedPreset | undefined {return MIXED_PRESETS.find((p) => p.id === id);}-export function mixedPreview(p: Pick<MixedPreset, "scene" | "fx">): PresetPreview {- return { poster: scenePoster(p.scene), scene: p.scene, fx: p.fx };+/** A look's card preview: its real cover when it has one (templateCover), else drawn. */+export function mixedPreview(p: Pick<MixedPreset, "id" | "scene" | "fx">): PresetPreview {+ const cover = templateCover("mixed-media", p.id);+ return cover ? templatePreview(cover) : { poster: scenePoster(p.scene), scene: p.scene, fx: p.fx };}export function defaultValues(p: Pick<MixedPreset, "settings">): MixedValues {diff --git a/src/lib/catalog/shorts.ts b/src/lib/catalog/shorts.tsindex 62d08600..a9a236a2 100644--- a/src/lib/catalog/shorts.ts+++ b/src/lib/catalog/shorts.ts@@ -14,6 +14,7 @@* docs/research/fuobe-originals-recipes-5.md (studios[shorts]).*/import { scenePoster, type PresetPreview, type PreviewFx, type PreviewScene } from "../preset-cards";+import { templateCover, templatePreview } from "../template-covers";import type { ChainSlot, Engine, Generation, GenerationRequest } from "./types";// ---------------------------------------------------------------------------@@ -197,8 +198,10 @@ export function getShortsPreset(id: string): ShortsPreset | undefined {return SHORTS_PRESETS.find((p) => p.id === id);}-export function shortsPreview(p: Pick<ShortsPreset, "scene" | "fx">): PresetPreview {- return { poster: scenePoster(p.scene), scene: p.scene, fx: p.fx };+/** A look's card preview: its real cover when it has one (templateCover: the restyled frame, and its reveal), else drawn. */+export function shortsPreview(p: Pick<ShortsPreset, "id" | "scene" | "fx">): PresetPreview {+ const cover = templateCover("shorts", p.id);+ return cover ? templatePreview(cover) : { poster: scenePoster(p.scene), scene: p.scene, fx: p.fx };}/** A preset the user made from reference images (stored in shorts_presets). */diff --git a/tests/template-cover-tiles.test.ts b/tests/template-cover-tiles.test.tsnew file mode 100644index 00000000..a5fdbfe3--- /dev/null+++ b/tests/template-cover-tiles.test.ts@@ -0,0 +1,195 @@+import { createElement, type FC } from "react";+import { renderToStaticMarkup } from "react-dom/server";+import { describe, expect, it, vi } from "vitest";++/*+ * The template and style tiles pick their real cover when the manifest (template-covers.generated.ts) lists one, and+ * keep their drawn art when it doesn't. The manifest is mocked here: one listed tile per group, in each of its forms+ * (a still's version, a still and clip's versions, URLs with frames or a rest on the clip's last frame).+ */+vi.mock("@/lib/template-covers.generated", () => ({+ TEMPLATE_COVERS: {+ "marketing/ps-sunlit-plinth": "1a2b3c4d",+ "marketing/m2-sticker-pop": ["2b3c4d5e", "3c4d5e6f"],+ "fashion/ultra-bold": { poster: "/previews/templates/fashion/ultra-bold.jpg?v=4d5e6f70", frames: ["/previews/templates/fashion/ultra-bold-2.jpg?v=5e6f7081", "/previews/templates/fashion/ultra-bold-3.jpg?v=6f708192"] },+ "photodump/zen": {+ poster: "/previews/templates/photodump/zen.jpg?v=708192a3",+ frames: ["/previews/templates/photodump/zen-2.jpg?v=8192a3b4", "/previews/templates/photodump/zen-3.jpg?v=92a3b4c5", "/previews/templates/photodump/zen-4.jpg?v=a3b4c5d6"],+ },+ "shorts/shorts-warm-glow": { poster: "/previews/templates/shorts/shorts-warm-glow.jpg?v=b4c5d6e7", video: "/previews/templates/shorts/shorts-warm-glow.mp4?v=c5d6e7f8", at: 3.542 },+ "mixed-media/mixed-sketch": { poster: "/previews/presets/effect-sketch.jpg?v=d6e7f809" },+ "canvas/product-angles": {+ poster: "/previews/templates/canvas/product-angles.jpg?v=e7f8091a",+ frames: ["/previews/templates/canvas/product-angles-2.jpg?v=f8091a2b", "/previews/templates/canvas/product-angles-3.jpg?v=091a2b3c"],+ },+ "canvas/effect-chain-fallen-angel": { poster: "/previews/presets/effect-fallen-angel.jpg?v=1a2b3c4e", video: "/previews/presets/effect-fallen-angel.mp4?v=2b3c4d5f" },+ "content-factory/what-if": ["3c4d5e60", "4d5e6f71"],+ "explainer/pixel-art": "5e6f7082",+ },+}));++const { TemplateCard: MarketingCard } = await import("@/components/marketing/template-gallery");+const { TemplatePreview: FashionPreview } = await import("@/components/fashion/template-preview");+const { PackCover } = await import("@/components/photodump/covers");+const { LookCard } = await import("@/components/shorts/preset-card");+const { TemplateCard: CanvasCard } = await import("@/components/canvas/canvas-list");+const { PresetTile } = await import("@/components/content-factory/parts");+const { StyleArt } = await import("@/components/faceless/style-art");+const { TEMPLATES } = await import("@/lib/catalog/marketing");+const { FASHION, PACKS } = await import("@/lib/catalog/packs");+const { SHORTS_PRESETS, shortsPreview } = await import("@/lib/catalog/shorts");+const { MIXED_PRESETS, mixedPreview } = await import("@/lib/catalog/mixed-media");+const { CANVAS_TEMPLATES, outline } = await import("@/lib/catalog/canvas");+const { PRESETS } = await import("@/lib/catalog/content-factory");+const { templateCover } = await import("@/lib/template-covers");++/** A component's markup as the server renders it first (a memo component or a function). */+const html = (type: unknown, props: Record<string, unknown>) => renderToStaticMarkup(createElement(type as FC<Record<string, unknown>>, props));+/** Every cover URL in the markup carries its version. */+const unversioned = (markup: string) => [...markup.matchAll(/\/previews\/[^"\s,?]+(?:\?v=[0-9a-f]{8})?/g)].map((m) => m[0]).filter((u) => !/\?v=[0-9a-f]{8}$/.test(u));+const by = <T extends { id: string }>(list: T[], id: string) => list.find((x) => x.id === id)!;+const noop = () => {};++describe("Marketing Studio's template cards", () => {+ const card = (id: string) => html(MarketingCard, { t: by(TEMPLATES, id), selected: false, onPick: noop });++ it("show the template's cover, its 320 px copy where the card is small, lazily", () => {+ const h = card("ps-sunlit-plinth");+ expect(h).toContain('src="/previews/templates/marketing/ps-sunlit-plinth.jpg?v=1a2b3c4d"');+ expect(h).toContain("/previews/templates/marketing/thumbs/ps-sunlit-plinth.jpg?v=1a2b3c4d 320w");+ expect(h).toMatch(/<img[^>]*loading="lazy"/);+ expect(h).not.toContain("<svg viewBox=\"0 0 240 320\"");+ expect(unversioned(h)).toEqual([]);+ });++ it("never load a clip before it plays", () => {+ const h = card("m2-sticker-pop");+ expect(h).toContain('src="/previews/templates/marketing/m2-sticker-pop.jpg?v=2b3c4d5e"');+ expect(h).not.toContain("<video");+ expect(h).not.toContain(".mp4");+ });++ it("keep the drawn preview for a template without a cover", () => {+ const h = card("ps-ice-bath");+ expect(h).toContain('<svg viewBox="0 0 240 320"');+ expect(h).not.toContain("<img");+ });+});++describe("Fashion Factory's templates", () => {+ it("show the cover's slides in the carousel (the first one only, until picked), else the drawn framings", () => {+ const h = html(FashionPreview, { t: by(FASHION, "ultra-bold") });+ expect(h).toContain('src="/previews/templates/fashion/ultra-bold.jpg?v=4d5e6f70"');+ expect(h).not.toContain("ultra-bold-2.jpg");+ expect(h).toContain('aria-label="Ultra bold preview 1 of 3"');+ expect(h).toContain('aria-label="Next preview"');+ const drawn = html(FashionPreview, { t: by(FASHION, "red-room") });+ expect(drawn).toContain('<svg viewBox="0 0 60 70"');+ expect(drawn).not.toContain("<img");+ });+});++describe("Photodump packs", () => {+ it("fill the contact sheet with the cover's four frames (320 px copies), else the drawn tiles", () => {+ const zen = by(PACKS, "zen");+ const h = html(PackCover, { id: zen.id, name: zen.name, count: 10 });+ for (const f of ["zen.jpg?v=708192a3", "zen-2.jpg?v=8192a3b4", "zen-3.jpg?v=92a3b4c5", "zen-4.jpg?v=a3b4c5d6"]) expect(h).toContain(`/previews/templates/photodump/thumbs/${f} 320w`);+ expect(h).not.toContain("linear-gradient");+ expect(unversioned(h)).toEqual([]);+ const drawn = html(PackCover, { id: "sleepy-head", name: "Sleepy Head", count: 10 });+ expect(drawn).toContain("gradient(");+ expect(drawn).not.toContain("<img");+ // A user's pack shows its own photos, whatever its id.+ expect(html(PackCover, { id: "zen", name: "Mine", count: 3, refs: ["/media/a.jpg"] })).not.toContain("/previews/templates/");+ });+});++describe("Shorts and Mixed Media looks", () => {+ const look = (preview: ReturnType<typeof shortsPreview>, id: string) => html(LookCard, { id, name: id, description: "", preview, hue: 20, selected: false, onSelect: noop });++ it("show the look's cover without the drawn motif, resting on the reveal's last frame", () => {+ const p = shortsPreview(by(SHORTS_PRESETS, "shorts-warm-glow"));+ expect(p).toEqual({+ poster: "/previews/templates/shorts/shorts-warm-glow.jpg?v=b4c5d6e7",+ video: "/previews/templates/shorts/shorts-warm-glow.mp4?v=c5d6e7f8",+ rest: { src: "/previews/templates/shorts/shorts-warm-glow.jpg?v=b4c5d6e7", at: 3.542, from: 0 },+ scene: "product",+ });+ const h = look(p, "shorts-warm-glow");+ expect(h).toContain('src="/previews/templates/shorts/shorts-warm-glow.jpg?v=b4c5d6e7"');+ expect(h).not.toContain("<video");+ expect(h).not.toContain('class="pv"');+ });++ it("show a preset's cover where the look is that preset's restyle", () => {+ const h = look(mixedPreview(by(MIXED_PRESETS, "mixed-sketch")), "mixed-sketch");+ expect(h).toContain('src="/previews/presets/effect-sketch.jpg?v=d6e7f809"');+ });++ it("keep the drawn preview and motif without a cover", () => {+ const shorts = by(SHORTS_PRESETS, "shorts-bold-urban");+ const p = shortsPreview(shorts);+ expect(p).toEqual({ poster: expect.stringMatching(/^\/samples\/previews\//), scene: shorts.scene, fx: shorts.fx });+ expect(look(p, shorts.id)).toContain('class="pv"');+ const mixed = by(MIXED_PRESETS, "mixed-noir");+ expect(mixedPreview(mixed)).toEqual({ poster: expect.stringMatching(/^\/samples\/previews\//), scene: mixed.scene, fx: mixed.fx });+ });+});++describe("Canvas templates", () => {+ const card = (id: string) => {+ const t = by(CANVAS_TEMPLATES, id);+ const engine = { outline: outline(t.build("cloud")), models: [] };+ return html(CanvasCard, { t: { id: t.id, name: t.name, description: t.description, icon: t.icon, hue: t.hue, byEngine: { cloud: engine, open: engine } }, engine: "cloud", busy: false });+ };++ it("show the cover's frames side by side with the board in a corner, or its still and clip, else the board", () => {+ const angles = card("product-angles");+ for (const f of ["product-angles.jpg?v=e7f8091a", "product-angles-2.jpg?v=f8091a2b", "product-angles-3.jpg?v=091a2b3c"]) expect(angles).toContain(`src="/previews/templates/canvas/${f}"`);+ expect(angles).toContain("<svg viewBox=");+ const chain = card("effect-chain-fallen-angel");+ expect(chain).toContain('src="/previews/presets/effect-fallen-angel.jpg?v=1a2b3c4e"');+ expect(chain).not.toContain("<video");+ const drawn = card("script-film");+ expect(drawn).not.toContain("<img");+ expect(drawn).toContain("linear-gradient(135deg");+ });+});++describe("Content Factory's trending styles and the Explainer styles", () => {+ it("show the trending style's cover, else its style's picture", () => {+ const tile = (id: string) => html(PresetTile, { p: by(PRESETS, id), on: false, tabStop: true, onPick: noop });+ expect(tile("what-if")).toContain('src="/previews/templates/content-factory/what-if.jpg?v=3c4d5e60"');+ expect(tile("what-if")).not.toContain("<video");+ expect(tile("dark-history")).toContain('<svg viewBox="0 0 160 100"');+ });++ it("show the style's cover wherever its picture shows, else the drawn motif", () => {+ const h = html(StyleArt, { styleId: "pixel-art", sizes: "96px" });+ expect(h).toContain('src="/previews/templates/explainer/pixel-art.jpg?v=5e6f7082"');+ expect(h).toContain('sizes="96px"');+ expect(html(StyleArt, { styleId: "low-poly" })).toContain('<svg viewBox="0 0 160 100"');+ });+});++describe("templateCover", () => {+ it("reads every form of entry, with versions on every URL, and nothing for a tile that isn't listed", () => {+ expect(templateCover("marketing", "m2-sticker-pop")).toEqual({+ poster: "/previews/templates/marketing/m2-sticker-pop.jpg?v=2b3c4d5e",+ thumb: "/previews/templates/marketing/thumbs/m2-sticker-pop.jpg?v=2b3c4d5e",+ video: "/previews/templates/marketing/m2-sticker-pop.mp4?v=3c4d5e6f",+ frames: [{ src: "/previews/templates/marketing/m2-sticker-pop.jpg?v=2b3c4d5e", thumb: "/previews/templates/marketing/thumbs/m2-sticker-pop.jpg?v=2b3c4d5e" }],+ });+ expect(templateCover("fashion", "ultra-bold")?.frames.map((f) => f.thumb)).toEqual([+ "/previews/templates/fashion/thumbs/ultra-bold.jpg?v=4d5e6f70",+ "/previews/templates/fashion/thumbs/ultra-bold-2.jpg?v=5e6f7081",+ "/previews/templates/fashion/thumbs/ultra-bold-3.jpg?v=6f708192",+ ]);+ // Group by group: the same id in another group is another tile.+ expect(templateCover("canvas", "ps-sunlit-plinth")).toBeUndefined();+ expect(templateCover("marketing", undefined)).toBeUndefined();+ expect(templateCover("marketing", "toString")).toBeUndefined();+ // The same object each time, so a memo card doesn't render again for it.+ expect(templateCover("marketing", "ps-sunlit-plinth")).toBe(templateCover("marketing", "ps-sunlit-plinth"));+ });+});