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.

Fashion Factory and Photodump: the Continue bar never covers a card's name

Adarsh1c627e10a8bc
diff --git a/src/components/fashion/fashion-view.tsx b/src/components/fashion/fashion-view.tsx
index ca84760b..afae5792 100644
--- a/src/components/fashion/fashion-view.tsx
+++ b/src/components/fashion/fashion-view.tsx
@@ -11,6 +11,7 @@ import type { SlotValue } from "@/components/studio/media-slot";
import { radioKeys, radioTab } from "@/components/studio/radio-keys";
import { DownloadAll, ResultsGrid } from "@/components/photodump/results";
import { useRun, useRunPreview } from "@/components/photodump/hooks";
+import { barPlace, CLEAR_OF_BAR, showPicked } from "@/components/photodump/clear-of-bar";
import { RunLine, Steps } from "@/components/photodump/steps";
import { CharacterPicker } from "@/components/photodump/subject";
import { UploadBox } from "@/components/photodump/upload-box";
@@ -21,7 +22,7 @@ import type { Generation } from "@/lib/catalog/types";
import { cn } from "@/lib/utils";
import { toastError } from "@/lib/refusals";
import { useStoredReducer } from "./stored";
-import { TemplatePreview } from "./template-preview";
+import { TemplatePreview, titleCase } from "./template-preview";
const LABELS = ["Select a template", "Character", "Generation", "Clothing", "Photoset"];
/**
@@ -131,9 +132,9 @@ export function FashionView() {
{FASHION.map((x) => {
const sel = x.id === s.templateId;
return (
- <div key={x.id} className="min-w-0">
+ <div key={x.id} data-picker-card className={cn("min-w-0", CLEAR_OF_BAR)}>
<div
- onClick={() => dispatch({ type: "template", id: x.id })}
+ onClick={(e) => (dispatch({ type: "template", id: x.id }), showPicked(e.currentTarget))}
className={cn("relative cursor-pointer overflow-hidden rounded-xl ring-offset-2 ring-offset-background", sel && "ring-3 ring-primary")}
>
<TemplatePreview t={x} className="aspect-[6/7]" />
@@ -142,10 +143,10 @@ export function FashionView() {
type="button"
role="radio"
aria-checked={sel}
- onClick={() => dispatch({ type: "template", id: x.id })}
- className="mt-1.5 block w-full rounded px-0.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/50"
+ onClick={(e) => (dispatch({ type: "template", id: x.id }), showPicked(e.currentTarget))}
+ className={cn("mt-1.5 block w-full rounded px-0.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/50", CLEAR_OF_BAR)}
>
- <span className="block text-[13px] font-semibold">{x.name.replace(/(^|[\s-])(\p{Ll})/gu, (_, a: string, c: string) => a + c.toUpperCase())}</span>
+ <span className="block text-[13px] font-semibold">{titleCase(x.name)}</span>
<span className="block text-[12px] text-muted-foreground">
{x.shots} shots · {x.description}
</span>
@@ -154,7 +155,7 @@ export function FashionView() {
);
})}
</div>
- <div className="sticky bottom-[calc(var(--chrome-bottom)+0.75rem)] z-10 flex items-center justify-between gap-3 rounded-2xl border bg-background/95 p-3 shadow-normal backdrop-blur">
+ <div className={cn(barPlace(!!t), "z-10 flex items-center justify-between gap-3 rounded-2xl border bg-background/95 p-3 shadow-normal backdrop-blur")}>
<p className="min-w-0 truncate text-[13px]">{t ? <span className="font-medium">{t.name}</span> : <span className="text-muted-foreground">Pick a template</span>}</p>
<Button aria-disabled={!t} className={cn(!t && "opacity-50")} onClick={() => !block(fashionBlocker(s)) && dispatch({ type: "next" })}>
Continue <ArrowRight />
diff --git a/src/components/fashion/template-preview.tsx b/src/components/fashion/template-preview.tsx
index 5c73b097..15d1d224 100644
--- a/src/components/fashion/template-preview.tsx
+++ b/src/components/fashion/template-preview.tsx
@@ -7,97 +7,37 @@ 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. */
-function Figure({ x, y, s, pose = 0, fill }: { x: number; y: number; s: number; pose?: number; fill: string }) {
- const lean = pose * 2;
+/** A template's name as its card shows it: every word capitalised ("Ultra bold" becomes "Ultra Bold"). */
+export const titleCase = (name: string) => name.replace(/(^|[\s-])(\p{Ll})/gu, (_, a: string, c: string) => a + c.toUpperCase());
+
+/** A fine noise layer (film grain) drawn by the browser, no image file. */
+const GRAIN =
+ "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E\")";
+
+/** The branded tile a template shows until its cover is published: its two colours as soft studio light, and its name. */
+function BrandTile({ name, hues }: { name: string; hues: [number, number] }) {
+ const [a, b] = hues;
+ const background = `radial-gradient(70% 55% at 50% 30%, oklch(0.9 0.06 ${a} / 0.75), transparent 70%), linear-gradient(160deg, oklch(0.62 0.15 ${a}), oklch(0.3 0.09 ${b}))`;
return (
- <g transform={`translate(${x} ${y}) scale(${s})`}>
- <circle cx={lean * 0.4} cy={-29} r={3.6} fill={fill} />
- <path
- d={`M${-5 + lean * 0.3} -24 Q0 -26 ${5 + lean * 0.3} -24 L${7 + lean} -6 L${3.5 + lean} -6 L${3 + pose * 3} 14 L${1 + pose * 3} 14 L0 -2 L-1 14 L-3 14 L${-3.5 + lean * 0.2} -6 L${-7 + lean * 0.2} -6 Z`}
- fill={fill}
- />
- </g>
+ <span role="img" aria-label={`${name} preview`} className="relative block size-full" style={{ background }}>
+ <span aria-hidden className="absolute inset-0 opacity-30 mix-blend-overlay" style={{ backgroundImage: GRAIN }} />
+ <span aria-hidden className="absolute inset-0 bg-gradient-to-t from-black/45 via-transparent to-transparent" />
+ <span aria-hidden className="absolute inset-x-4 bottom-4 font-heading text-[clamp(1.25rem,2.6vw,2.25rem)] leading-[1.05] text-white drop-shadow-sm">
+ {name}
+ </span>
+ </span>
);
}
-const SCENES: Record<string, (slide: number) => React.ReactNode> = {
- "ultra-bold": (k) => (
- <>
- <rect width="60" height="70" fill="#1f3fd1" />
- <rect y="48" width="60" height="22" fill="#ffcc1a" />
- <rect x={k === 1 ? 6 : 38} y="34" width="14" height="14" fill="#e8331c" />
- <rect x={k === 2 ? 0 : 44} y="0" width="16" height="48" fill="#13a35a" opacity={k === 2 ? 1 : 0} />
- <Figure x={k === 1 ? 36 : 24} y={k === 2 ? 42 : 34} s={k === 2 ? 1.5 : 1} pose={k - 1} fill="#141414" />
- </>
- ),
- "blue-green-gradient": (k) => (
- <>
- <defs>
- <linearGradient id="bgg" x1="0" y1="0" x2="1" y2="1">
- <stop offset="0" stopColor="#2f6fe0" />
- <stop offset="1" stopColor="#2fd39a" />
- </linearGradient>
- </defs>
- <rect width="60" height="70" fill="url(#bgg)" />
- <ellipse cx="30" cy="62" rx="22" ry="3" fill="#000" opacity="0.12" />
- <Figure x={k === 1 ? 22 : 30} y={k === 2 ? 44 : 36} s={k === 2 ? 1.55 : 1.05} pose={k === 1 ? 1 : 0} fill="#f4f1ea" />
- </>
- ),
- "street-style-paparazzi": (k) => (
- <>
- <rect width="60" height="70" fill="#151821" />
- <rect y="50" width="60" height="20" fill="#262a33" />
- {[8, 22, 47].map((cx, i) => (
- <g key={cx} opacity={i === k ? 1 : 0.55}>
- <circle cx={cx} cy={12 + i * 6} r="5" fill="#fff" opacity="0.18" />
- <circle cx={cx} cy={12 + i * 6} r="1.6" fill="#fff" />
- </g>
- ))}
- <rect x="4" y="38" width="10" height="7" rx="1.5" fill="#e4b425" opacity={k === 1 ? 1 : 0.4} />
- <Figure x={k === 2 ? 34 : 28} y={k === 2 ? 40 : 37} s={k === 2 ? 1.4 : 1.05} pose={k === 0 ? 1 : -1} fill="#d9d4ca" />
- </>
- ),
- "view-from-the-top": (k) => (
- <>
- <rect width="60" height="70" fill="#d8cbb2" />
- {Array.from({ length: 7 }, (_, i) => (
- <rect key={i} x={i * 9 - (k % 2) * 4} y="0" width="4.5" height="70" fill="#bfae8d" opacity="0.7" />
- ))}
- <g transform={`rotate(${k === 0 ? -35 : k === 1 ? 20 : 0} 30 35)`}>
- <Figure x={30} y={40} s={k === 2 ? 0.7 : 1.1} pose={0.5} fill="#7a2f22" />
- </g>
- </>
- ),
- "light-blue-studio": (k) => (
- <>
- <rect width="60" height="70" fill="#cfe3f5" />
- <rect y="46" width="60" height="24" fill="#bcd6ee" />
- {k === 1 && <rect x="34" y="42" width="14" height="12" fill="#a9c9e8" />}
- <Figure x={k === 1 ? 26 : 30} y={k === 2 ? 44 : 36} s={k === 2 ? 1.5 : 1.05} pose={k - 1} fill="#2a3442" />
- </>
- ),
- "red-room": (k) => (
- <>
- <rect width="60" height="70" fill="#b5161b" />
- <rect y="48" width="60" height="22" fill="#8f0f13" />
- <rect x={k === 1 ? 36 : 6} y="22" width="16" height="26" fill="#9c1217" />
- {k === 2 && <rect x="36" y="36" width="16" height="14" rx="3" fill="#7a0b0f" />}
- <Figure x={k === 1 ? 22 : 30} y={k === 2 ? 42 : 36} s={k === 2 ? 1.35 : 1.05} pose={k === 1 ? 1 : -0.5} fill="#160406" />
- </>
- ),
-};
-
/**
- * 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.
+ * A template's preview: its real cover's slides in a carousel (arrows on hover, dots below; templateCover, and only the
+ * slide in view loads). Until its cover is published, a branded tile in the template's colours with its name.
*/
-export function TemplatePreview({ t, className }: { t: Pick<FashionTemplate, "id" | "name">; className?: string }) {
+export function TemplatePreview({ t, className }: { t: Pick<FashionTemplate, "id" | "name" | "hues">; className?: string }) {
const [slide, setSlide] = useState(0);
const cover = templateCover("fashion", t.id);
- const n = cover ? cover.frames.length : 3;
+ const n = cover ? cover.frames.length : 1;
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)}>
@@ -106,9 +46,7 @@ export function TemplatePreview({ t, className }: { t: Pick<FashionTemplate, "id
<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>
+ <BrandTile name={titleCase(t.name)} hues={t.hues} />
)}
{n > 1 && (
<>
diff --git a/src/components/photodump/clear-of-bar.ts b/src/components/photodump/clear-of-bar.ts
new file mode 100644
index 00000000..a83801d7
--- /dev/null
+++ b/src/components/photodump/clear-of-bar.ts
@@ -0,0 +1,20 @@
+/**
+ * Picker cards and the Continue bar under a picker grid (Fashion Factory templates, Photodump packs).
+ *
+ * The bar is sticky only once something is picked; before that it sits after the grid, so it never covers a card's name
+ * on first view. A card keeps a bottom scroll margin the size of the bar (about 3.5rem tall, 0.75rem above the phone
+ * tabs), so picking it or tabbing to it scrolls the whole card, name included, above the bar.
+ */
+export const CLEAR_OF_BAR = "scroll-mb-[calc(var(--chrome-bottom)+5.5rem)]";
+
+/** The Continue bar's position: sticky above the phone tabs once `picked`, else in flow after the grid. */
+export const barPlace = (picked: boolean) => (picked ? "sticky bottom-[calc(var(--chrome-bottom)+0.75rem)]" : "relative");
+
+/** Scrolls a picked card (the element carrying CLEAR_OF_BAR) clear of the bar that shows once something is picked. */
+export function showPicked(el: Element | null | undefined) {
+ const card = el?.closest("[data-picker-card]");
+ if (!card) return;
+ const smooth = !window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
+ // After React has rendered the pick, so the bar is already sticky.
+ requestAnimationFrame(() => card.scrollIntoView({ block: "nearest", behavior: smooth ? "smooth" : "auto" }));
+}
diff --git a/src/components/photodump/photodump-view.tsx b/src/components/photodump/photodump-view.tsx
index c35a327b..95c75b1d 100644
--- a/src/components/photodump/photodump-view.tsx
+++ b/src/components/photodump/photodump-view.tsx
@@ -21,6 +21,7 @@ import { onAttr, TAB_PILL, TabRow } from "@/components/ui/tab-row";
import { linkTab, TabFromLink } from "@/components/nav/tab-from-link";
import { toastError } from "@/lib/refusals";
import { useAskFirst } from "./ask-first";
+import { barPlace, CLEAR_OF_BAR, showPicked } from "./clear-of-bar";
import { PackCover } from "./covers";
import { useOwnsElements, usePhotoCharacters, useRun, useRunPreview, usePackActions, useUserPacks } from "./hooks";
import { DownloadAll, ResultsGrid, runState } from "./results";
@@ -283,13 +284,13 @@ export function PhotodumpView() {
{shown.map((p) => {
const sel = p.id === packId;
return (
- <div key={p.id} className="group/pack relative min-w-0">
+ <div key={p.id} data-picker-card className={cn("group/pack relative min-w-0", CLEAR_OF_BAR)}>
<button
type="button"
aria-pressed={sel}
- onClick={() => setPackId(p.id)}
+ onClick={(e) => (setPackId(p.id), showPicked(e.currentTarget))}
onDoubleClick={() => (setPackId(p.id), go(1))}
- className={cn("block w-full overflow-hidden rounded-xl text-left outline-none focus-visible:ring-2 focus-visible:ring-ring", sel && "ring-3 ring-primary")}
+ className={cn("block w-full overflow-hidden rounded-xl text-left outline-none focus-visible:ring-2 focus-visible:ring-ring", CLEAR_OF_BAR, sel && "ring-3 ring-primary")}
>
<PackCover id={p.id} name={p.name} count={p.count} refs={p.refs} hue={p.hue} tone={p.tone} className="aspect-[3/4]" />
</button>
@@ -311,8 +312,8 @@ export function PhotodumpView() {
})}
</div>
{!shown.length && <p className="py-10 text-center text-[14px] text-muted-foreground">{tab === "mine" && !needle ? "No packs of your own yet — create one from your reference photos." : `No packs match “${q}”`}</p>}
- <div className="sticky bottom-[calc(var(--chrome-bottom)+0.75rem)] z-10 flex items-center justify-between gap-3 rounded-2xl border bg-background/95 p-3 shadow-normal backdrop-blur">
- <p className="min-w-0 truncate text-[13px]">{pack ? <><span className="font-medium">{pack.name}</span> · {pack.count} photos</> : <span className="text-muted-foreground">Pick a pack to continue</span>}</p>
+ <div className={cn(barPlace(!!pack), "z-10 flex items-center justify-between gap-3 rounded-2xl border bg-background/95 p-3 shadow-normal backdrop-blur")}>
+ <p className="min-w-0 truncate text-[13px]">{pack ?<><span className="font-medium">{pack.name}</span> · {pack.count} photos</> : <span className="text-muted-foreground">Pick a pack to continue</span>}</p>
<Button disabled={!pack} onClick={() => go(1)}>
Use this pack <ArrowRight />
</Button>
diff --git a/tests/template-cover-tiles.test.ts b/tests/template-cover-tiles.test.ts
index 0199fe1d..721de51c 100644
--- a/tests/template-cover-tiles.test.ts
+++ b/tests/template-cover-tiles.test.ts
@@ -115,15 +115,20 @@ describe("Click to Ad's styles", () => {
});
describe("Fashion Factory's templates", () => {
- it("show the cover's slides in the carousel (the first one only, until picked), else the drawn framings", () => {
+ it("show the cover's slides in the carousel (the first one only, until picked), else a branded tile with the name", () => {
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).toContain('aria-label="Red Room preview"');
+ expect(drawn).toContain(">Red Room</span>");
+ expect(drawn).toContain("gradient(");
+ // Never the old drawn figure, and no carousel for a tile with one face.
+ expect(drawn).not.toContain("<svg");
expect(drawn).not.toContain("<img");
+ expect(drawn).not.toContain('aria-label="Next preview"');
});
});