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.

Galleries: Effects, Camera motions, Apps and the pickers list the featured presets first

Adarsh8b7c70b08ed4
diff --git a/src/app/(studio)/apps/page.tsx b/src/app/(studio)/apps/page.tsx
index fcb9a1d2..b7e096a1 100644
--- a/src/app/(studio)/apps/page.tsx
+++ b/src/app/(studio)/apps/page.tsx
@@ -3,6 +3,7 @@ import { PageHeader, PageShell } from "@/components/page-shell";
import { PresetGallery } from "@/components/preset-gallery";
import { APPS } from "@/lib/catalog";
import { toPresetCard } from "@/lib/preset-card-data";
+import { featuredGallery } from "@/lib/preset-featured";
export const metadata: Metadata = {
title: "Apps",
@@ -17,7 +18,7 @@ export default function Page() {
description="One-click tools for faces, products, styles and fun, each on an open-source ComfyUI workflow (and a cloud model where the studio has one)."
/>
{/* Slim card data only: no prompt templates, routes or LoRA URLs in the page payload. */}
- <PresetGallery presets={APPS.map(toPresetCard)} href="/apps/{id}" noun="apps" />
+ <PresetGallery {...featuredGallery(APPS.map(toPresetCard))} href="/apps/{id}" noun="apps" />
</PageShell>
);
}
diff --git a/src/app/(studio)/effects/page.tsx b/src/app/(studio)/effects/page.tsx
index 6cacb143..4ebbcde1 100644
--- a/src/app/(studio)/effects/page.tsx
+++ b/src/app/(studio)/effects/page.tsx
@@ -3,10 +3,11 @@ import { PageHeader, PageShell } from "@/components/page-shell";
import { PresetGallery } from "@/components/preset-gallery";
import { EFFECTS } from "@/lib/catalog";
import { toPresetCard } from "@/lib/preset-card-data";
+import { featuredGallery } from "@/lib/preset-featured";
export const metadata: Metadata = {
title: "Effects",
- description: "Explosions, transformations and viral VFX from one photo, made with open-source models on your own GPU.",
+ description: "Storms, transformations and cinematic VFX from one photo, made with open-source models on your own GPU.",
};
export default function Page() {
@@ -14,9 +15,9 @@ export default function Page() {
<PageShell>
<PageHeader
title="Effects"
- description="Explosions, transformations and viral VFX from one photo. Runs free on your GPU or in the cloud; color looks apply instantly in your browser."
+ description="Storms, transformations and cinematic VFX from one photo. Runs free on your GPU or in the cloud; color looks apply instantly in your browser."
/>
- <PresetGallery presets={EFFECTS.map(toPresetCard)} href="/video?preset={id}" noun="effects" />
+ <PresetGallery {...featuredGallery(EFFECTS.map(toPresetCard))} href="/video?preset={id}" noun="effects" />
</PageShell>
);
}
diff --git a/src/app/(studio)/motions/page.tsx b/src/app/(studio)/motions/page.tsx
index 468b9254..fab5bf44 100644
--- a/src/app/(studio)/motions/page.tsx
+++ b/src/app/(studio)/motions/page.tsx
@@ -3,6 +3,7 @@ import { PageHeader, PageShell } from "@/components/page-shell";
import { PresetGallery } from "@/components/preset-gallery";
import { MOTIONS } from "@/lib/catalog";
import { toPresetCard } from "@/lib/preset-card-data";
+import { featuredGallery } from "@/lib/preset-featured";
export const metadata: Metadata = {
title: "Camera motions",
@@ -16,7 +17,7 @@ export default function Page() {
title="Camera motions"
description="Pick a camera move and add a start frame. Fuobe DoP films it with a trained camera LoRA, free on your GPU or in the cloud."
/>
- <PresetGallery presets={MOTIONS.map(toPresetCard)} href="/video?preset={id}" noun="moves" />
+ <PresetGallery {...featuredGallery(MOTIONS.map(toPresetCard))} href="/video?preset={id}" noun="moves" />
</PageShell>
);
}
diff --git a/src/components/preset-gallery.tsx b/src/components/preset-gallery.tsx
index 8f826c42..d8df2268 100644
--- a/src/components/preset-gallery.tsx
+++ b/src/components/preset-gallery.tsx
@@ -11,7 +11,7 @@ import { useProgressive } from "@/components/use-progressive";
import { CardChip, badgeKey, parseBadgeKey } from "@/components/gpu/readiness-chip";
import { useGpuBadges } from "@/hooks/use-gpu";
import { useEngineMode, useViewer } from "@/lib/api";
-import { interleaveByCategory, matchesSearch, previewFlip, searchText, type PresetCardData } from "@/lib/preset-cards";
+import { matchesSearch, previewFlip, searchText, type PresetCardData } from "@/lib/preset-cards";
import { cn } from "@/lib/utils";
/** A tiny label shown on hover/focus (CSS only: a gallery has hundreds of these). */
@@ -205,10 +205,14 @@ const GRID = GALLERY_GRID;
export function PresetGallery({
presets,
+ categories,
href,
noun = "presets",
}: {
+ /** In the order the All view shows them (featuredGallery): a category or a search keeps it. */
presets: PresetCardData[];
+ /** The category tabs, in catalog order. */
+ categories: string[];
/** "{id}" is replaced with the preset id. */
href: string;
/** Plural shown in the result count, e.g. "effects". */
@@ -224,17 +228,13 @@ export function PresetGallery({
const query = useDeferredValue(q.trim().toLowerCase());
const index = useMemo(() => presets.map((p) => [p, searchText(p)] as const), [presets]);
- // Unfiltered, the categories take turns, so the first screen shows the range of the catalog.
- const mixed = useMemo(() => interleaveByCategory(presets), [presets]);
- const cats = useMemo(() => ["All", ...new Set(presets.map((p) => p.category))], [presets]);
+ const cats = useMemo(() => ["All", ...categories], [categories]);
const list = useMemo(
() =>
- cat === "All" && !query
- ? mixed.filter((p) => runsOn === "all" || p[runsOn])
- : index
- .filter(([p, text]) => (cat === "All" || p.category === cat) && (!query || matchesSearch(text, query)) && (runsOn === "all" || p[runsOn]))
- .map(([p]) => p),
- [index, mixed, cat, query, runsOn],
+ index
+ .filter(([p, text]) => (cat === "All" || p.category === cat) && (!query || matchesSearch(text, query)) && (runsOn === "all" || p[runsOn]))
+ .map(([p]) => p),
+ [index, cat, query, runsOn],
);
// Cards render a page at a time; a new filter starts from the first page again.
const { shown, hasMore, moreFrom, sentinel, left } = useProgressive(list.length, `${cat}|${query}|${runsOn}`, FIRST_PAGE, PAGE);
diff --git a/src/components/studio/preset-chips.tsx b/src/components/studio/preset-chips.tsx
index 8ba8965f..e3a34a0e 100644
--- a/src/components/studio/preset-chips.tsx
+++ b/src/components/studio/preset-chips.tsx
@@ -1,11 +1,12 @@
"use client";
import { Ban, Film, Loader2, Shuffle } from "lucide-react";
-import { useRef, useState } from "react";
+import { useMemo, useRef, useState } from "react";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { Slider } from "@/components/ui/slider";
import type { Preset } from "@/lib/catalog/types";
import { presetCover } from "@/lib/preset-covers";
+import { featuredAll } from "@/lib/preset-featured";
import { cn } from "@/lib/utils";
import { CoverScrollBox, CoverTile, usePickerPlayback } from "@/components/cover-tile";
import { PRESET_ICONS } from "@/components/preset-icons";
@@ -15,7 +16,8 @@ import { Chip, ClearableChip } from "./chip";
/**
* Camera-motion / effect picker and Mix. Loaded as its own chunk (with the preset icons and the slim
* covers map), and the preset lists come from the full catalog chunk, fetched on first hover or open.
- * A preset shows its real cover, as in the galleries, else its drawn tile.
+ * A preset shows its real cover, as in the galleries, else its drawn tile. Both list them as the galleries do
+ * (featuredAll), with the category tabs in catalog order.
*/
const tileClass = "group flex flex-col items-start gap-1 overflow-hidden rounded-lg p-1 text-left ring-primary transition hover:bg-accent";
@@ -44,7 +46,8 @@ function PresetTile({ preset: p, picked, onPick }: { preset: Preset; picked: boo
export function PresetGrid({ list, value, onPick, noneLabel }: { list: Preset[] | null; value?: string; onPick: (id: string | undefined) => void; noneLabel: string }) {
const [cat, setCat] = useState<string>("All");
const box = useRef<HTMLDivElement>(null);
- if (!list)
+ const ordered = useMemo(() => (list ? featuredAll(list) : null), [list]);
+ if (!list || !ordered)
return (
<div className="grid h-40 place-items-center" role="status" aria-label="Loading presets">
<Loader2 className="size-4 animate-spin text-muted-foreground" />
@@ -85,7 +88,7 @@ export function PresetGrid({ list, value, onPick, noneLabel }: { list: Preset[]
<span className="w-full truncate px-0.5 text-[12px] font-medium">{noneLabel}</span>
</button>
)}
- {list
+ {ordered
.filter((p) => cat === "All" || p.category === cat)
.map((p) => (
<PresetTile key={p.id} preset={p} picked={value === p.id} onPick={() => onPick(p.id)} />
@@ -179,7 +182,12 @@ export function MixChip({
const catalog = useCatalog();
const second = mix ? catalog.getPreset(mix.presetId) : undefined;
const cover = second && presetCover(second.id);
- const mixable = catalog.presets ? [...catalog.presets.motion, ...catalog.presets.effect].filter((p) => p.id !== primary.id && !p.inputs.some((i) => i.key === "endImage")) : null;
+ // Kept while the sliders move, so the picker isn't sorted again on every step.
+ const presets = catalog.presets;
+ const mixable = useMemo(
+ () => (presets ? [...presets.motion, ...presets.effect].filter((p) => p.id !== primary.id && !p.inputs.some((i) => i.key === "endImage")) : null),
+ [presets, primary.id],
+ );
return (
<ClearableChip active={!!mix} onClear={() => onChange({ mix: undefined })} clearLabel="Remove the mix">
<Popover
diff --git a/src/lib/preset-featured.ts b/src/lib/preset-featured.ts
new file mode 100644
index 00000000..9051d50e
--- /dev/null
+++ b/src/lib/preset-featured.ts
@@ -0,0 +1,164 @@
+/**
+ * Featured order for Home and the galleries (most featured first). Each kind lists its presets in bands, each band in
+ * order: a gallery's category shows them band by band, and its All view lets the categories take turns within each
+ * band, starting with the category of the band's first preset. The studio pickers use the same order. A preset not
+ * listed here (a new one) comes after the listed ones, in catalog order.
+ */
+import { interleaveByCategory } from "@/lib/preset-cards";
+
+const ORDER: Record<"app" | "motion" | "effect", string[]> = {
+ app: [
+ `
+ app-behind-the-scenes app-relight app-macroshot-product app-sketch-to-real app-age-shift app-makeup-studio
+ app-angles app-shots app-match-lighting app-match-colors app-product-shot app-bullet-time-scene
+ app-bullet-time-splash app-chameleon app-outfit-swap app-steal-the-look app-outfit-shot app-color-grading
+ app-video-face-swap app-video-background-remover app-breakdown
+ `,
+ `
+ app-hairstyle-try-on app-fuobe-angles app-product-placement app-link-to-video-ad app-style-snap app-urban-cuts
+ app-signboard app-j-poster app-giallo-horror app-face-swap app-character-swap app-headshot-generator
+ app-skin-enhancer app-zooms app-what-s-next app-packshot app-billboard-ad app-macro-scene app-asmr-promo
+ app-ai-stylist app-colorize app-bring-to-life app-dance app-clipcut app-sticker-match-cut app-latex app-sand-worm
+ app-storm-creature app-renaissance app-3d-rotation app-ghoulgao app-object-remover
+ `,
+ `
+ app-ai-influencer app-zoom-out app-product-360 app-poster app-magic-button app-virtual-try-on app-transitions
+ app-nano-strike app-burning-sunset app-upscale app-expression-edit app-commercial-faces app-expand-image
+ app-ad-creative app-bullet-time-white app-giant-product app-restore-photo app-talking-photo app-nano-theft
+ app-gtai app-melting-doodle app-remove-background app-change-background app-text-edit app-asmr-add-on
+ app-this-is-fine app-yes-kiss app-click-to-ad app-unboxing-video app-image-to-3d app-truck-ad app-fridge-ad
+ app-asmr-classic app-asmr-host app-outfit-vending app-style-transfer app-figurine app-recast app-hug app-3d-render
+ app-j-magazine app-mascot app-rap-god app-mugshot app-vectorize app-similarity-score
+ `,
+ `
+ app-3d-figure app-idol app-60s-cafe app-hook-frame app-kick-ad app-graffiti-ad app-volcano-ad app-simlife
+ app-pixel-game app-brick-cube app-micro-beasts app-paint-app app-social-media-icon app-victory-card app-comic-book
+ app-glitter-sticker app-mukbang app-roller-coaster app-banana-eating app-sticker-pack app-plushies
+ app-meme-generator app-cloud-surf app-game-dump app-japanese-show app-skibidi
+ `,
+ ],
+ motion: [
+ `
+ motion-dolly-in motion-crane-up motion-catwalk motion-classic-static motion-glam motion-slow-motion motion-zoom-in
+ motion-super-dolly-in motion-super-dolly-out motion-crash-zoom-in motion-crash-zoom-out motion-360-orbit
+ motion-arc-left motion-lazy-susan motion-crane-down motion-crane-over-the-head motion-dolly-left motion-tracking
+ motion-double-dolly motion-snorricam motion-fpv-drone motion-aerial-pullback motion-helicopter-shot
+ motion-car-grip motion-car-chasing motion-static motion-documentary-snap motion-dreamy-flow motion-epic-scale
+ motion-intimate-observer motion-one-take motion-silent-machine
+ `,
+ `
+ motion-rapid-zoom-out motion-eyes-in motion-mouth-in motion-arc-right motion-3d-rotation motion-pan
+ motion-action-run motion-drone-reveal motion-robo-arm motion-kiss motion-raw-chaos motion-zoom-out
+ motion-dolly-zoom-in motion-through-object-out motion-jib-up motion-overhead motion-buckle-up motion-truck-left
+ motion-bts motion-robot-arm motion-timelapse-glam motion-low-shutter motion-focus-change motion-roll-transition
+ motion-flying-cam-transition motion-boxing motion-ski-carving motion-snowboard-carving
+ `,
+ `
+ motion-zoom motion-dolly-out motion-rapid-zoom-in motion-through-object-in motion-earth-zoom-out motion-pan-left
+ motion-pan-right motion-dolly-right motion-whip-pan motion-incline motion-handheld motion-hero-cam
+ motion-timelapse-human motion-basketball-dunks motion-moonwalk-left motion-moonwalk-right motion-skateboard-ollie
+ motion-ski-powder motion-impossible-camera motion-bullet-time motion-lazy-orbit motion-jib-down
+ motion-pedestal-down motion-tilt-up motion-truck-right motion-dutch-angle motion-pov motion-head-tracking
+ motion-object-pov motion-road-rush motion-flying motion-general motion-timelapse-landscape motion-skate-cruise
+ motion-skateboard-glide motion-snowboard-powder motion-dolly-zoom-out motion-downhill-pov motion-hyperlapse
+ motion-baseball-kick motion-eating-zoom motion-wiggle motion-timelapse motion-face-punch
+ `,
+ `
+ motion-tilt-down motion-yoyo-zoom motion-rap-flex motion-fisheye
+ `,
+ ],
+ effect: [
+ `
+ effect-sand-storm effect-outfit-switch effect-wind-to-face effect-levitation effect-nature-bloom effect-lens-flare
+ effect-dirty-lens effect-train-rush effect-exploded-view effect-display-transition effect-splash-transition
+ effect-pearl-earring effect-blue-depth effect-magazine effect-film-colors effect-black-gloss effect-crimson-vigil
+ effect-bleached-warm effect-cold-steel
+ `,
+ `
+ effect-invisible effect-shadow-smoke effect-car-drive effect-color-rain effect-seamless-transition
+ effect-smash-and-grab effect-architecture-wave effect-broken-mirror effect-marble effect-modern effect-silhouette
+ effect-contre-jour effect-disintegration effect-set-on-fire effect-water-splash effect-flood
+ effect-turn-into-statue effect-diamond effect-black-tears effect-datamosh effect-paparazzi effect-northern-lights
+ effect-pool-jump effect-raven-transition effect-ballet effect-hair-style effect-column-wipe effect-studio-slide
+ effect-cutout effect-boarding-pass effect-floating-fall effect-stop-world effect-agamemnon effect-acid
+ effect-bubbles effect-canvas effect-comic effect-fragments effect-multiverse effect-ocean effect-origami
+ effect-particles effect-bleach-bypass effect-teal-orange-epic
+ `,
+ `
+ effect-ice-rose effect-medusa-gorgona effect-bloom-mouth effect-floral-eyes effect-sakura-petals
+ effect-tiny-planet effect-beach-ride effect-dream-date effect-flashback effect-red-carpet effect-trucksition
+ effect-lacewalker effect-lidar-transition effect-pigeons effect-monet-muse effect-cold-vision effect-lsd
+ effect-lava effect-layer-mixed-media effect-noir effect-overexposed effect-random-glow effect-vintage
+ effect-nostalgic-blue effect-classic-bw effect-freezing effect-air-bending effect-agent-reveal effect-point-cloud
+ effect-paint-splash effect-glow-trace effect-deflate effect-earth-zoom-out effect-helicopter-escape
+ effect-live-concert effect-mystification effect-morning-routine effect-static-posing effect-yacht
+ effect-hole-transition effect-frozen-in-motion effect-superstar effect-moonwalk effect-akrill effect-cannabis
+ effect-paper effect-toxic effect-tracking effect-ultraviolet effect-practicals effect-window effect-overhead-fall
+ effect-soft-palette effect-hyper-neon effect-sodium-decay effect-glowshift effect-objects-around
+ effect-turning-metal effect-cyborg effect-glitch effect-crush effect-giant effect-beast-appearance
+ effect-motor-ride effect-sunglasses effect-jump-transition effect-melt-transition effect-wild-ride
+ effect-fairytale-castle effect-hand-paint effect-sketch effect-soft-cross effect-naturalistic-clean effect-polygon
+ effect-garden-bloom effect-jelly-drift effect-skin-surge effect-super-fast-run effect-giant-people
+ effect-boiling-point effect-firework effect-tattoo-animation effect-fix-and-pose effect-handheld-run
+ effect-outfit-check effect-peak-moment effect-plate-check effect-sand-cut effect-selfie effect-selfie-outfit
+ effect-hand-transition effect-smoke-transition effect-street-colossus effect-world-morphing effect-mighty-fighter
+ effect-skatedog effect-dolphin-ride effect-palette effect-two-color effect-windows effect-candy-pink
+ effect-lime-jam
+ `,
+ `
+ effect-building-explosion effect-car-explosion effect-head-off effect-water-element effect-morphskin
+ effect-melting effect-glowing-fish effect-x-ray effect-atomic effect-attack-of-clones effect-clothes-rain
+ effect-selfception effect-act-natural effect-vanish effect-flash-comic effect-overtime effect-powder-explosion
+ effect-earth-wave effect-water-bending effect-duplicate effect-innerlight effect-luminous-gaze effect-hero-flight
+ effect-animalization effect-gas-transformation effect-floating-fish effect-pixelated-face effect-cakeify
+ effect-push-to-glass effect-cotton-cloud effect-drunk-master effect-explosion effect-group-photo
+ effect-plasma-explosion effect-saint-glow effect-balloon effect-high-flip effect-clones effect-infinite-clones
+ effect-lens-crack effect-portal effect-wireframe effect-visor-x effect-squish effect-aquarium effect-crying
+ effect-fairies-around effect-monstrosity effect-spirit-animal effect-eating effect-happy effect-scrapbook-collage
+ effect-head-explosion effect-fire-breath effect-thunder-god effect-fire-element effect-firelava
+ effect-earth-element effect-soul-jump effect-i-can-fly effect-horror-face effect-censorship
+ effect-starship-troopers effect-wonderland effect-buddy effect-giant-grab effect-money-rain effect-oni-mask
+ effect-happy-mode effect-angry-mode effect-selfie-posing effect-flame-transition effect-burning-man
+ effect-fallen-angel effect-cyclope effect-flame-on effect-clone-explosion effect-angel-wings effect-super-saiyan
+ effect-werewolf effect-gorilla-transfer effect-tentacles effect-spiders-from-mouth effect-inflate effect-muscle-up
+ effect-look-boom effect-pizza-fall effect-shocked effect-turning-monkey effect-monster-dab
+ `,
+ ],
+};
+
+/** Each kind's bands, first to last, as lists of ids. */
+export const FEATURED = Object.fromEntries(
+ Object.entries(ORDER).map(([kind, bands]) => [kind, bands.map((b) => b.split(/\s+/).filter(Boolean))]),
+) as Record<keyof typeof ORDER, string[][]>;
+
+/** How many bands there are; an id not listed takes the one after them. */
+export const FEATURED_BANDS = Math.max(...Object.values(FEATURED).map((b) => b.length));
+
+const RANK = new Map(Object.values(FEATURED).flatMap((bands) => bands.flatMap((ids, band) => ids.map((id, at) => [id, { band, at }] as const))));
+
+/** The id's band (0 is the first), or FEATURED_BANDS when it isn't listed. */
+export const featuredBand = (id: string) => RANK.get(id)?.band ?? FEATURED_BANDS;
+
+/** Featured first: by band, then place in it; ids not listed keep their order after the listed ones. */
+function featuredFirst<T extends { id: string }>(items: readonly T[]): T[] {
+ const key = (id: string) => RANK.get(id) ?? { band: FEATURED_BANDS, at: 0 };
+ return items
+ .map((it, i) => ({ it, i, k: key(it.id) }))
+ .sort((a, b) => a.k.band - b.k.band || a.k.at - b.k.at || a.i - b.i)
+ .map((x) => x.it);
+}
+
+/**
+ * A gallery's All view: band by band, the categories take turns (interleaveByCategory), each in featured order. In
+ * each band the categories go in the order of their first preset there, so the gallery opens on the band's first
+ * preset. Filtered to one category, it is that category's featured order.
+ */
+export function featuredAll<T extends { id: string; category: string }>(items: readonly T[]): T[] {
+ const ranked = featuredFirst(items);
+ return Array.from({ length: FEATURED_BANDS + 1 }, (_, band) => interleaveByCategory(ranked.filter((it) => featuredBand(it.id) === band))).flat();
+}
+
+/** A gallery's cards in featured order (featuredAll), with its category tabs in catalog order. */
+export function featuredGallery<T extends { id: string; category: string }>(items: readonly T[]) {
+ return { presets: featuredAll(items), categories: [...new Set(items.map((it) => it.category))] };
+}
diff --git a/tests/preset-featured.test.ts b/tests/preset-featured.test.ts
new file mode 100644
index 00000000..850517fe
--- /dev/null
+++ b/tests/preset-featured.test.ts
@@ -0,0 +1,91 @@
+import { createElement } from "react";
+import { renderToStaticMarkup } from "react-dom/server";
+import { describe, expect, it, vi } from "vitest";
+import { GALLERY_GRID } from "@/components/skeletons";
+import { PresetGrid } from "@/components/studio/preset-chips";
+import { APPS, EFFECTS, MOTIONS } from "@/lib/catalog";
+import type { Preset } from "@/lib/catalog/types";
+import { HOME_BEFORE_AFTER, HOME_EFFECTS, HOME_MOTIONS, HOME_REVEALS, HOME_WALL } from "@/lib/home-showcase";
+import { toPresetCard } from "@/lib/preset-card-data";
+import { FEATURED, FEATURED_BANDS, featuredAll, featuredBand, featuredGallery } from "@/lib/preset-featured";
+
+// home-showcase.ts reads next/cache, which only a Next render provides.
+vi.mock("next/cache", () => ({ cacheLife: () => {} }));
+
+/*
+ * The featured order (src/lib/preset-featured.ts) against the catalog, Home and the galleries: every preset is
+ * listed once, Home and each gallery open on the first band, and a gallery's tabs keep the catalog's order.
+ */
+
+const KINDS: [keyof typeof FEATURED, Preset[]][] = [
+ ["app", APPS],
+ ["motion", MOTIONS],
+ ["effect", EFFECTS],
+];
+/** The most cards a gallery row holds (GALLERY_GRID's widest grid). */
+const ROW = Math.max(...[...GALLERY_GRID.matchAll(/grid-cols-(\d+)/g)].map((m) => Number(m[1])));
+
+describe("Featured order", () => {
+ it("lists every preset of the catalog once, under its own kind", () => {
+ for (const [kind, list] of KINDS) {
+ const listed = FEATURED[kind].flat();
+ expect(new Set(listed).size, kind).toBe(listed.length);
+ expect([...listed].sort(), kind).toEqual(list.map((p) => p.id).sort());
+ for (const band of FEATURED[kind]) expect(band.length, kind).toBeGreaterThan(0);
+ }
+ });
+
+ it("puts a preset that isn't listed yet (a new one) after the listed ones, in catalog order", () => {
+ expect(featuredBand("effect-not-listed")).toBe(FEATURED_BANDS);
+ const last = FEATURED.effect.at(-1)!.at(-1)!;
+ const items = [
+ { id: "effect-new-b", category: "Elements" },
+ { id: last, category: "Elements" },
+ { id: "effect-new-a", category: "Elements" },
+ { id: FEATURED.effect[0][0], category: "Elements" },
+ ];
+ expect(featuredAll(items).map((i) => i.id)).toEqual([FEATURED.effect[0][0], last, "effect-new-b", "effect-new-a"]);
+ });
+
+ it("opens Home's wall and every row's first cards on the first band", () => {
+ const first = [...HOME_WALL, ...HOME_MOTIONS, ...HOME_REVEALS, ...HOME_BEFORE_AFTER, ...HOME_EFFECTS.slice(0, 6)].map((t) => t.id);
+ for (const id of first) expect(featuredBand(id), id).toBe(0);
+ });
+
+ it("opens each gallery on the first band, a category per card, with the tabs in catalog order", () => {
+ for (const [kind, list] of KINDS) {
+ const { presets, categories } = featuredGallery(list.map(toPresetCard));
+ expect(categories, kind).toEqual([...new Set(list.map((p) => p.category))]);
+ expect(presets.map((p) => p.id).sort(), kind).toEqual(list.map((p) => p.id).sort());
+ const row = presets.slice(0, ROW);
+ expect(row[0].id, kind).toBe(FEATURED[kind][0][0]);
+ for (const p of row) expect(featuredBand(p.id), p.id).toBe(0);
+ expect(new Set(row.map((p) => p.category)).size, kind).toBe(ROW);
+ // Band by band: no card of a later band before one of an earlier one.
+ const bands = presets.map((p) => featuredBand(p.id));
+ expect(bands, kind).toEqual([...bands].sort((a, b) => a - b));
+ // A category shows its presets in the listed order.
+ const place = new Map(FEATURED[kind].flat().map((id, i) => [id, i]));
+ for (const c of categories) {
+ const at = presets.filter((p) => p.category === c).map((p) => place.get(p.id)!);
+ expect(at, `${kind} ${c}`).toEqual([...at].sort((a, b) => a - b));
+ }
+ }
+ });
+
+ it("lists a studio picker's tiles in its gallery's order", () => {
+ // The tiles' names as the camera motion and effect pickers render them, after None (the tabs are buttons too).
+ const tileNames = (list: Preset[]) =>
+ renderToStaticMarkup(createElement(PresetGrid, { list, noneLabel: "None", onPick: () => {} }))
+ .split("<button")
+ .slice(1)
+ .filter((b) => !b.includes('role="tab"'))
+ .slice(1)
+ .map((b) => [...b.matchAll(/font-medium">([^<]*)<\/span>/g)].at(-1)![1].replaceAll("&amp;", "&").replaceAll("&#x27;", "'"));
+ for (const list of [MOTIONS, EFFECTS]) {
+ const gallery = featuredGallery(list.map(toPresetCard)).presets.map((p) => p.name);
+ expect(tileNames(list)).toEqual(gallery);
+ expect(gallery).not.toEqual(list.map((p) => p.name));
+ }
+ });
+});
diff --git a/tests/shell-logic.test.ts b/tests/shell-logic.test.ts
index 1e14bbd9..27196542 100644
--- a/tests/shell-logic.test.ts
+++ b/tests/shell-logic.test.ts
@@ -17,6 +17,7 @@ import {
type CameraMove,
} from "@/lib/preset-cards";
import { previewFor, toPresetCard } from "@/lib/preset-card-data";
+import { featuredGallery } from "@/lib/preset-featured";
import {
autoplays,
browserPlaybackEnv,
@@ -579,8 +580,9 @@ describe("gallery variety at rest", () => {
{ id: "c2", category: "C" },
];
expect(interleaveByCategory(items).map((i) => i.id)).toEqual(["a1", "b1", "c1", "a2", "c2", "a3"]);
- // The first row of /effects no longer shows one category's near-identical cards.
- const firstRow = interleaveByCategory(EFFECTS.map(toPresetCard)).slice(0, 5);
+ // The first row of /effects (its featured order, which takes turns the same way) shows five categories, not one
+ // category's near-identical cards.
+ const firstRow = featuredGallery(EFFECTS.map(toPresetCard)).presets.slice(0, 5);
expect(new Set(firstRow.map((c) => c.category)).size).toBe(5);
expect(new Set(firstRow.map((c) => c.preview.fx)).size).toBeGreaterThanOrEqual(4);
});