Skip to content
Python

Top-bar menus: hover Image, Video or Audio to see every app of that studio and its models

neuregex14bac3d46aeb
diff --git a/README.md b/README.md
index 2d54595..65bf99e 100644
--- a/README.md
+++ b/README.md
@@ -210,6 +210,8 @@ On Windows PowerShell, environment variables go before the command as `$env:FREE
`npm run serve` opens a studio laid out like the one it rebuilds:
- **Explore**: featured apps as video cards, the studios, and one lab example per app.
+- Pointing at **Image**, **Video** or **Audio** in the top bar opens a menu with every app of that studio, grouped as
+ in the studio, and a column with the open models behind them and how many apps use each.
- **Image** and **Audio**: prompt-first apps. Results fill the page and a floating bar holds the prompt, reference
images (click **+**, drop or paste them), one chip per setting, the number of generations and **Generate**, which shows
how long the lab example took on the GPU.
diff --git a/web/app.css b/web/app.css
index c7a3bc1..f81eed0 100644
--- a/web/app.css
+++ b/web/app.css
@@ -585,3 +585,37 @@ dl.vals dd { margin: 0; overflow-wrap: anywhere; }
.start-card .media > img, .start-card .media > video { width: 100%; height: 100%; object-fit: cover; }
.start-card .nm { padding: 0 12px; font-weight: 600; font-size: 14.5px; }
.start-card .dim { padding: 0 12px; font-size: 12.5px; color: var(--dim); }
+
+/* top-bar menus (menu.js): hover Image, Video or Audio for every app of that studio and the models behind them */
+.mm { position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin: 0 auto; width: min(1240px, calc(100vw - 24px)); z-index: 45;
+ max-height: calc(100vh - var(--top) - 22px); overflow: auto; overscroll-behavior: contain; background: #121214; border: 1px solid #26262b;
+ border-radius: 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, .65); animation: rise .14s var(--ease); }
+.mm[data-studio="audio"] { width: min(760px, calc(100vw - 24px)); }
+.mm-inner { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 12px 22px; padding: 18px 18px 14px; }
+.mm-audio { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
+.mm h4 { display: flex; align-items: baseline; gap: 8px; margin: 0 8px 10px; font-size: 12.5px; font-weight: 500; color: var(--dim); }
+.mm h4 .n { color: var(--faint); font-size: 12px; }
+.mm h5 { margin: 6px 8px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); }
+.mm-cols { columns: 3 230px; column-gap: 14px; }
+.mm-cols.one { columns: 1; }
+.mm-group { break-inside: avoid; padding-bottom: 12px; }
+.mm-models { border-left: 1px solid var(--line); padding-left: 18px; align-self: start; position: sticky; top: 0; }
+.mm-item { display: flex; align-items: center; gap: 11px; min-width: 0; padding: 6px 8px; border-radius: 10px; color: var(--ink); }
+.mm-item:hover, .mm-item:focus-visible { background: #1d1d21; }
+.mm-item[aria-current="page"] .nm { color: var(--accent); }
+.mm-thumb { display: grid; place-items: center; width: 38px; height: 38px; flex: none; overflow: hidden; border-radius: 9px; background: #1a1a1d;
+ box-shadow: inset 0 0 0 1px #27272c; color: var(--dim); font-size: 17px; }
+.mm-thumb img { width: 100%; height: 100%; object-fit: cover; }
+.mm-thumb.glyph { color: #d6d6db; }
+.mm-txt { display: grid; gap: 1px; min-width: 0; }
+.mm-item.model .mm-txt { flex: 1; }
+.mm-txt b { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13.5px; font-weight: 600; }
+.mm-txt .nm, .mm-txt small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.mm-txt small { font-size: 12px; color: var(--dim); }
+.mm .tag { height: 16px; padding: 0 5px; font-size: 9.5px; flex: none; }
+.mm-txt b .n { margin-left: auto; padding-left: 6px; font-size: 11.5px; font-weight: 500; color: var(--faint); flex: none; }
+@media (max-width: 1000px) {
+ .mm-inner, .mm-audio { grid-template-columns: minmax(0, 1fr); }
+ .mm-models { border-left: 0; border-top: 1px solid var(--line); padding: 14px 0 0; position: static; }
+}
+@media (max-width: 760px) { .mm { display: none; } }
diff --git a/web/js/catalog.js b/web/js/catalog.js
index a71fd29..76535a2 100644
--- a/web/js/catalog.js
+++ b/web/js/catalog.js
@@ -40,17 +40,56 @@ export function categoryOf(id) {
/** The video studio's three tabs, like a camera crew: shoot, fix, move. */
export const VIDEO_TABS = [
- { id: "create", apps: ["video", "effects", "morph", "video-t2v", "genjutsu", "speak", "talking", "dub", "transitions", "camera-moves"] },
- { id: "edit", apps: ["recast", "mixed-media", "reframe", "vfx-clean-plate", "vfx-day-to-night", "vfx-water", "sdr-hdr", "upscale-video", "smooth", "reshoot"] },
+ { id: "create", apps: ["video", "h3-video", "h3-photo", "effects", "morph", "video-t2v", "genjutsu", "speak", "talking", "dub", "transitions", "camera-moves"] },
+ { id: "edit", apps: ["recast", "mixed-media", "reframe", "extend-video", "vfx-clean-plate", "vfx-day-to-night", "vfx-water", "sdr-hdr", "upscale-video", "smooth", "reshoot", "video-remove-bg"] },
{ id: "motion", apps: ["motion-transfer", "camera-copy"] },
{ id: "templates", apps: ["behind-the-scenes", "asmr-product", "asmr-whisper", "asmr-host", "chameleon", "magic-button", "truck-ad", "kick-ad", "volcano-ad",
- "roller-coaster", "storm-creature", "cloud-surf", "mukbang", "melting-doodle", "rap-video", "idol"] },
+ "roller-coaster", "storm-creature", "cloud-surf", "mukbang", "melting-doodle", "rap-video", "idol", "bullet-time-scene", "bullet-time-white", "bullet-time-splash"] },
];
export const videoTabOf = (id) => VIDEO_TABS.find((tab) => tab.apps.includes(id))?.id ?? null;
/** Shown in the top bar next to the studios, like a store's front window. */
export const FEATURED = [{ id: "recast", tag: "featured" }, { id: "speak", tag: "new" }, { id: "relight", tag: null }];
+/** The open models behind the apps, for the top bar's menus. `file` is a piece of the model file's name: an app that
+ * downloads a matching file uses the model. `app` runs the model on its own. Order matters for modelOf(): an app is
+ * labelled with the first model it uses, so the video and audio models come before FLUX 3 Klein, which many video
+ * apps use only to prepare a frame. */
+export const MODELS = [
+ { name: "LTX-2.5 22B", file: "ltx-2.5-22b", app: "video", note: ["Image to video, IC-LoRAs and VFX", "Imagen a video, IC-LoRAs y VFX"] },
+ { name: "MiniMax H3", file: "minimax_h3_", app: "h3-video", note: ["Video with sound, extend, reshoot", "Video con sonido, extender y re-shoot"] },
+ { name: "Wan 2.1 I2V 14B", file: "wan2.1_i2v", app: "effects", note: ["24 effect LoRAs and Bullet Time", "24 LoRAs de efectos y Bullet Time"] },
+ { name: "Wan 2.2 Fun Camera", file: "wan2.2_fun_camera", app: "camera-moves", note: ["Camera moves", "Movimientos de cámara"] },
+ { name: "Wan Animate 2", file: "wan_animate", app: "motion-transfer", note: ["The motion of a driving clip", "El movimiento de otro clip"] },
+ { name: "SCAIL-2 + SAM 3.1", file: "SCAIL", app: "recast", note: ["Swap the actor of a clip", "Cambia al actor de un clip"] },
+ { name: "SeedVR2 3B", file: "seedvr2", app: "upscale-video", note: ["Video and image upscale", "Escalado de video y de imagen"] },
+ { name: "MiniMax Music 3", file: "minimax_music3", app: "music", note: ["Songs with lyrics", "Canciones con letra"] },
+ { name: "Stable Audio 3", file: "stable_audio_3", app: "sfx", note: ["Sound effects and instrumental music", "Efectos de sonido y música instrumental"] },
+ { name: "Qwen-Image-Edit 2509", file: "qwen_image_edit", app: "relight", note: ["Light, angles and the next shot", "Luz, ángulos y la siguiente toma"] },
+ { name: "Krea 2 Turbo", file: "krea2_turbo", app: "styles", note: ["Styles with Krea's LoRAs", "Estilos con los LoRAs de Krea"] },
+ { name: "MOSS-Image", file: "moss_image", app: "moss-image", note: ["Layout prompts", "Prompts con layout"] },
+ { name: "Z-Image Turbo", file: "z_image_turbo", app: "z-image", note: ["Fast drafts", "Borradores rápidos"] },
+ { name: "FLUX 3 Image Klein", file: "flux3-image-klein", app: "create-image", note: ["Text to image and every edit", "Texto a imagen y todas las ediciones"] },
+];
+export const usesModel = (app, m) => app.models.some((x) => x.name.includes(m.file));
+/** The model an app is built on, for a one-line label ("FLUX 3 Image Klein"); null for the model-free apps. */
+export function modelOf(app) {
+ return MODELS.find((m) => usesModel(app, m)) ?? null;
+}
+
+/** The apps a top-bar menu lists, grouped like the studio itself: the image apps by category, the video apps by tab. */
+export function menuGroups(studio) {
+ const inMenu = (a) => studio === "image" ? a.section === "image" && studioOf(a) !== "video" : studioOf(a) === studio;
+ const pick = (ids) => ids.map((id) => byId.get(id)).filter((a) => a && inMenu(a));
+ const groups = studio === "video" ? VIDEO_TABS.map((g) => ({ key: `vtab.${g.id}`, apps: pick(g.apps) }))
+ : studio === "image" ? CATEGORIES.map((g) => ({ key: `cat.${g.id}.t`, apps: pick(g.apps) }))
+ : [{ key: null, apps: apps.filter(inMenu) }];
+ const listed = new Set(groups.flatMap((g) => g.apps));
+ const rest = apps.filter((a) => inMenu(a) && !listed.has(a));
+ if (rest.length) groups.push({ key: "cat.more.t", apps: rest });
+ return groups.filter((g) => g.apps.length);
+}
+
/** Big cards on the Explore page, in this order when they have an example. */
// the hosted demo opens with these, each loaded with its lab example: quick first, then the big video models
export const START_HERE = ["face-swap", "morph", "mixed-media", "dub", "reshoot"];
@@ -128,6 +167,85 @@ const TAGLINES = {
morph: ["Fifteen transformations, your face", "Quince transformaciones, tu cara"],
music: ["Write a song", "Compón una canción"],
sfx: ["Sound for every scene", "Sonido para cada escena"],
+
+ "ai-influencer": ["A made-up influencer for your feed", "Un influencer inventado para tu feed"],
+ angles: ["The same scene from another angle", "La misma escena desde otro ángulo"],
+ "asmr-host": ["You hosting an ASMR studio", "Tú conduciendo un estudio de ASMR"],
+ "asmr-product": ["Your product in an ASMR clip", "Tu producto en un clip de ASMR"],
+ "asmr-whisper": ["You whispering in an ASMR clip", "Tú susurrando en un clip de ASMR"],
+ "behind-the-scenes": ["The camera pulls back to the film set", "La cámara se aleja y muestra el set"],
+ billboard: ["Your photo on a city billboard", "Tu foto en un espectacular"],
+ breakdown: ["Your subject taken apart and labeled", "Tu objeto desarmado y rotulado"],
+ "brick-toy": ["Rebuilt from plastic bricks", "Reconstruido con bloques de plástico"],
+ "bullet-time-scene": ["Freeze the moment, circle the camera", "Congela el momento y gira la cámara"],
+ "bullet-time-splash": ["Frozen water around your subject", "Agua congelada alrededor del sujeto"],
+ "bullet-time-white": ["Bullet time on a white backdrop", "Bullet time sobre fondo blanco"],
+ "burning-sunset": ["Your scene under a blazing sunset", "Tu escena bajo un atardecer intenso"],
+ "cafe-60s": ["You in a 1960s cafe", "Tú en un café de los años 60"],
+ chameleon: ["A chameleon in your product's colors", "Un camaleón del color de tu producto"],
+ "character-swap": ["Put another person in the scene", "Pon a otra persona en la escena"],
+ "cloud-surf": ["You surfing across pink clouds", "Tú surfeando sobre nubes rosas"],
+ "color-grade": ["Six color grades for a photo", "Seis gradaciones de color"],
+ "comic-book": ["Your photo as a comic panel", "Tu foto como viñeta de cómic"],
+ "commercial-faces": ["Campaign portraits of you", "Retratos de campaña tuyos"],
+ "create-image": ["Text to image with FLUX 3 Klein", "Texto a imagen con FLUX 3 Klein"],
+ "depth-map": ["Depth or normals from a photo", "Profundidad o normales de una foto"],
+ "edit-text": ["Change the text in an image", "Cambia el texto de una imagen"],
+ "expand-image": ["Grow a photo past its edges", "Extiende una foto más allá del borde"],
+ "extend-video": ["Continue a clip, sound included", "Continúa un clip, con sonido"],
+ "face-swap": ["The face from another photo", "La cara de otra foto"],
+ "fashion-factory": ["A catalog photo in a new garment", "Foto de catálogo con otra prenda"],
+ "figure-3d": ["You as a boxed collectible figure", "Tú como figura coleccionable"],
+ "fridge-ad": ["Your product in a display fridge", "Tu producto en un refrigerador"],
+ "game-styles": ["You in 12 video game styles", "Tú en 12 estilos de videojuego"],
+ giallo: ["A 1970s giallo film still", "Un fotograma de giallo de los 70"],
+ "giant-product": ["Your product as a city monument", "Tu producto gigante sobre la ciudad"],
+ "glitter-sticker": ["You as a glitter sticker", "Tú como sticker con brillos"],
+ "graffiti-ad": ["Your product as a graffiti mural", "Tu producto como mural de grafiti"],
+ "h3-photo": ["A photo to a clip with sound", "De foto a clip con sonido"],
+ "h3-video": ["A clip with sound from a prompt", "Un clip con sonido desde un prompt"],
+ headshot: ["A studio headshot from a selfie", "Headshot de estudio desde una selfie"],
+ idol: ["Your K-pop stage moment", "Tu momento de idol de K-pop"],
+ "image-effects": ["Ten effects for a photo", "Diez efectos para una foto"],
+ "j-magazine": ["You on a Japanese magazine cover", "Tú en portada de revista japonesa"],
+ "j-poster": ["A Japanese-style poster of you", "Un póster de estilo japonés tuyo"],
+ "japanese-show": ["You on a retro Japanese TV show", "Tú en un programa japonés retro"],
+ "kick-ad": ["Boxes knocked away from your product", "Cajas que vuelan junto a tu producto"],
+ "macro-product": ["A macro detail of your product", "Un detalle macro de tu producto"],
+ "macro-scene": ["Your product in a macro scene", "Tu producto en una escena macro"],
+ "magic-button": ["A glowing button changes the scene", "Un botón que cambia la escena"],
+ mascot: ["You in a mascot costume", "Tú con traje de mascota"],
+ "melting-doodle": ["Doodles melting down the frame", "Garabatos que se derriten"],
+ meme: ["A meme from a scene and two lines", "Un meme: una escena y dos textos"],
+ "micro-beasts": ["You among tiny animals", "Tú entre animales diminutos"],
+ "moss-image": ["Text to image with a layout", "Texto a imagen con layout"],
+ mukbang: ["You eating for the camera", "Tú comiendo para la cámara"],
+ mural: ["You on a street mural", "Tú en un mural callejero"],
+ "outfit-shot": ["A garment on a model, in studio", "Una prenda en modelo, en estudio"],
+ "outfit-swap": ["Wear someone else's outfit", "Ponte el outfit de otra persona"],
+ "outfit-vending": ["Your clothes in a vending machine", "Tu ropa en una máquina expendedora"],
+ packshot: ["The closing frame of an ad", "El cuadro final de un anuncio"],
+ "paint-app": ["Redrawn in a 90s paint program", "En un programa de dibujo de los 90"],
+ "pixel-game": ["Your scene as 16-bit pixel art", "Tu escena en pixel art de 16 bits"],
+ plushie: ["Remade as a plush toy", "Convertido en peluche"],
+ poster: ["A product photo to a poster", "De foto de producto a póster"],
+ "rap-video": ["You in a rap music video", "Tú en un video de rap"],
+ renaissance: ["You as a Renaissance painting", "Tú como pintura renacentista"],
+ "render-3d": ["A stylized 3D render", "Un render 3D estilizado"],
+ "roller-coaster": ["You on a roller coaster", "Tú en una montaña rusa"],
+ shots: ["Nine framings of one image", "Nueve encuadres de una imagen"],
+ "sketch-to-real": ["From a sketch to a photo", "De boceto a foto"],
+ "skin-enhancer": ["A natural skin retouch", "Retoque de piel natural"],
+ "storm-creature": ["A storm giant behind your scene", "Gigante de tormenta tras tu escena"],
+ "style-snap": ["You in a complete new outfit", "Tú con un outfit completo nuevo"],
+ "truck-ad": ["A toy truck with your product", "Camión de juguete con tu producto"],
+ "try-on": ["Try a garment on your photo", "Pruébate una prenda en tu foto"],
+ "ugc-shot": ["A casual phone photo of your product", "Una foto casual de tu producto"],
+ "victory-card": ["Your face on a winning card", "Tu cara en una carta ganadora"],
+ "video-remove-bg": ["Cut the subject out of a clip", "Recorta al sujeto de un clip"],
+ "volcano-ad": ["A volcano erupts behind your product", "Un volcán detrás de tu producto"],
+ "whats-next": ["The next shot of your scene", "La siguiente toma de tu escena"],
+ zooms: ["Zoom levels of one image", "Niveles de zoom de una imagen"],
};
export function tagline(app) {
const pair = TAGLINES[app.id];
diff --git a/web/js/i18n.js b/web/js/i18n.js
index 042c6a1..538fd91 100644
--- a/web/js/i18n.js
+++ b/web/js/i18n.js
@@ -6,6 +6,7 @@ import { store } from "./util.js";
const en = {
"nav.explore": "Explore", "nav.image": "Image", "nav.video": "Video", "nav.audio": "Audio", "nav.apps": "Apps", "nav.library": "Library",
"nav.vram": "VRAM map", "nav.create": "Create", "nav.lang": "Language",
+ "menu.features": "Features", "menu.models": "Models", "menu.used": "{n} apps", "menu.used1": "1 app",
"tag.featured": "Featured", "tag.new": "New", "tag.draft": "Draft", "tag.top": "Top",
"gpu.none": "No backend", "gpu.asleep": "GPU asleep", "gpu.waking": "Waking GPU · {s}s", "gpu.ready": "GPU ready", "gpu.failed": "Wake failed",
"gpu.pop.none": "Put the URL that `modal deploy infra/modal_app.py` printed in .env as COMFY_BASE_URL, then restart `npm run serve`.",
@@ -89,6 +90,7 @@ const en = {
const es = {
"nav.explore": "Explorar", "nav.image": "Imagen", "nav.video": "Video", "nav.audio": "Audio", "nav.apps": "Apps", "nav.library": "Biblioteca",
"nav.vram": "Mapa de VRAM", "nav.create": "Crear", "nav.lang": "Idioma",
+ "menu.features": "Funciones", "menu.models": "Modelos", "menu.used": "{n} apps", "menu.used1": "1 app",
"tag.featured": "Destacado", "tag.new": "Nuevo", "tag.draft": "Borrador", "tag.top": "Top",
"gpu.none": "Sin backend", "gpu.asleep": "GPU dormida", "gpu.waking": "Despertando GPU · {s}s", "gpu.ready": "GPU lista", "gpu.failed": "No despertó",
"gpu.pop.none": "Pon en .env, como COMFY_BASE_URL, la URL que imprimió `modal deploy infra/modal_app.py` y reinicia `npm run serve`.",
diff --git a/web/js/menu.js b/web/js/menu.js
new file mode 100644
index 0000000..d104341
--- /dev/null
+++ b/web/js/menu.js
@@ -0,0 +1,119 @@
+// The top bar's menus: hovering Image, Video or Audio opens a panel with every app of that studio, grouped like the
+// studio, and the open models behind them. A click on the link itself still opens the studio. Pointer only: on touch
+// screens the links behave as before, and phones use the menu button.
+import { el, icon } from "./util.js";
+import { t, lang } from "./i18n.js";
+import { apps, byId, FEATURED, MODELS, menuGroups, modelOf, usesModel, tagline } from "./catalog.js";
+
+const canHover = window.matchMedia?.("(hover: hover) and (pointer: fine)");
+const OPEN_MS = 90, CLOSE_MS = 180;
+
+function thumbOf(app) {
+ const ex = app.example;
+ const src = ex?.poster || (ex && ex.type !== "video" ? ex.card : null);
+ return el("span", { class: "mm-thumb" }, src
+ ? el("img", { src, alt: "", loading: "lazy", decoding: "async" })
+ : icon(app.section === "video" ? "video" : app.section === "audio" ? "audio" : "image"));
+}
+
+function tagOf(app) {
+ if (app.status === "draft") return el("span", { class: "tag ghost" }, t("tag.draft"));
+ const f = FEATURED.find((x) => x.id === app.id);
+ return f?.tag ? el("span", { class: `tag${f.tag === "new" ? "" : " violet"}` }, t(`tag.${f.tag}`)) : null;
+}
+
+const usedBy = (n) => t(n === 1 ? "menu.used1" : "menu.used", { n });
+
+function appItem(app) {
+ const model = modelOf(app);
+ const tip = [model?.name, app.higgsfield_feature ? `${t("how.equiv")}: ${app.higgsfield_feature}` : null].filter(Boolean).join(" · ");
+ const line = tagline(app);
+ return el("a", { class: "mm-item", href: `#/app/${app.id}`, role: "menuitem", title: tip || null },
+ thumbOf(app),
+ el("span", { class: "mm-txt" }, el("b", {}, el("span", { class: "nm" }, app.name), tagOf(app)),
+ el("small", {}, line !== app.name ? line : model?.name ?? "")));
+}
+
+function modelItem(m, menuApps, studio) {
+ const users = menuApps.filter((a) => usesModel(a, m));
+ // the model's own app, or the first app of this menu built on it (SeedVR2 in Image opens Upscale, not Upscale Video)
+ const target = users.includes(byId.get(m.app)) ? byId.get(m.app) : users[0];
+ return el("a", { class: "mm-item model", href: `#/app/${target.id}`, role: "menuitem" },
+ el("span", { class: "mm-thumb glyph" }, icon(studio === "video" ? "video" : studio === "audio" ? "audio" : "layers")),
+ el("span", { class: "mm-txt" }, el("b", {}, el("span", { class: "nm" }, m.name),
+ target.status === "draft" ? el("span", { class: "tag ghost" }, t("tag.draft")) : el("span", { class: "n" }, usedBy(users.length))),
+ el("small", {}, m.note[lang === "es" ? 1 : 0])));
+}
+
+function panelFor(studio) {
+ const groups = menuGroups(studio);
+ const menuApps = groups.flatMap((g) => g.apps);
+ const models = MODELS.map((m, i) => ({ m, i, n: menuApps.filter((a) => usesModel(a, m)).length }))
+ .filter((x) => x.n).sort((a, b) => b.n - a.n || a.i - b.i);
+ const feats = el("section", { class: "mm-feats" },
+ el("h4", {}, t("menu.features"), el("span", { class: "n" }, t("explore.apps", { n: menuApps.length }))),
+ el("div", { class: `mm-cols${groups.length === 1 ? " one" : ""}` }, ...groups.map((g) => el("div", { class: "mm-group", role: "group", "aria-label": g.key ? t(g.key) : null },
+ g.key ? el("h5", {}, t(g.key)) : null, ...g.apps.map(appItem)))));
+ const mods = el("section", { class: "mm-models" }, el("h4", {}, t("menu.models")), ...models.map(({ m }) => modelItem(m, menuApps, studio)));
+ return el("div", { class: `mm-inner mm-${studio}` }, feats, mods);
+}
+
+/** Wire the menus onto the studio links of a freshly built top bar. */
+export function attachMenus(bar, links) {
+ if (!canHover?.matches) return;
+ const panel = el("div", { class: "mm", role: "menu", hidden: true });
+ bar.append(panel);
+ const built = new Map();
+ let openKey = null, openTimer = null, closeTimer = null;
+
+ const close = () => {
+ clearTimeout(openTimer); clearTimeout(closeTimer);
+ if (!openKey) return;
+ links.get(openKey)?.setAttribute("aria-expanded", "false");
+ openKey = null;
+ panel.hidden = true;
+ };
+ const open = (key) => {
+ clearTimeout(openTimer); clearTimeout(closeTimer);
+ if (openKey === key) return;
+ if (openKey) links.get(openKey)?.setAttribute("aria-expanded", "false");
+ if (!built.has(key)) built.set(key, panelFor(key));
+ panel.replaceChildren(built.get(key));
+ panel.dataset.studio = key;
+ panel.hidden = false;
+ panel.scrollTop = 0;
+ for (const a of panel.querySelectorAll(".mm-item")) {
+ if (a.getAttribute("href") === location.hash) a.setAttribute("aria-current", "page"); else a.removeAttribute("aria-current");
+ }
+ openKey = key;
+ links.get(key).setAttribute("aria-expanded", "true");
+ };
+ const later = () => { clearTimeout(openTimer); clearTimeout(closeTimer); closeTimer = setTimeout(close, CLOSE_MS); };
+
+ for (const key of ["image", "video", "audio"]) {
+ const a = links.get(key);
+ if (!a || !apps.length) continue;
+ a.setAttribute("aria-haspopup", "true");
+ a.setAttribute("aria-expanded", "false");
+ a.addEventListener("pointerenter", () => {
+ clearTimeout(closeTimer);
+ clearTimeout(openTimer);
+ // moving from one open menu to the next swaps at once; the first one waits a beat so passing over the bar does not flash it
+ if (openKey) open(key); else openTimer = setTimeout(() => open(key), OPEN_MS);
+ });
+ a.addEventListener("pointerleave", later);
+ a.addEventListener("click", close);
+ a.addEventListener("keydown", (e) => {
+ if (e.key === "ArrowDown") { e.preventDefault(); open(key); panel.querySelector(".mm-item")?.focus(); }
+ });
+ }
+ panel.addEventListener("pointerenter", () => clearTimeout(closeTimer));
+ panel.addEventListener("pointerleave", later);
+ panel.addEventListener("click", (e) => { if (e.target.closest("a")) close(); });
+ panel.addEventListener("keydown", (e) => {
+ if (e.key === "Escape") { const k = openKey; close(); links.get(k)?.focus(); }
+ });
+ panel.addEventListener("focusout", (e) => { if (!panel.contains(e.relatedTarget) && ![...links.values()].includes(e.relatedTarget)) close(); });
+ window.addEventListener("hashchange", close);
+ window.addEventListener("blur", close);
+}
diff --git a/web/js/nav.js b/web/js/nav.js
index 682439f..04d16ef 100644
--- a/web/js/nav.js
+++ b/web/js/nav.js
@@ -1,8 +1,9 @@
-// The top bar: studios, featured apps, the VRAM map, language, and the GPU pill that tells
+// The top bar: studios (with a menu of their apps on hover, menu.js), featured apps, the VRAM map, language, and the GPU pill that tells
// whether the backend is warm (and wakes it on request; looking never starts it).
import { el, icon, logoMark, api, popover, closePopover, toast, live } from "./util.js";
import { t, lang, LANGS, setLang } from "./i18n.js";
import { byId, FEATURED } from "./catalog.js";
+import { attachMenus } from "./menu.js";
export const gpuState = { data: null, listeners: new Set() };
let pollTimer = null;
@@ -106,6 +107,7 @@ export function topbar({ onLang }) {
el("a", { class: "logo", href: "#/", "aria-label": "Freefield" }, logoMark(), el("span", { class: "word" }, "freefield")),
nav,
el("div", { class: "nav-right" }, vram, langBtn, gpuPill(), el("a", { class: "btn lime small cta", href: "#/image" }, icon("spark"), t("nav.create"))));
+ attachMenus(bar, links);
if (!pollTimer) pollGpu();
return {
node: bar,
diff --git a/web/js/views.js b/web/js/views.js
index 1324314..1c12b1b 100644
--- a/web/js/views.js
+++ b/web/js/views.js
@@ -1,7 +1,7 @@
// The pages that are not a workspace: Explore (home), Apps (the store), Library and the VRAM map.
import { el, icon, masonry } from "./util.js";
import { t } from "./i18n.js";
-import { apps, byId, CATEGORIES, HERO, START_HERE, hosted, tagline, iconOf, fitOf, categoryOf, studioOf } from "./catalog.js";
+import { apps, byId, CATEGORIES, HERO, START_HERE, hosted, tagline, iconOf, fitOf, categoryOf, studioOf, menuGroups } from "./catalog.js";
import { exampleItem, thumb, hoverPlay, optionTile } from "./media.js";
import { feed, feedView, hooks } from "./feed.js";
import { pickOption, recreate } from "./workspace.js";
@@ -48,7 +48,8 @@ export function exploreView() {
row.addEventListener("scroll", arrows, { passive: true });
requestAnimationFrame(arrows);
- const count = (studio) => apps.filter((a) => studioOf(a) === studio).length;
+ // the same apps the top bar's menu lists for that studio
+ const count = (studio) => menuGroups(studio).reduce((n, g) => n + g.apps.length, 0);
const tiles = [
["image", "image", "#/image", count("image")], ["video", "video", "#/video", count("video")], ["audio", "audio", "#/audio", count("audio")],
["apps", "layers", "#/apps", apps.length], ["library", "film", "#/library", null], ["vram", "chip", "#/vram", null],