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.

Studios menu: studio features fit every window, in line with the rows

Adarshfbfbf4235549
diff --git a/src/app/nav-states.css b/src/app/nav-states.css
index e0346897..5c68c65c 100644
--- a/src/app/nav-states.css
+++ b/src/app/nav-states.css
@@ -150,3 +150,79 @@ html:not([data-input="pointer"]) .nav-focus-out:focus-visible {
background-color: Highlight;
}
}
+
+/*
+ * A studio's features under it in the Studios menu (mega-panel SubLinks). With a mouse: 24 px names in a column, two to
+ * a row's 48 px (an odd number gets a 24 px pad), so the columns' rows stay in line. On a touch screen: pills that wrap,
+ * 32 px to see and 44 px to tap. Below the height its column has room for, a studio with data-subs-line (Genjutsu)
+ * lists them as one wrapped line of names instead. In a layer, so a utility that hides the list still wins.
+ */
+@layer components {
+ .nav-subs {
+ display: flex;
+ flex-direction: column;
+ }
+ .nav-subs > li > a {
+ min-height: 24px;
+ padding-inline: 8px;
+ border-radius: 8px;
+ font-size: 12.5px;
+ line-height: 16px;
+ }
+ .nav-subs[data-odd] {
+ padding-bottom: 24px;
+ }
+ @media (pointer: coarse) {
+ .nav-subs {
+ flex-direction: row;
+ flex-wrap: wrap;
+ gap: 12px 6px;
+ padding-block: 8px 12px;
+ }
+ .nav-subs[data-odd] {
+ padding-bottom: 12px;
+ }
+ .nav-subs > li > a {
+ min-height: 32px;
+ padding-inline: 12px;
+ border: 1px solid var(--border);
+ border-radius: 9999px;
+ font-size: 13px;
+ }
+ .nav-subs > li > a::after {
+ content: "";
+ position: absolute;
+ inset: -6px 0;
+ }
+ }
+ @media (not (pointer: coarse)) and (max-height: 799.98px) {
+ .nav-subs[data-subs-line] {
+ flex-direction: row;
+ flex-wrap: wrap;
+ /* Two lines of names make a 50 px list: with the row it hangs from (its own line left out), two whole rows. */
+ padding-block: 4px 6px;
+ }
+ .nav-subs[data-subs-line] > li {
+ display: flex;
+ align-items: center;
+ }
+ /* A dot after each name but the last: a line that wraps starts on a name. */
+ .nav-subs[data-subs-line] > li:not(:last-child)::after {
+ content: "\00B7";
+ color: var(--muted-foreground);
+ }
+ /* The last one shown: the links after it (data-from) need a taller window. */
+ .nav-subs[data-subs-line] > li:not([data-from]):not(:has(~ li:not([data-from])))::after {
+ content: none;
+ }
+ .nav-subs[data-subs-line] > li > a {
+ min-height: 20px;
+ padding-inline: 2px;
+ font-size: 12px;
+ }
+ /* The open feature reads by its weight here: no pip beside a name in a line. */
+ .nav-subs[data-subs-line] > li > a.nav-mark-start::before {
+ display: none;
+ }
+ }
+}
diff --git a/src/components/areas/area-islands.tsx b/src/components/areas/area-islands.tsx
index 859a9800..71e39b9f 100644
--- a/src/components/areas/area-islands.tsx
+++ b/src/components/areas/area-islands.tsx
@@ -3,7 +3,7 @@
import { Search } from "lucide-react";
import { useCallback, useEffect, useRef, useState } from "react";
import { IntentLink } from "@/components/intent-link";
-import { PILL, PILL_ICON, PILL_TAP } from "@/components/home/pill";
+import { PILL, PILL_ICON, PILL_TAP, SUB_PILL, SUB_ROW, SUB_ROW_NAME } from "@/components/home/pill";
import { useExplored } from "@/components/nav/explore-tracker";
import { useViewerKind } from "@/components/nav/nav-ui";
import { useSearchPalette } from "@/components/nav/search-context";
@@ -241,7 +241,7 @@ const pillOf = (e: NavEntry, tap = true) => {
/** A studio's feature as a pill in its row on /studios: its tab's name, no icon (the row names the studio). */
const subPillOf = (e: NavEntry) => (
<li key={e.id}>
- <IntentLink href={e.href} className={cn(PILL, PILL_TAP)}>
+ <IntentLink href={e.href} className={SUB_PILL}>
{subLabel(e)}
</IntentLink>
</li>
@@ -290,8 +290,8 @@ export function OwnerSubRow({ parent, ids }: { parent: string; ids: string[] })
const list = ids.map(entry).filter((e): e is NavEntry => !!e && visibleTo(e, kind));
if (!list.length) return null;
return (
- <li className="flex flex-col gap-1.5 sm:flex-row sm:items-start sm:gap-4">
- <p className="shrink-0 pt-1.5 text-[13px] leading-5 font-medium sm:w-40">{p.label}</p>
+ <li className={SUB_ROW}>
+ <p className={SUB_ROW_NAME}>{p.label}</p>
<ul aria-label={`In ${p.label}`} className="flex flex-wrap gap-x-1.5 gap-y-3">
{list.map(subPillOf)}
</ul>
diff --git a/src/components/areas/area-page.tsx b/src/components/areas/area-page.tsx
index 6a8468f0..b7be93da 100644
--- a/src/components/areas/area-page.tsx
+++ b/src/components/areas/area-page.tsx
@@ -1,6 +1,6 @@
import { ChevronLeft, Plus } from "lucide-react";
import { DestinationsSection, HomeFooter, SectionHead } from "@/components/home/home-sections";
-import { PILL, PILL_ICON, PILL_TAP } from "@/components/home/pill";
+import { PILL, PILL_ICON, PILL_TAP, SUB_PILL, SUB_ROW, SUB_ROW_NAME } from "@/components/home/pill";
import { IntentLink } from "@/components/intent-link";
import { PageShell } from "@/components/page-shell";
import type { AreaShowcase } from "@/lib/area-showcase";
@@ -109,11 +109,6 @@ export function AreaSections({ sections }: { sections: AreaShowcase["sections"]
));
}
-/** A studio's row of features: its name, then its tabs and modes as pills that wrap (44 px to tap). */
-export const SUB_ROW = "flex flex-col gap-1.5 sm:flex-row sm:items-start sm:gap-4";
-export const SUB_ROW_NAME = "shrink-0 pt-1.5 text-[13px] leading-5 font-medium sm:w-40";
-export const SUB_PILL = cn(PILL, PILL_TAP);
-
/**
* What a section's studios hold inside (their tabs and modes), a row per studio under its cards and pills, so each is
* one tap from here: "Marketing Studio (Click to Ad) (Ad Multiplier)". The owner's own features come with the island.
diff --git a/src/components/home/pill.ts b/src/components/home/pill.ts
index 60ddd346..b8434e5b 100644
--- a/src/components/home/pill.ts
+++ b/src/components/home/pill.ts
@@ -8,3 +8,13 @@ export const PILL_TAP = "relative after:absolute after:inset-x-0 after:-inset-y-
/** A pill's icon. */
export const PILL_ICON = "size-3.5 text-muted-foreground transition-colors group-hover:text-brand-text";
+
+/**
+ * A studio's feature as a pill (/studios' "Inside these studios", the phone's Studios sheet): 44 px to tap, and the open
+ * page's (aria-current) in the foreground's weight.
+ */
+export const SUB_PILL = `${PILL} ${PILL_TAP} aria-[current=page]:border-foreground/40 aria-[current=page]:font-semibold`;
+
+/** A studio's row of feature pills on /studios: its name, then its pills that wrap. */
+export const SUB_ROW = "flex flex-col gap-1.5 sm:flex-row sm:items-start sm:gap-4";
+export const SUB_ROW_NAME = "shrink-0 pt-1.5 text-[13px] leading-5 font-medium sm:w-40";
diff --git a/src/components/nav/mega-panel.tsx b/src/components/nav/mega-panel.tsx
index 61a7c10c..130a29c5 100644
--- a/src/components/nav/mega-panel.tsx
+++ b/src/components/nav/mega-panel.tsx
@@ -6,7 +6,7 @@ import { Fragment, lazy, Suspense, useEffect, useId, useRef, useState } from "re
import { IntentLink } from "@/components/intent-link";
import { Kbd } from "@/components/ui/kbd";
import { MEGA_AREAS, ROW_CAPS, studiosMenu, TILE_COLS, type MegaColumn, type MegaId, type MegaItem, type MegaModel } from "@/lib/mega-menus";
-import { isNew, type ViewerKind } from "@/lib/nav-model";
+import { isNew, subParent, type ViewerKind } from "@/lib/nav-model";
import { cn } from "@/lib/utils";
import { CoverThumb } from "./cover-thumb";
import { useMegaMenu } from "./mega-data";
@@ -35,13 +35,14 @@ function NewBadge() {
}
/** A column's first card: its cover, name and one line. `row` 1 under the owner's New board (Canvas), its cover shorter by that button. */
-export function LeadCard({ e, col, row = 0, current, now }: { e: MegaItem; col: number; row?: number; current: boolean; now: number }) {
+export function LeadCard({ e, col, row = 0, current, inside, now }: { e: MegaItem; col: number; row?: number; current: boolean; inside?: boolean; now: number }) {
return (
<IntentLink
href={e.href}
data-col={col}
data-row={row}
aria-current={current ? "page" : undefined}
+ data-active={inside ? "" : undefined}
className="nav-row group/lead flex flex-col overflow-hidden rounded-[14px] border bg-card text-card-foreground"
>
<CoverThumb
@@ -68,13 +69,14 @@ export function LeadCard({ e, col, row = 0, current, now }: { e: MegaItem; col:
);
}
-function Row({ e, col, row, current, now, className }: { e: MegaItem; col: number; row: number; current: boolean; now: number; className?: string }) {
+function Row({ e, col, row, current, inside, now, className }: { e: MegaItem; col: number; row: number; current: boolean; inside?: boolean; now: number; className?: string }) {
return (
<IntentLink
href={e.href}
data-col={col}
data-row={row}
aria-current={current ? "page" : undefined}
+ data-active={inside ? "" : undefined}
title={e.line ? `${e.label}: ${e.line}` : e.label}
className={cn("nav-row nav-mark-start -mx-2 flex min-h-11 items-center gap-3 rounded-[10px] px-2 py-1.5 md:max-lg:min-h-10", className)}
>
@@ -83,38 +85,65 @@ function Row({ e, col, row, current, now, className }: { e: MegaItem; col: numbe
<CoverThumb id={e.navCover} cover={e.cover} size="row" icon={e.icon} className="max-[1439.98px]:hidden" />
<span className="flex min-w-0 flex-col">
<span className="flex min-w-0 items-center gap-1.5">
- <span className={cn("truncate text-[13px] leading-[18px] font-medium max-xl:line-clamp-2 max-xl:whitespace-normal", current && "font-semibold")}>{e.label}</span>
+ <span className={cn("truncate text-[13px] leading-[18px] font-medium max-xl:line-clamp-2 max-xl:whitespace-normal", (current || inside) && "font-semibold")}>{e.label}</span>
{isNew(e, now) && <NewBadge />}
</span>
- <span className="truncate text-[12px] leading-4 text-muted-foreground max-xl:hidden">{e.line}</span>
+ {/* A studio whose links become one line on a short window gives that line its own line's room. */}
+ <span className={cn("truncate text-[12px] leading-4 text-muted-foreground max-xl:hidden", e.subsLine && "[@media(max-height:799.98px)]:hidden")}>{e.line}</span>
</span>
</IntentLink>
);
}
-/** A studio's links hide on a window shorter than they need (the panel never scrolls inside). */
-const SUBS_FROM: Record<800 | 880 | 960, string> = { 800: "[@media(max-height:799.98px)]:hidden", 880: "[@media(max-height:879.98px)]:hidden", 960: "[@media(max-height:959.98px)]:hidden" };
+/**
+ * Below the window height a studio's links need, they hide, so the panel never scrolls inside. With a mouse they are
+ * 24 px names; on a touch screen pills 44 px to tap (nav-states.css), so they need a taller window there.
+ */
+const HIDE_SHORT: Record<800 | 880 | 960, string> = {
+ 800: "[@media(max-height:799.98px)]:hidden",
+ 880: "[@media(max-height:879.98px)]:hidden",
+ 960: "[@media(max-height:959.98px)]:hidden",
+};
+const HIDE_TOUCH: Record<800 | 880 | 960, string> = {
+ 800: "[@media(pointer:coarse)_and_(max-height:1023.98px)]:hidden",
+ 880: "[@media(pointer:coarse)_and_(max-height:1099.98px)]:hidden",
+ 960: "[@media(pointer:coarse)_and_(max-height:1199.98px)]:hidden",
+};
+/** `line`: with a mouse they become one line of names there instead (nav-states.css), so only a touch screen hides them. */
+const hideBelow = (h: 800 | 880 | 960, line = false) => cn(!line && HIDE_SHORT[h], HIDE_TOUCH[h]);
/**
* What a studio holds inside (its tabs and modes), as links under its card or row: names only, smaller and quieter
- * than the rows, hung from a hairline under the studio. `row`: the first link's place for the arrow keys (they go
- * down from the studio through its links to the next row). `current`: the open page's feature.
+ * than the rows, hung from a hairline under the studio (nav-states.css .nav-subs: with a mouse, two 24 px names to a
+ * row's 48 px, so the columns' rows stay in line; pills on a touch screen; one wrapped line of names below the height a
+ * studio with `subsLine` needs). `row`: the first link's place for the arrow keys (they go down from the studio through
+ * its links to the next row). `current`: the open page's feature. `under`: links under a row, whose names start where
+ * the row's name does.
*/
-function SubLinks({ e, col, row, current, className }: { e: MegaItem; col: number; row: number; current?: string; className?: string }) {
+function SubLinks({ e, col, row, current, under }: { e: MegaItem; col: number; row: number; current?: string; under?: boolean }) {
if (!e.subs?.length) return null;
+ // An odd number of links ends half a row short: a 24 px pad fills it (the owner's taller-window links come in twos).
+ const odd = e.subs.filter((s) => !s.from).length % 2 === 1;
return (
- <ul aria-label={`In ${e.label}`} data-subs={e.id} className={cn("mt-0.5 mb-1 ml-[17px] flex flex-col border-l border-border pl-1 max-[1439.98px]:ml-1.5", e.subsFrom && SUBS_FROM[e.subsFrom], className)}>
+ <ul
+ aria-label={`In ${e.label}`}
+ data-subs={e.id}
+ data-odd={odd ? "" : undefined}
+ data-subs-line={e.subsLine ? "" : undefined}
+ className={cn("nav-subs ml-[17px] border-l border-border pl-1 max-[1439.98px]:ml-1.5", under && "min-[1440px]:pl-[21px]", e.subsFrom && hideBelow(e.subsFrom, e.subsLine))}
+ >
{e.subs.map((s, i) => (
- <li key={s.id} className={s.from && SUBS_FROM[s.from]}>
+ <li key={s.id} data-from={s.from ? "" : undefined} className={cn(s.from && hideBelow(s.from))}>
<IntentLink
href={s.href}
data-col={col}
data-row={row + i}
data-sub=""
aria-current={current === s.id ? "page" : undefined}
+ aria-label={s.name}
title={s.line}
className={cn(
- "nav-row nav-mark-start group/sub flex min-h-7 items-center gap-1 rounded-[8px] px-2 text-[12.5px] leading-4 [@media(pointer:coarse)]:min-h-11",
+ "nav-row nav-mark-start group/sub flex items-center gap-1",
s.more ? "font-medium text-brand-text" : "text-muted-foreground hover:text-foreground aria-[current=page]:font-semibold aria-[current=page]:text-foreground",
)}
>
@@ -201,6 +230,8 @@ export function MegaColumns({ model, current, now, kind }: { model: MegaModel; c
const families = !!model.families?.length;
const tileColumns = model.columns.filter((c) => c.variant === "tiles").length;
const places = keyPlaces(model.columns);
+ // On a studio's feature (Genjutsu's Restyle, Upscale's Video), its studio is marked as holding the page too.
+ const holder = current ? subParent(current) : undefined;
const column = (c: MegaColumn, ci: number) => {
const { col, row: firstRow } = places[ci];
@@ -249,9 +280,11 @@ export function MegaColumns({ model, current, now, kind }: { model: MegaModel; c
</div>
);
}
+ // A studio listed under another (Ads Studio under Marketing Studio) is one of its links, not a row of its own.
+ const rows = c.rows.filter((e) => !e.under);
// Places for the arrow keys, top to bottom: the lead (0), its links, then each row and its links.
let next = 1 + (c.lead?.subs?.length ?? 0);
- const at = c.rows.map((e) => {
+ const at = rows.map((e) => {
const r = next;
next += 1 + (e.subs?.length ?? 0);
return r;
@@ -262,14 +295,14 @@ export function MegaColumns({ model, current, now, kind }: { model: MegaModel; c
<ul aria-labelledby={labelId} className="flex flex-col gap-0.5">
{c.lead && (
<li className="pb-1.5">
- <LeadCard e={c.lead} col={col} current={current === c.lead.id} now={now} />
- <SubLinks e={c.lead} col={col} row={1} current={current} className="mt-1.5" />
+ <LeadCard e={c.lead} col={col} current={current === c.lead.id} inside={holder === c.lead.id} now={now} />
+ <SubLinks e={c.lead} col={col} row={1} current={current} />
</li>
)}
- {c.rows.map((e, ri) => (
+ {rows.map((e, ri) => (
<li key={e.id} className={capped ? ROW_HIDE(ri, families) : undefined}>
- <Row e={e} col={col} row={at[ri]} current={current === e.id} now={now} />
- <SubLinks e={e} col={col} row={at[ri] + 1} current={current} />
+ <Row e={e} col={col} row={at[ri]} current={current === e.id} inside={holder === e.id} now={now} />
+ <SubLinks e={e} col={col} row={at[ri] + 1} current={current} under />
</li>
))}
</ul>
diff --git a/src/components/nav/studios-sheet.tsx b/src/components/nav/studios-sheet.tsx
index 736a88ec..7a7589c2 100644
--- a/src/components/nav/studios-sheet.tsx
+++ b/src/components/nav/studios-sheet.tsx
@@ -3,6 +3,7 @@
import { usePathname, useSearchParams } from "next/navigation";
import { lazy, Suspense, useEffect, useState } from "react";
import { ArrowRight, CircleUserRound, House, Library, RotateCw, Search } from "lucide-react";
+import { SUB_PILL } from "@/components/home/pill";
import { CoverThumb } from "@/components/nav/cover-thumb";
import { useNavUi, useViewerKind } from "@/components/nav/nav-ui";
import { IntentLink } from "@/components/intent-link";
@@ -50,10 +51,12 @@ function Tile({ entry, current }: { entry: MegaItem; current: boolean }) {
/**
* What the group's studios hold inside (their tabs and modes, every one a viewer may run): under the tiles, a small
- * heading per studio and its features as 44 px pills that wrap. Only for one group (All stays one screen of tiles).
+ * heading per studio and its features as pills that wrap (/studios' own, 44 px to tap). Only for one group (All stays
+ * one screen of tiles). A feature that is a tile here already (Ads Studio) isn't listed again.
*/
function SheetSubs({ items, kind, current }: { items: MegaItem[]; kind: ViewerKind | undefined; current?: string }) {
- const groups = items.map((e) => ({ e, subs: studioSubs(e.id, kind, "sheet") })).filter((g) => g.subs.length > 0);
+ const tiles = new Set(items.map((e) => e.id));
+ const groups = items.map((e) => ({ e, subs: studioSubs(e.id, kind, "sheet").filter((s) => !tiles.has(s.id)) })).filter((g) => g.subs.length > 0);
if (!groups.length) return null;
return (
<div data-sheet-subs className="flex flex-col gap-3 border-t pt-3 pb-3">
@@ -62,11 +65,11 @@ function SheetSubs({ items, kind, current }: { items: MegaItem[]; kind: ViewerKi
<p id={`sheet-subs-${e.id}`} className="text-[11px] leading-4 font-semibold tracking-[.08em] text-brand-text uppercase">
{e.label}
</p>
- {/* 36 px pills whose touch area reaches 4 px past each edge (44 px): rows 8 px apart, so no two overlap. */}
- <ul aria-labelledby={`sheet-subs-${e.id}`} className="mt-2 flex flex-wrap gap-x-1.5 gap-y-2">
+ {/* 32 px pills whose touch area reaches 6 px past each edge (44 px): rows 12 px apart, so no two overlap. */}
+ <ul aria-labelledby={`sheet-subs-${e.id}`} className="mt-2 flex flex-wrap gap-x-1.5 gap-y-3">
{subs.map((s) => (
<li key={s.id}>
- <IntentLink href={s.href} aria-current={current === s.id ? "page" : undefined} {...onAttr(current === s.id)} title={s.what} className={cn(TAB_PILL, "px-3.5 text-[13px]")}>
+ <IntentLink data-sub="" href={s.href} aria-current={current === s.id ? "page" : undefined} title={s.what} className={SUB_PILL}>
{subLabel(s)}
</IntentLink>
</li>
@@ -172,8 +175,6 @@ export function StudiosSheet({ family = "studios", group: initial, onSearch }: {
useEffect(() => warmMenu(family), [family]);
// The query too: moving from one preset to another (/video?preset=…) keeps the path.
const current = megaCurrent(family, pathname, useSearchParams()?.toString() ?? "");
- // On a studio's feature (Genjutsu's Restyle, Ads Studio), that studio's tile is the one marked.
- const currentTile = family === "studios" && current ? (subParent(current) ?? current) : current;
const area = MEGA_AREAS[family];
// Canvas: its "Start here" column is the desktop's; on a phone the boards are the grid.
const columns = model?.columns.filter((c) => !(family === "canvas" && c.id === "start")) ?? [];
@@ -181,6 +182,9 @@ export function StudiosSheet({ family = "studios", group: initial, onSearch }: {
// Canvas' "What's a canvas?" (a finished board's scene, which the sections leave out) opens its All grid.
const intro = family === "canvas" && !group ? model?.columns.find((c) => c.id === "start")?.lead : undefined;
const items = model ? [...(intro ? [intro] : []), ...chipItems({ ...model, columns }, group)] : [];
+ // On a studio's feature (Genjutsu's Restyle), that studio's tile is the one marked; a feature with a tile of its own
+ // (Ads Studio) marks that.
+ const currentTile = family === "studios" && current && !items.some((e) => e.id === current) ? (subParent(current) ?? current) : current;
const families = model?.families;
const seeAll =
group && families
diff --git a/src/components/nav/tab-from-link.tsx b/src/components/nav/tab-from-link.tsx
index 746ba32e..a536caf4 100644
--- a/src/components/nav/tab-from-link.tsx
+++ b/src/components/nav/tab-from-link.tsx
@@ -1,18 +1,18 @@
"use client";
import { useSearchParams } from "next/navigation";
-import { Suspense, useEffect } from "react";
+import { Suspense, useLayoutEffect } from "react";
/*
* A studio tab that a link can open: the bar's menus, the phone's Studios sheet and search link a studio's tabs by a
* query (/character-sheet?mode=cast, /photodump?tab=instadump). The tab follows the address on load and whenever a link
* changes it; picking a tab writes it back (linkTab), so the address can be shared and a link to another tab still
- * switches it.
+ * switches it. The tab is set before the browser paints (a layout effect), so a link from the menus opens straight on it.
*/
function ReadTab<T extends string>({ param, ids, onTab }: { param: string; ids: readonly T[]; onTab: (id: T) => void }) {
const value = useSearchParams().get(param);
- useEffect(() => {
+ useLayoutEffect(() => {
if (value && (ids as readonly string[]).includes(value)) onTab(value as T);
}, [value, ids, onTab]);
return null;
diff --git a/src/lib/mega-menus.ts b/src/lib/mega-menus.ts
index 6862138a..146919a3 100644
--- a/src/lib/mega-menus.ts
+++ b/src/lib/mega-menus.ts
@@ -49,6 +49,13 @@ export interface MegaItem {
subs?: MegaSub[];
/** The window height its links need (800, 880 or 960 px): below it they hide, so the panel never scrolls. */
subsFrom?: 800 | 880 | 960;
+ /** Below `subsFrom`, its links show as one wrapped line of names (Genjutsu's modes) instead of hiding. */
+ subsLine?: true;
+ /**
+ * The studio the desktop menu lists it under, as one of its links (Ads Studio under Marketing Studio): the menu leaves
+ * out its own row; the phone's sheet keeps its tile (its All grid is tiles only).
+ */
+ under?: string;
}
/** A feature inside a studio, as a link under it: its tab's name, its line as the link's title. */
@@ -59,6 +66,8 @@ export interface MegaSub {
line?: string;
/** "See all N": the studio's page, where every one of its features is a tab. */
more?: true;
+ /** Its accessible name, when its label alone doesn't say where it goes ("See all 13 in Audio"). */
+ name?: string;
/** The window height this one link needs, when it is more than its studio's other links do (the owner's own). */
from?: 880 | 960;
}
@@ -172,24 +181,34 @@ export function megaSubs(parent: NavEntry, kind: ViewerKind | undefined): MegaSu
}));
// Every tab the studio's page shows this viewer (Audio's rows in the Sound column count too).
const all = Math.max(studioSubs(parent.id, kind, "list").length, entriesFor(kind).filter((e) => e.kind === "tool" && e.parent === parent.id).length);
- if (all > shown.length) subs.push({ id: `${parent.id}-all`, href: parent.href, label: `See all ${all}`, line: `Every tool in ${parent.label}`, more: true });
+ if (all > shown.length) subs.push({ id: `${parent.id}-all`, href: parent.href, label: `See all ${all}`, name: `See all ${all} in ${parent.label}`, line: `Every tool in ${parent.label}`, more: true });
return subs;
}
const withSubs = (e: NavEntry, kind: ViewerKind | undefined): MegaItem => {
const subs = megaSubs(e, kind);
- const from = STUDIO_SUBS[e.id]?.tall;
- return { ...studioItem(e), ...(subs.length > 0 && { subs, ...(from && { subsFrom: from }) }) };
+ const spec = STUDIO_SUBS[e.id];
+ const under = subParent(e.id);
+ return {
+ ...studioItem(e),
+ ...(subs.length > 0 && { subs, ...(spec?.tall && { subsFrom: spec.tall, ...(spec.short === "line" && { subsLine: true as const }) }) }),
+ ...(under && { under }),
+ };
};
+/** The Studios menu for each kind of viewer, built once: it only reads the navigation model. */
+const studiosMenus = new Map<ViewerKind | undefined, MegaModel>();
+
/**
* Studios as a menu: the launcher's columns (launcherColumns) for who is looking, each studio with what it holds inside
* as links under it (megaSubs). A studio that is a tab of another's suite (Ads Studio, in Marketing Studio's) is one of
- * those links instead of a row of its own.
+ * those links in the desktop menu instead of a row of its own (`under`); the phone's sheet keeps its tile.
*/
export function studiosMenu(kind: ViewerKind | undefined): MegaModel {
+ const built = studiosMenus.get(kind);
+ if (built) return built;
const n = studioCount();
- return {
+ const model: MegaModel = {
id: "studios",
count: n,
countLine: `${n} studios, grouped by what you want to make`,
@@ -199,9 +218,11 @@ export function studiosMenu(kind: ViewerKind | undefined): MegaModel {
label: c.group.label,
chip: c.group.chip,
lead: withSubs(c.lead, kind),
- rows: c.rest.filter((e) => !subParent(e.id)).map((e) => withSubs(e, kind)),
+ rows: c.rest.map((e) => withSubs(e, kind)),
})),
};
+ studiosMenus.set(kind, model);
+ return model;
}
/** Every item of a menu, leads first in each column, in column order (a phone's "All", a test). */
diff --git a/src/lib/nav-model.ts b/src/lib/nav-model.ts
index f872015e..7af1424b 100644
--- a/src/lib/nav-model.ts
+++ b/src/lib/nav-model.ts
@@ -685,6 +685,8 @@ export interface StudioSubs {
menu?: number;
pick?: readonly string[];
tall?: 800 | 880 | 960;
+ /** Below `tall`: "line" shows them as one wrapped line of names instead of hiding them (Genjutsu's modes). */
+ short?: "line";
/** The owner's own features in the list (Genjutsu's From picture and Finish) show from this height. */
ownerTall?: 880 | 960;
}
@@ -693,7 +695,7 @@ const hubTools = (hub: HubKind, skip: readonly string[] = []) => HUB_MODES[hub].
export const STUDIO_SUBS: Readonly<Record<string, StudioSubs>> = {
marketing: { ids: ["marketing-click-to-ad", "ads", "ads-multiplier"] },
- genjutsu: { ids: ["genjutsu-motion", "genjutsu-character", "genjutsu-swap", "genjutsu-restyle", "genjutsu-insert", "genjutsu-picture", "genjutsu-finish"], tall: 800, ownerTall: 880 },
+ genjutsu: { ids: ["genjutsu-motion", "genjutsu-character", "genjutsu-swap", "genjutsu-restyle", "genjutsu-insert", "genjutsu-picture", "genjutsu-finish"], tall: 800, short: "line", ownerTall: 880 },
// The modes that aren't rows of the Sound column already.
audio: { ids: hubTools("audio", SOUND_COLUMN), menu: 3 },
upscale: { ids: hubTools("upscale") },
diff --git a/src/lib/nav-search.ts b/src/lib/nav-search.ts
index 5d9fb97a..dff5d907 100644
--- a/src/lib/nav-search.ts
+++ b/src/lib/nav-search.ts
@@ -5,7 +5,7 @@
* perfume ad is a job for Marketing Studio. The word match itself is command-search.ts's (wordScore).
*/
import { GROUP_LIMIT, KIND_LABELS, normalize, wordScore, type PaletteEntry, type PaletteKind } from "./command-search";
-import { entry as navEntry, THEME_ACTION, type NavEntry, type NavKind } from "./nav-model";
+import { entry as navEntry, STUDIO_SUBS, THEME_ACTION, type NavEntry, type NavKind } from "./nav-model";
export type HitKind = PaletteKind | "studio" | "tool";
@@ -23,6 +23,8 @@ export interface SearchEntry extends Omit<PaletteEntry, "kind"> {
/** A nav icon name. */
icon?: string;
popular?: boolean;
+ /** A tool's studio id (a nav entry's parent): a studio found as the best match lists its tools after it. */
+ parent?: string;
}
export interface NavHit {
@@ -344,6 +346,8 @@ export function searchNav(query: string, entries: SearchEntry[], opts: { intents
.slice(0, 2)
.map((h) => ({ ...h, from: KIND_LABELS[h.kind as PaletteKind] }));
const shown = new Set([...best, ...also].map((h) => h.key));
+ const inside = insideOf(best[0], entries, shown);
+ for (const h of inside?.hits ?? []) shown.add(h.key);
const byGroup = new Map<string, { kind: string; label: string; limit: number; hits: NavHit[] }>();
for (const h of hits) {
if (shown.has(h.key)) continue;
@@ -355,7 +359,46 @@ export function searchNav(query: string, entries: SearchEntry[], opts: { intents
const groups = [...byGroup.values()]
.sort((a, b) => b.hits[0].score - a.hits[0].score || GROUP_ORDER.indexOf(a.kind) - GROUP_ORDER.indexOf(b.kind))
.map(({ kind, label, hits }) => ({ kind, label, hits }));
- return { best, also, groups };
+ return { best, also, groups: inside ? [inside, ...groups] : groups };
+}
+
+/** How many of a studio's tools its "In <studio>" group lists. */
+export const INSIDE_LIMIT = 8;
+
+/** Each studio's tools in a set of entries (STUDIO_SUBS order first), worked out once per set: the palette keeps its set. */
+const toolsCache = new WeakMap<SearchEntry[], Map<string, SearchEntry[]>>();
+function studioTools(entries: SearchEntry[]): Map<string, SearchEntry[]> {
+ const cached = toolsCache.get(entries);
+ if (cached) return cached;
+ const byId = new Map<string, SearchEntry>();
+ const byParent = new Map<string, SearchEntry[]>();
+ for (const e of entries) {
+ if (!e.key.startsWith("nav:")) continue;
+ if (e.id && !byId.has(e.id)) byId.set(e.id, e);
+ if (e.parent) byParent.set(e.parent, [...(byParent.get(e.parent) ?? []), e]);
+ }
+ const out = new Map<string, SearchEntry[]>();
+ for (const parent of new Set([...Object.keys(STUDIO_SUBS), ...byParent.keys()])) {
+ const listed = (STUDIO_SUBS[parent]?.ids ?? []).map((id) => byId.get(id)).filter((e): e is SearchEntry => !!e);
+ const keys = new Set(listed.map((e) => e.key));
+ out.set(parent, [...listed, ...(byParent.get(parent) ?? []).filter((e) => !keys.has(e.key))]);
+ }
+ toolsCache.set(entries, out);
+ return out;
+}
+
+/**
+ * A studio found as the best match: what it holds inside (its tabs and modes, STUDIO_SUBS order, then its other tools),
+ * as a group right after it ("genjutsu" lists Motion transfer, Character swap…). Not the ones already shown, nor a tab
+ * that is the studio's own page. Undefined for anything else, or a studio with nothing inside.
+ */
+function insideOf(lead: NavHit | undefined, entries: SearchEntry[], shown: ReadonlySet<string>): SearchResult["groups"][number] | undefined {
+ if (lead?.kind !== "studio" || !lead.id) return undefined;
+ const hits = (studioTools(entries).get(lead.id) ?? [])
+ .filter((e) => !shown.has(e.key) && e.href !== lead.href)
+ .slice(0, INSIDE_LIMIT)
+ .map((e) => toHit(e, 0));
+ return hits.length ? { kind: `in-${lead.id}`, label: `In ${lead.label}`, hits } : undefined;
}
// ---------------------------------------------------------------------------
@@ -390,6 +433,7 @@ export function navSearchEntry(e: NavEntry): SearchEntry {
icon: e.icon,
...((e.cover ?? parent?.cover) && { cover: e.cover ?? parent?.cover }),
...(e.popular && { popular: true }),
+ ...(e.parent && { parent: e.parent }),
};
}
diff --git a/tests/e2e/nav-hubs.mjs b/tests/e2e/nav-hubs.mjs
index ab912369..8e37a143 100644
--- a/tests/e2e/nav-hubs.mjs
+++ b/tests/e2e/nav-hubs.mjs
@@ -285,8 +285,8 @@ try {
if (tab === "Studios") {
const tiles = sheet.locator("ul").first().getByRole("link");
const seen = await tiles.evaluateAll((els) => els.map((el) => el.getBoundingClientRect()).map((r) => r.top >= 0 && r.bottom <= innerHeight));
- // 32 studio tiles (Ads Studio is under Marketing Studio, in the Sell group) and the See all tile that ends the grid.
- check(seen.length === 33 && seen.every(Boolean), "phone Studios sheet: all 32 tiles and See all fit 390x844", `${seen.filter(Boolean).length}/${seen.length}`);
+ // 33 studio tiles and the See all tile that ends the grid.
+ check(seen.length === 34 && seen.every(Boolean), "phone Studios sheet: all 33 tiles and See all fit 390x844", `${seen.filter(Boolean).length}/${seen.length}`);
check((await sheet.getByRole("button", { name: "Search everything" }).count()) === 1, "phone Studios sheet: Search everything is an icon button");
if (shots) await p.screenshot({ path: path.join(shots, "phone-studios-sheet-390.png") });
}
diff --git a/tests/e2e/nav-subfeatures.mjs b/tests/e2e/nav-subfeatures.mjs
index 4549f9fd..0e8d9955 100644
--- a/tests/e2e/nav-subfeatures.mjs
+++ b/tests/e2e/nav-subfeatures.mjs
@@ -106,9 +106,19 @@ const measure = (p) =>
const subs = {};
for (const ul of el.querySelectorAll("[data-subs]")) {
if (!ul.checkVisibility()) continue;
- subs[ul.getAttribute("data-subs")] = [...ul.querySelectorAll("a")].filter((a) => a.checkVisibility()).map((a) => ({ label: a.textContent.trim(), h: a.getBoundingClientRect().height }));
+ subs[ul.getAttribute("data-subs")] = [...ul.querySelectorAll("a")]
+ .filter((a) => a.checkVisibility())
+ .map((a) => {
+ // A pill's touch area past it (::after on a touch screen).
+ const after = getComputedStyle(a, "::after");
+ const reach = after.content !== "none" && after.position === "absolute" ? Math.max(0, -parseFloat(after.top) || 0) + Math.max(0, -parseFloat(after.bottom) || 0) : 0;
+ return { label: a.textContent.trim(), h: a.getBoundingClientRect().height, tap: a.getBoundingClientRect().height + reach, line: getComputedStyle(ul).flexDirection === "row" && !matchMedia("(pointer: coarse)").matches };
+ });
}
+ // Each list column's rows (studios, not their links): their tops, to see the columns' rows in line.
+ const rows = [...el.querySelectorAll("[data-group] > ul > li:not(:first-child) > a")].filter((a) => a.checkVisibility()).map((a) => a.getBoundingClientRect().top);
return {
+ rows,
inner: el.scrollHeight - el.clientHeight,
offscreen: links.filter((a) => {
const r = a.getBoundingClientRect();
@@ -123,11 +133,18 @@ const measure = (p) =>
try {
// 1. The Studios menu: each viewer, each size: everything on screen, the studios' links where their column has room.
for (const who of ["guest", "owner", ...(publicSignup ? ["account"] : [])]) {
+ // Window sizes, and the page area common laptops leave inside the browser's own bars (1440x790, 1536x730, 1920x940),
+ // and both sides of the 880 px step.
for (const size of [
{ width: 1280, height: 720 },
{ width: 1366, height: 768 },
+ { width: 1536, height: 730 },
+ { width: 1440, height: 790 },
{ width: 1280, height: 800 },
+ { width: 1440, height: 879 },
+ { width: 1440, height: 880 },
{ width: 1440, height: 900 },
+ { width: 1920, height: 940 },
{ width: 1920, height: 1080 },
]) {
const label = `${who} ${size.width}x${size.height}`;
@@ -140,19 +157,32 @@ try {
check(r.inner <= 1 && r.offscreen === 0, `${label}: every studio and link on screen, no scrolling inside`, `inner ${r.inner}, ${r.offscreen}/${r.links} off`);
check(names("marketing").join(" · ") === "Click to Ad · Ads Studio · Ad Multiplier", `${label}: Marketing Studio lists Click to Ad · Ads Studio · Ad Multiplier`, names("marketing").join(" · "));
check(names("upscale").join(" · ") === "Image · Video · FPS Boost · SDR to HDR · Export", `${label}: Upscale lists its five tabs`, names("upscale").join(" · "));
- if (size.height >= 800) {
+ {
+ // Genjutsu's modes at every height: a column of links from 800 px, one wrapped line of names below it. The
+ // owner's own two modes from 880 px (People is the tallest column then).
const gen = names("genjutsu");
- // The owner's own two modes from 880 px (People is the tallest column then).
const want = ["Motion transfer", "Character swap", "Object swap", "Restyle", "Insert", ...(who === "owner" && size.height >= 880 ? ["From picture", "Finish"] : [])];
check(want.every((w) => gen.includes(w)) && gen.length === want.length, `${label}: Genjutsu lists its modes`, gen.join(" · "));
+ const line = (r.subs.genjutsu ?? []).some((s) => s.line);
+ check(line === size.height < 800, `${label}: Genjutsu's modes ${size.height < 800 ? "as one line" : "as a column"}`);
if (size.height >= 880) check(/^See all \d+$/.test(names("video-tools").at(-1) ?? ""), `${label}: Video tools lists a few, then See all`, names("video-tools").join(" · "));
else check(!r.subs["video-tools"], `${label}: Video tools keeps its row only (its links from 880 px)`);
- } else {
- check(!r.subs.genjutsu && !r.subs["video-tools"], `${label}: full columns keep their rows only (Genjutsu and Video tools links from 800 px)`, Object.keys(r.subs).join(","));
}
check((await panel(p).locator('[data-group="sell"] > ul > li > a[href="/ads"]').count()) === 0, `${label}: Ads Studio is under Marketing Studio, not a row of its own`);
const allSubs = Object.values(r.subs).flat();
- check(allSubs.every((s) => s.h >= 27.5), `${label}: every link at least 28 px tall`, allSubs.filter((s) => s.h < 27.5).map((s) => `${s.label} ${s.h}`).join(", "));
+ // 24 px with a mouse (two to a row); a name in a line 20 px, its neighbours a dot away.
+ const short = allSubs.filter((s) => s.h < (s.line ? 19.5 : 23.5));
+ check(short.length === 0, `${label}: every link 24 px tall (20 in a line)`, short.map((s) => `${s.label} ${s.h}`).join(", "));
+ // The columns' rows stay in line (from 800 px: below it Genjutsu's line takes what it needs): every row's top is a
+ // whole number of 48 px rows from the first one's.
+ if (size.width >= 1280 && size.height >= 800 && r.rows.length) {
+ const base = Math.min(...r.rows);
+ const off = r.rows.filter((t) => {
+ const m = (((t - base) % 48) + 48) % 48;
+ return m > 2.5 && m < 45.5;
+ });
+ check(off.length === 0, `${label}: the columns' rows stay in line`, off.map(Math.round).join(", "));
+ }
if (who !== "owner") {
const said = OWNER_SUBS.filter((w) => allSubs.some((s) => s.label === w));
check(said.length === 0, `${label}: no link a visitor can't use`, said.join(", "));
@@ -177,19 +207,29 @@ try {
await ctx.close();
}
}
- {
- const ctx = await as("guest", { viewport: { width: 1366, height: 1024 }, hasTouch: true, isMobile: false });
- const p = await page(ctx);
- await openRoute(p, `${app}/image`, { settleMs: 300 });
- const coarse = await p.evaluate(() => matchMedia("(pointer: coarse)").matches);
- if (coarse) {
- await openStudios(p);
- const r = await measure(p);
- const small = Object.values(r.subs).flat().filter((s) => s.h < 43.5);
- check(small.length === 0, "touch screen at 1366x1024: every link 44 px tall", small.map((s) => `${s.label} ${s.h}`).join(", "));
- check(r.inner <= 1 && r.offscreen === 0, "touch screen at 1366x1024: still no scrolling inside", `inner ${r.inner}, off ${r.offscreen}`);
- } else console.log(" touch screen: this engine doesn't report (pointer: coarse) here, skipped");
- await ctx.close();
+ for (const who of ["guest", "owner"]) {
+ for (const [width, height] of [
+ [1180, 820],
+ [1280, 800],
+ [1366, 1024],
+ [1280, 1100],
+ ]) {
+ const label = `touch screen ${who} ${width}x${height}`;
+ const ctx = await as(who, { viewport: { width, height }, hasTouch: true, isMobile: false });
+ const p = await page(ctx);
+ await openRoute(p, `${app}/image`, { settleMs: 300 });
+ const coarse = await p.evaluate(() => matchMedia("(pointer: coarse)").matches);
+ if (coarse) {
+ await openStudios(p);
+ const r = await measure(p);
+ const small = Object.values(r.subs).flat().filter((s) => s.tap < 43.5);
+ check(small.length === 0, `${label}: every link 44 px to tap`, small.map((s) => `${s.label} ${s.tap}`).join(", "));
+ check(r.inner <= 1 && r.offscreen === 0, `${label}: no scrolling inside`, `inner ${r.inner}, off ${r.offscreen}`);
+ check(!!r.subs.genjutsu === height >= 1024, `${label}: Genjutsu's modes ${height >= 1024 ? "listed" : "left to its page (from 1024 px)"}`);
+ if (shots && who === "guest" && width === 1280) await shot(p, `studios-${width}x${height}-touch-guest`);
+ } else console.log(` ${label}: this engine doesn't report (pointer: coarse) here, skipped`);
+ await ctx.close();
+ }
}
{
const ctx = await as("guest", { viewport: { width: 1440, height: 900 } }, { reducedMotion: "reduce" });
@@ -251,6 +291,12 @@ try {
await openStudios(p);
check((await panel(p).locator('a[data-sub][href="/ads/multiplier"]').getAttribute("aria-current")) === "page", "on Ad Multiplier its link is marked as the page");
check((await panel(p).locator('[aria-current="page"]').count()) === 1, "and nothing else is");
+ check((await panel(p).locator('a[href="/marketing"]:not([data-sub])').getAttribute("data-active")) === "", "and Marketing Studio shows it holds the page");
+ await p.keyboard.press("Escape");
+ // A feature the menu doesn't link for a visitor still marks its studio (Character Sheet's modes).
+ await openRoute(p, `${app}/character-sheet?mode=cast`, { settleMs: 300 });
+ await openStudios(p);
+ check((await panel(p).locator('a[href="/character-sheet"]:not([data-sub])').getAttribute("data-active")) === "", "on Character Sheet's Build from scratch, Character Sheet is marked");
// Every link resolves (those the window hides too).
const hrefs = [...new Set(await panel(p).locator("a[data-sub]").evaluateAll((as_) => as_.map((a) => a.getAttribute("href"))))];
const bad = [];
@@ -323,9 +369,11 @@ try {
const body = sheet.locator('[data-sheet-family="studios"]');
await body.locator("a[href]").first().waitFor({ timeout: 10_000 });
check((await body.locator("[data-sheet-subs]").count()) === 0, `${label}: All shows tiles only`);
+ check((await body.locator('a[href="/ads"]').count()) === 1, `${label}: All keeps the Ads Studio tile`);
const chip = (name) => sheet.locator('[role="group"][aria-label="Show the studios for one goal"]').getByRole("button", { name, exact: true });
for (const [g, studio, want] of [
- ["Sell", "Marketing Studio", ["Click to Ad", "Ads Studio", "Ad Multiplier"]],
+ // Ads Studio is a tile of Sell (and of All), so not a pill again.
+ ["Sell", "Marketing Studio", ["Click to Ad", "Ad Multiplier"]],
["People", "Genjutsu", ["Motion transfer", "Character swap", "Object swap", "Restyle", "Insert"]],
["Film", "Video tools", ["Remove background", "Relight", "Captions"]],
["Finish", "Upscale", ["Image", "Video", "FPS Boost", "SDR to HDR", "Export"]],
@@ -440,6 +488,13 @@ try {
check(/Click to Ad/.test(cta[0] ?? ""), `search (${who}): "click to ad" finds Click to Ad first`, cta.slice(0, 3).join(" | "));
const blockout = await ask("blockout");
check(blockout.some((t) => /^Blockout|Blockout Cinema|Cinema Studio.*Blockout|Blockout.*Cinema/.test(t)) === (who === "owner"), `search (${who}): Blockout ${who === "owner" ? "found" : "not found"}`, blockout.slice(0, 3).join(" | "));
+ {
+ await ask("genjutsu");
+ const heads = await p.locator("[cmdk-group-heading]").allInnerTexts();
+ const inGen = await p.locator('[cmdk-group]:has([cmdk-group-heading]:text-is("In Genjutsu")) [cmdk-item]').allInnerTexts();
+ const modes = ["Motion transfer", "Character swap", "Object swap", "Restyle", "Insert"];
+ check(heads.some((h) => h.trim().toLowerCase() === "in genjutsu") && modes.every((m) => inGen.some((t) => t.includes(m))), `search (${who}): "genjutsu" lists its modes right after it`, `${heads.join(" | ")} :: ${inGen.join(" | ").replace(/\s+/g, " ")}`);
+ }
if (who === "guest") {
await ask("restyle");
await p.keyboard.press("Enter");
diff --git a/tests/e2e/nav.mjs b/tests/e2e/nav.mjs
index d64ca0bd..18871fcc 100644
--- a/tests/e2e/nav.mjs
+++ b/tests/e2e/nav.mjs
@@ -301,9 +301,9 @@ try {
await p.waitForTimeout(350);
const tiles = sheet.locator("ul").first().getByRole("link");
const seen = await inView(tiles);
- // 32 tiles (Ads Studio is under Marketing Studio, in the Sell group) and the closing See all.
- if (size.height >= 844) check(seen.length === 33 && seen.every(Boolean), `${label}: the Studios sheet shows all 32 and See all without scrolling`, `${seen.filter(Boolean).length}/${seen.length}`);
- else check(seen.length === 33, `${label}: the Studios sheet lists all 32 and See all (it scrolls inside at this height)`, String(seen.length));
+ // 33 tiles (Ads Studio keeps its tile here; the desktop menu lists it under Marketing Studio) and the closing See all.
+ if (size.height >= 844) check(seen.length === 34 && seen.every(Boolean), `${label}: the Studios sheet shows all 33 and See all without scrolling`, `${seen.filter(Boolean).length}/${seen.length}`);
+ else check(seen.length === 34, `${label}: the Studios sheet lists all 33 and See all (it scrolls inside at this height)`, String(seen.length));
await sheet.getByRole("button", { name: /^Film/ }).tap();
check((await sheet.locator("ul").first().getByRole("link").count()) === 9, `${label}: the Film chip shows 8 and See all`);
if (size.height >= 844) await shot(p, "phone-studios-sheet-film-390");
diff --git a/tests/mega-menus.test.ts b/tests/mega-menus.test.ts
index 4ca0170a..967a6453 100644
--- a/tests/mega-menus.test.ts
+++ b/tests/mega-menus.test.ts
@@ -162,8 +162,10 @@ describe("Studios as a menu", () => {
for (const kind of [undefined, "guest", "account", "owner"] as const) {
const m: MegaModel = studiosMenu(kind);
expect(m.columns.map((c) => [c.id, c.lead?.id, ...c.rows.map((r) => r.id)])).toEqual(
- launcherColumns(kind).map((c) => [c.group.id, c.lead.id, ...c.rest.filter((e) => !subParent(e.id)).map((e) => e.id)]),
+ launcherColumns(kind).map((c) => [c.group.id, c.lead.id, ...c.rest.map((e) => e.id)]),
);
+ // The desktop menu lists Ads Studio under Marketing Studio, not as a row (the phone's sheet keeps its tile).
+ expect(megaItems(m).filter((e) => e.under).map((e) => [e.id, e.under])).toEqual([["ads", subParent("ads")]]);
const marketing = m.columns.find((c) => c.id === "sell")!.lead!;
expect(marketing.subs!.map((s) => [s.id, s.href])).toEqual([
["marketing-click-to-ad", "/marketing/click-to-ad"],
@@ -171,7 +173,9 @@ describe("Studios as a menu", () => {
["ads-multiplier", "/ads/multiplier"],
]);
// A studio's features stay out of the phone's "All" (megaItems: leads and rows).
- expect(megaItems(m).some((e) => e.id === "ads" || e.id.startsWith("genjutsu-"))).toBe(false);
+ expect(megaItems(m).some((e) => e.id.startsWith("genjutsu-"))).toBe(false);
+ // Built once per kind of viewer.
+ expect(studiosMenu(kind)).toBe(m);
}
});
});
diff --git a/tests/nav-bar.test.ts b/tests/nav-bar.test.ts
index 95b1b4c1..4cb0a715 100644
--- a/tests/nav-bar.test.ts
+++ b/tests/nav-bar.test.ts
@@ -148,14 +148,16 @@ describe("the launcher's columns", () => {
expect(main).toHaveLength(33);
expect(new Set(main.map((a) => a.href)).size).toBe(33);
expect(launcherColumns(undefined).map((c) => 1 + c.rest.length)).toEqual([8, 6, 6, 6, 5, 3]);
- expect(studiosMenu(undefined).columns.map((c) => 1 + c.rows.length)).toEqual([8, 6, 5, 6, 5, 3]);
+ // Ads Studio stays in the model (the phone's sheet keeps its tile); the desktop menu lists it under Marketing Studio.
+ expect(studiosMenu(undefined).columns.map((c) => 1 + c.rows.filter((e) => !e.under).length)).toEqual([8, 6, 5, 6, 5, 3]);
+ expect(studiosMenu(undefined).columns.flatMap((c) => c.rows.filter((e) => e.under).map((e) => [e.id, e.under]))).toEqual([["ads", "marketing"]]);
expect(launcherColumns(undefined).map((c) => c.lead.id)).toEqual(["cinema", "shorts", "marketing", "fashion-factory", "audio", "upscale"]);
expect(html).toContain("grid-cols-6");
// The arrow keys' places: the lead, its features, then each row and its features, top to bottom.
for (const [i, c] of studiosMenu(undefined).columns.entries()) {
const at = (href: string, sub: boolean) => anchors(html).find((a) => a.href === href && a.tag.includes(`data-col="${i}"`) && a.tag.includes("data-sub") === sub)?.tag ?? "";
let r = 0;
- for (const e of [c.lead!, ...c.rows]) {
+ for (const e of [c.lead!, ...c.rows.filter((x) => !x.under)]) {
expect(at(e.href, false), e.id).toContain(`data-col="${i}" data-row="${r++}"`);
for (const s of e.subs ?? []) expect(at(s.href, true), s.id).toContain(`data-col="${i}" data-row="${r++}"`);
}
@@ -175,11 +177,13 @@ describe("the launcher's columns", () => {
expect(subs("audio")).toEqual(["Dialogue", "Voice change", "Design a voice", "See all 13"]);
expect(subs("video-tools")).toEqual(["Relight", "Captions", "Remove object", "See all 10"]);
for (const w of ["Click to Ad", "Ads Studio", "Ad Multiplier", "Motion transfer", "FPS Boost"]) expect(words(html)).toContain(w);
- // Under a hairline, quieter than a row, with no picture and no line of their own.
+ // Under a hairline, quieter than a row, with no picture and no line of their own (nav-states.css .nav-subs: 24 px
+ // names with a mouse, 44 px pills to tap on a touch screen).
const sub = anchors(html).find((a) => a.tag.includes("data-sub"))!.tag;
- expect(sub).toContain("text-[12.5px]");
- expect(sub).toContain("min-h-7");
- expect(sub).toContain("[@media(pointer:coarse)]:min-h-11");
+ expect(sub).toContain("text-muted-foreground");
+ expect(html).toMatch(/<ul[^>]*class="nav-subs /);
+ // A "See all N" says whose.
+ expect(html).toContain('aria-label="See all 13 in Audio"');
});
it("labels the groups, and every link has its studio's real cover in a box of fixed size", () => {
@@ -206,6 +210,35 @@ describe("the launcher's columns", () => {
expect(anchors(on).find((a) => a.href === "/katana")?.tag).toContain('aria-current="page"');
});
+ it("on a studio's feature, marks the feature and shows its studio as holding the page (no second aria-current)", () => {
+ const studio = (html: string, href: string) => anchors(html).find((a) => a.href === href && !a.tag.includes("data-sub"))?.tag ?? "";
+ const restyle = render(createElement(LauncherColumns, { kind: undefined, current: "genjutsu-restyle", now: 0 }));
+ expect(count(restyle, 'aria-current="page"')).toBe(1);
+ expect(anchors(restyle).find((a) => a.href === "/genjutsu?mode=restyle")?.tag).toContain('aria-current="page"');
+ expect(studio(restyle, "/genjutsu")).toContain('data-active=""');
+ expect(studio(restyle, "/genjutsu")).not.toContain("aria-current");
+ // A lead card too (Marketing Studio on Click to Ad), and a feature the menu doesn't link for a visitor (Character
+ // Sheet's modes): its studio is still marked.
+ expect(studio(render(createElement(LauncherColumns, { kind: undefined, current: "marketing-click-to-ad", now: 0 })), "/marketing")).toContain('data-active=""');
+ const cast = render(createElement(LauncherColumns, { kind: undefined, current: "character-sheet-cast", now: 0 }));
+ expect(count(cast, 'aria-current="page"')).toBe(0);
+ expect(studio(cast, "/character-sheet")).toContain('data-active=""');
+ // Nothing is marked as holding a page on a studio's own page.
+ expect(render(createElement(LauncherColumns, { kind: undefined, current: "genjutsu", now: 0 }))).not.toContain("data-active");
+ });
+
+ it("gives Genjutsu's modes one wrapped line on a short window, and pads an odd list to whole rows", () => {
+ const ul = (id: string) => html.match(new RegExp(`<ul[^>]*data-subs="${id}"[^>]*>`))?.[0] ?? "";
+ expect(ul("genjutsu")).toContain("data-subs-line");
+ // With a mouse it never hides (the line takes over); on a touch screen it needs 1024 px.
+ expect(ul("genjutsu")).not.toContain("[@media(max-height:799.98px)]:hidden");
+ expect(ul("genjutsu")).toContain("[@media(pointer:coarse)_and_(max-height:1023.98px)]:hidden");
+ expect(ul("video-tools")).toContain("[@media(max-height:879.98px)]:hidden");
+ expect(ul("video-tools")).not.toContain("data-subs-line");
+ expect(ul("marketing")).toContain("data-odd");
+ expect(ul("audio")).not.toContain("data-odd");
+ });
+
it("shows New badges only until their date", () => {
const newOnes = NAV_ENTRIES.filter((e) => e.group && e.newUntil);
const before = render(createElement(LauncherColumns, { kind: undefined, now: 0 }));
diff --git a/tests/nav-subfeatures.test.ts b/tests/nav-subfeatures.test.ts
index f56a4cd0..1a3dbc0b 100644
--- a/tests/nav-subfeatures.test.ts
+++ b/tests/nav-subfeatures.test.ts
@@ -179,6 +179,24 @@ describe("finding a studio's features", () => {
expect(top("motion transfer")).toMatchObject({ id: "genjutsu-motion", href: "/genjutsu?mode=motion" });
});
+ it("lists a studio's features right after it when the studio is the best match, in the studio's order", () => {
+ const inside = (kind: ViewerKind | undefined, q: string) => find(kind, q).groups[0];
+ expect(find("guest", "genjutsu").best[0]).toMatchObject({ id: "genjutsu" });
+ expect(inside("guest", "genjutsu")).toMatchObject({ label: "In Genjutsu" });
+ expect(inside("guest", "genjutsu").hits.map((h) => h.label)).toEqual(["Motion transfer", "Character swap", "Object swap", "Restyle", "Insert"]);
+ expect(inside("owner", "genjutsu").hits.map((h) => h.label)).toEqual(["Motion transfer", "Character swap", "Object swap", "Restyle", "Insert", "From picture", "Finish"]);
+ expect(inside("guest", "character sheet").hits.map((h) => h.label)).toEqual(["From Reference", "Build from scratch", "From a description"]);
+ // Not a tab that is the studio's own page (Upscale's Image), nor one already among the best matches.
+ const upscale = find("guest", "upscale");
+ const listed = [...upscale.best, ...upscale.groups[0].hits].map((h) => h.label);
+ for (const t of ["video", "fps boost", "sdr to hdr", "export"]) expect(listed.some((l) => l.toLowerCase().includes(t)), `${t}: ${listed.join(", ")}`).toBe(true);
+ expect(upscale.groups[0].hits.some((h) => h.href === "/upscale")).toBe(false);
+ expect(new Set(listed).size).toBe(listed.length);
+ // Up to eight, and never a group for something that isn't a studio.
+ expect(inside("guest", "audio").hits.length).toBeLessThanOrEqual(8);
+ expect(find("guest", "restyle").groups.some((g) => g.label.startsWith("In "))).toBe(false);
+ });
+
it("finds the owner's own only for the owner", () => {
const hits = (kind: ViewerKind | undefined, q: string) => {
const r = find(kind, q);
diff --git a/tests/phone-nav.test.ts b/tests/phone-nav.test.ts
index bdac06d0..0988393a 100644
--- a/tests/phone-nav.test.ts
+++ b/tests/phone-nav.test.ts
@@ -22,10 +22,7 @@ import { PhoneTabs } from "@/components/nav/phone-tabs";
import { StudiosSheet } from "@/components/nav/studios-sheet";
import { PhoneBar } from "@/components/phone-bar";
import { navCovers } from "@/lib/nav-covers";
-import { activeEntry, LAUNCHER_GROUPS, launcherEntries as allLauncherEntries, studioCount, subParent, type LauncherGroupId, type ViewerKind } from "@/lib/nav-model";
-
-/** The studios as tiles: every launcher entry but one that is a tab of another's suite (Ads Studio, under Marketing Studio). */
-const launcherEntries = (kind: ViewerKind | undefined, group?: LauncherGroupId) => allLauncherEntries(kind, group).filter((e) => !subParent(e.id));
+import { activeEntry, LAUNCHER_GROUPS, launcherEntries, studioCount } from "@/lib/nav-model";
/*
* The phone's navigation (below md): the tab bar (Home, Create, Studios, Library, You), the Studios sheet with every
@@ -192,15 +189,16 @@ describe("the Studios sheet", () => {
// The grid ends on a See all tile (/studios): the family's whole set. A studio's features are pills under it.
const tiles = (html: string) =>
[...html.matchAll(/<a [^>]*href="([^"]*)"[^>]*>/g)]
- .filter((m) => !m[0].includes("tab-pill"))
+ .filter((m) => !m[0].includes("data-sub"))
.map((m) => m[1].replaceAll("&amp;", "&"))
.filter((h) => h !== "/" && h !== "/library" && h !== "/studios");
- const pills = (html: string) => [...html.matchAll(/<a [^>]*class="tab-pill[^>]*>([^<]*)</g)].map((m) => m[1]);
+ const pills = (html: string) => [...html.matchAll(/<a data-sub=""[^>]*>([^<]*)</g)].map((m) => m[1]);
- it("shows every studio, Apps and the Sound modes (33 tiles, 29 studios), in launcher order, each with a real cover", () => {
+ it("shows every studio, Apps and the Sound modes (34 tiles, 29 studios), in launcher order, each with a real cover", () => {
const html = at("/", () => sheet());
const all = launcherEntries(undefined);
- expect(all).toHaveLength(33);
+ // Ads Studio keeps its tile here (the desktop menu lists it under Marketing Studio).
+ expect(all).toHaveLength(34);
// All is one screen of tiles: a studio's features show under one group only.
expect(pills(html)).toEqual([]);
expect(studioCount()).toBe(29);
@@ -237,7 +235,7 @@ describe("the Studios sheet", () => {
});
it("starts on the group it was opened for", () => {
- const sizes = { film: 8, social: 6, sell: 5, people: 6, sound: 5, finish: 3 } as const;
+ const sizes = { film: 8, social: 6, sell: 6, people: 6, sound: 5, finish: 3 } as const;
for (const g of LAUNCHER_GROUPS) {
const html = at("/", () => sheet({ group: g.id }));
expect(tiles(html), g.id).toEqual(launcherEntries(undefined, g.id).map((e) => e.href));
@@ -248,7 +246,8 @@ describe("the Studios sheet", () => {
it("lists what a group's studios hold inside as pills under the tiles, by their tabs' names, as a visitor may run them", () => {
const sell = at("/", () => sheet({ group: "sell" }));
- expect(pills(sell)).toEqual(["Click to Ad", "Ads Studio", "Ad Multiplier"]);
+ // Ads Studio is a tile of the group already: not a pill again.
+ expect(pills(sell)).toEqual(["Click to Ad", "Ad Multiplier"]);
expect(words(sell)).toContain("Marketing Studio");
const people = at("/", () => sheet({ group: "people" }));
expect(pills(people)).toEqual(["Motion transfer", "Character swap", "Object swap", "Restyle", "Insert"]);
@@ -267,6 +266,10 @@ describe("the Studios sheet", () => {
const html = at("/ads/multiplier", () => sheet({ group: "sell" }));
expect(tagWith(html, 'href="/ads/multiplier"')).toContain('aria-current="page"');
expect(tagWith(html, 'href="/marketing"')).toContain('aria-current="page"');
+ // A feature with a tile of its own marks that tile.
+ const ads = at("/ads", () => sheet({ group: "sell" }));
+ expect(tagWith(ads, 'href="/ads"')).toContain('aria-current="page"');
+ expect(tagWith(ads, 'href="/marketing"')).not.toContain('aria-current="page"');
});
it("marks the studio you are in", () => {