diff --git a/docs/screenshots/ui-polish/00-before-apps-list.webp b/docs/screenshots/ui-polish/00-before-apps-list.webp new file mode 100644 index 0000000..3b18cc9 Binary files /dev/null and b/docs/screenshots/ui-polish/00-before-apps-list.webp differ diff --git a/docs/screenshots/ui-polish/00-before-mobile-toolbar.webp b/docs/screenshots/ui-polish/00-before-mobile-toolbar.webp new file mode 100644 index 0000000..d4d13cc Binary files /dev/null and b/docs/screenshots/ui-polish/00-before-mobile-toolbar.webp differ diff --git a/docs/screenshots/ui-polish/01-apps-list.webp b/docs/screenshots/ui-polish/01-apps-list.webp new file mode 100644 index 0000000..4274758 Binary files /dev/null and b/docs/screenshots/ui-polish/01-apps-list.webp differ diff --git a/docs/screenshots/ui-polish/02-apps-detail.webp b/docs/screenshots/ui-polish/02-apps-detail.webp new file mode 100644 index 0000000..852e80b Binary files /dev/null and b/docs/screenshots/ui-polish/02-apps-detail.webp differ diff --git a/docs/screenshots/ui-polish/03-roles-list.webp b/docs/screenshots/ui-polish/03-roles-list.webp new file mode 100644 index 0000000..49ca11e Binary files /dev/null and b/docs/screenshots/ui-polish/03-roles-list.webp differ diff --git a/docs/screenshots/ui-polish/04-roles-detail.webp b/docs/screenshots/ui-polish/04-roles-detail.webp new file mode 100644 index 0000000..3cd6c13 Binary files /dev/null and b/docs/screenshots/ui-polish/04-roles-detail.webp differ diff --git a/docs/screenshots/ui-polish/05-xray-legend.webp b/docs/screenshots/ui-polish/05-xray-legend.webp new file mode 100644 index 0000000..ff4296e Binary files /dev/null and b/docs/screenshots/ui-polish/05-xray-legend.webp differ diff --git a/docs/screenshots/ui-polish/06-used-by.webp b/docs/screenshots/ui-polish/06-used-by.webp new file mode 100644 index 0000000..34b8a70 Binary files /dev/null and b/docs/screenshots/ui-polish/06-used-by.webp differ diff --git a/docs/screenshots/ui-polish/07-guided-path.webp b/docs/screenshots/ui-polish/07-guided-path.webp new file mode 100644 index 0000000..02bf05c Binary files /dev/null and b/docs/screenshots/ui-polish/07-guided-path.webp differ diff --git a/docs/screenshots/ui-polish/08-mobile-toolbar.webp b/docs/screenshots/ui-polish/08-mobile-toolbar.webp new file mode 100644 index 0000000..26cdeb1 Binary files /dev/null and b/docs/screenshots/ui-polish/08-mobile-toolbar.webp differ diff --git a/docs/screenshots/ui-polish/09-mobile-role.webp b/docs/screenshots/ui-polish/09-mobile-role.webp new file mode 100644 index 0000000..fae7ceb Binary files /dev/null and b/docs/screenshots/ui-polish/09-mobile-role.webp differ diff --git a/docs/screenshots/ui-polish/10-light-apps.webp b/docs/screenshots/ui-polish/10-light-apps.webp new file mode 100644 index 0000000..8ecfe9f Binary files /dev/null and b/docs/screenshots/ui-polish/10-light-apps.webp differ diff --git a/docs/screenshots/ui-polish/11-keyboard-focus.webp b/docs/screenshots/ui-polish/11-keyboard-focus.webp new file mode 100644 index 0000000..8418e67 Binary files /dev/null and b/docs/screenshots/ui-polish/11-keyboard-focus.webp differ diff --git a/docs/screenshots/ui-polish/12-shortcuts.webp b/docs/screenshots/ui-polish/12-shortcuts.webp new file mode 100644 index 0000000..22693ac Binary files /dev/null and b/docs/screenshots/ui-polish/12-shortcuts.webp differ diff --git a/frontend/e2e/smoke.spec.ts b/frontend/e2e/smoke.spec.ts index 1cf7fb1..d9fd1c6 100644 --- a/frontend/e2e/smoke.spec.ts +++ b/frontend/e2e/smoke.spec.ts @@ -181,3 +181,44 @@ test("An ?app= link opens straight onto that app's stack", async ({ page }) => { await page.goto("/?app=netflix"); await expect(page.getByRole("region", { name: "Famous apps" }).getByRole("heading", { name: "Netflix" })).toBeVisible({ timeout: 20_000 }); }); + +test("Apps show logos, arrow keys move through the grid, and โ† / โ†’ step between apps", async ({ page }) => { + await page.goto("/?app="); + const panel = page.getByRole("region", { name: "Famous apps" }); + await expect(panel.locator(".apps-grid svg").first()).toBeVisible({ timeout: 20_000 }); + const first = panel.locator(".apps-grid button").first(); + await first.focus(); + await page.keyboard.press("ArrowRight"); + await expect(panel.locator(".apps-grid button").nth(1)).toBeFocused(); + await page.keyboard.press("End"); + await expect(panel.locator(".apps-grid button").last()).toBeFocused(); + await panel.locator(".apps-grid button").first().click(); + await expect(panel.getByRole("heading", { name: "Netflix" })).toBeVisible(); + await panel.getByRole("button", { name: /^Next: / }).click(); + await expect(panel.getByRole("heading", { name: "Spotify" })).toBeVisible(); + await page.keyboard.press("["); + await expect(panel.getByRole("heading", { name: "Netflix" })).toBeVisible(); +}); + +test("Roles have emojis, ?role= opens the list, and ] steps to the next role", async ({ page }) => { + await page.goto("/?role="); + const panel = page.getByRole("region", { name: "Role paths" }); + await expect(panel.locator(".role-list .role-emoji").first()).toHaveText("๐ŸŽจ", { timeout: 20_000 }); + await panel.getByRole("button", { name: /Frontend engineer/ }).click(); + await expect(panel.getByRole("heading", { name: "Frontend engineer" })).toBeVisible(); + await page.keyboard.press("]"); + await expect(panel.getByRole("heading", { name: "Backend engineer" })).toBeVisible(); + await expect(page).toHaveURL(/[?&]role=backend-engineer/); +}); + +test("On a phone the toolbar scrolls behind a โ†’ button instead of running off-screen", async ({ page }) => { + await page.setViewportSize({ width: 390, height: 844 }); + await page.goto("/"); + await expect(page.getByText(/\d+ nodes ยท \d+ edges/)).toBeAttached({ timeout: 20_000 }); + const more = page.getByRole("button", { name: "Scroll atlas modes right" }); + await expect(more).toBeVisible(); + await more.click(); + await expect(page.getByRole("button", { name: /Switch to (light|dark) theme/ })).toBeInViewport(); + const width = await page.evaluate(() => document.documentElement.scrollWidth); + expect(width).toBeLessThanOrEqual(390); +}); diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 292a26c..4a8e00b 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -25,6 +25,7 @@ "@vitejs/plugin-react": "^4.3.3", "eslint": "^9.13.0", "jsdom": "^25.0.1", + "simple-icons": "^16.38.1", "typescript": "^5.6.3", "typescript-eslint": "^8.12.2", "vite": "^5.4.10", @@ -1118,9 +1119,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1245,9 +1243,6 @@ "arm" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1262,9 +1257,6 @@ "arm" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1279,9 +1271,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1296,9 +1285,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1313,9 +1299,6 @@ "loong64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1330,9 +1313,6 @@ "loong64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1347,9 +1327,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1364,9 +1341,6 @@ "ppc64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1381,9 +1355,6 @@ "riscv64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1398,9 +1369,6 @@ "riscv64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1415,9 +1383,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1432,9 +1397,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1449,9 +1411,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -4120,6 +4079,26 @@ "graphology-utils": "^2.5.2" } }, + "node_modules/simple-icons": { + "version": "16.38.1", + "resolved": "https://registry.npmjs.org/simple-icons/-/simple-icons-16.38.1.tgz", + "integrity": "sha512-q4JnGp1cgeASp4jzEsmSh/7BD/e2y7aYO8XST+QBEvOJ5wzZ/9WRmKsI+QUwkfPUSiXC+sfh2+QetD38zl3N0g==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/simple-icons" + }, + { + "type": "github", + "url": "https://github.com/sponsors/simple-icons" + } + ], + "license": "CC0-1.0", + "engines": { + "node": ">=0.12.18" + } + }, "node_modules/source-map-js": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", diff --git a/frontend/package.json b/frontend/package.json index b9052e6..2fc5e82 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -35,6 +35,7 @@ "@vitejs/plugin-react": "^4.3.3", "eslint": "^9.13.0", "jsdom": "^25.0.1", + "simple-icons": "^16.38.1", "typescript": "^5.6.3", "typescript-eslint": "^8.12.2", "vite": "^5.4.10", diff --git a/frontend/scripts/build-app-logos.mjs b/frontend/scripts/build-app-logos.mjs new file mode 100644 index 0000000..1209bc8 --- /dev/null +++ b/frontend/scripts/build-app-logos.mjs @@ -0,0 +1,40 @@ +/* global console, process */ +// Writes src/content/appLogos.ts: one brand mark per famous app, taken from Simple Icons +// (CC0, https://simpleicons.org). Only the 40-odd marks the Apps panel needs are kept, so +// the chunk stays small; it loads on demand the first time a logo is drawn. +// Apps with no mark in Simple Icons (some brands asked to be removed) get a monogram tile. +// Run after adding an app to data/seed/apps.json: node scripts/build-app-logos.mjs +// Logos are trademarks of their owners and are shown only to identify each company. +import { readFileSync, writeFileSync } from "node:fs"; +import { join } from "node:path"; +import * as icons from "simple-icons"; + +// App id (apps.json) -> Simple Icons slug, where it differs or needs a pick. +const SLUG = { + "khan-academy": "khanacademy", + "x-twitter": "x", + "google-search": "google", + "stack-overflow": "stackoverflow", +}; + +const root = join(import.meta.dirname, ".."); +const apps = JSON.parse(readFileSync(join(root, "..", "data", "seed", "apps.json"), "utf8")); +const bySlug = new Map(Object.values(icons).filter((i) => i && i.slug).map((i) => [i.slug, i])); +const out = {}; +const missing = []; +for (const app of apps) { + const icon = bySlug.get(SLUG[app.id] ?? app.id); + if (icon) out[app.id] = { hex: icon.hex, path: icon.path }; + else missing.push(app.id); +} +const lines = Object.entries(out).map(([id, l]) => ` ${JSON.stringify(id)}: { hex: "${l.hex}", path: ${JSON.stringify(l.path)} },`); +writeFileSync(join(root, "src", "content", "appLogos.ts"), `// Generated by scripts/build-app-logos.mjs from Simple Icons (CC0). Do not edit by hand. +// Logos are trademarks of their owners, shown only to identify each company. +// No mark available (shown as a monogram): ${missing.join(", ") || "none"}. +export interface BrandMark { hex: string; path: string } +export const APP_LOGOS: Record = { +${lines.join("\n")} +}; +`); +console.log(`wrote ${Object.keys(out).length} logos; monogram for: ${missing.join(", ") || "none"}`); +process.exit(0); diff --git a/frontend/scripts/check-bundle-size.mjs b/frontend/scripts/check-bundle-size.mjs index 1f99af1..3dc0082 100644 --- a/frontend/scripts/check-bundle-size.mjs +++ b/frontend/scripts/check-bundle-size.mjs @@ -13,16 +13,18 @@ import { gzipSync } from "node:zlib"; // lazily loaded chunk (src/content/data.ts), which loads alongside the graph. // content: that chunk. ~24 KB with 145 paths / 11 roles / 22 apps, ~49 KB after the // 3,000-node content pass (257 paths / 32 roles / 40 apps). -const BUDGETS = { js: 172_000, css: 15_000, woff2: 60_000, graph: 280_000, content: 56_000 }; +// logos: famous-app brand marks (src/content/appLogos.ts), fetched when the Apps panel or a +// "Used by" chip first draws. ~14 KB for 35 marks. +const BUDGETS = { js: 172_000, css: 15_000, woff2: 60_000, graph: 280_000, content: 56_000, logos: 18_000 }; const dir = join(process.cwd(), "dist", "assets"); let failed = false; -const totals = { js: 0, css: 0, woff2: 0, content: 0 }; +const totals = { js: 0, css: 0, woff2: 0, content: 0, logos: 0 }; for (const file of readdirSync(dir)) { const ext = file.split(".").pop(); if (!(ext in totals)) continue; const buf = readFileSync(join(dir, file)); // The entry chunk counts as js and the content chunk on its own; other lazy chunks load on demand. - const key = ext === "js" && file.startsWith("data-") ? "content" : ext; + const key = ext === "js" && file.startsWith("data-") ? "content" : ext === "js" && file.startsWith("appLogos-") ? "logos" : ext; if (key === "js" && !file.startsWith("index-")) continue; const size = ext === "woff2" ? statSync(join(dir, file)).size : gzipSync(buf).length; totals[key] += size; diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 0fb4f16..3b63ec5 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -29,8 +29,11 @@ import { connectionPath } from "./graph/compare"; import { StackPanel } from "./components/StackPanel"; import { readStack, writeStack, type StackParams } from "./recommend/stackLink"; import { RolePanel } from "./components/RolePanel"; -import { readRole, writeRole } from "./graph/roles"; +import { readRole, readRolesOpen, writeRole } from "./graph/roles"; import { AppsPanel } from "./components/AppsPanel"; +import { ScrollRow } from "./components/ScrollRow"; +import { useStepKeys } from "./components/StepNav"; +import { arrowNav } from "./util/arrowNav"; import { readApp, readAppsOpen, writeApp } from "./graph/apps"; import { PathsLibrary } from "./components/PathsLibrary"; import { @@ -137,12 +140,12 @@ export default function App() { window.history.replaceState(null, "", `${window.location.pathname}${query ? `?${query}` : ""}`); }, [stackParams]); // Role / career lens: ?role= reopens a role's path. - const [roleOpen, setRoleOpen] = useState(() => readRole(window.location.search) !== null); + const [roleOpen, setRoleOpen] = useState(() => readRolesOpen(window.location.search)); const [roleId, setRoleId] = useState(() => readRole(window.location.search)); const [roleHighlight, setRoleHighlight] = useState<{ nodes: string[]; edges: string[] }>({ nodes: [], edges: [] }); const onRoleHighlight = useCallback((nodes: string[], edges: string[]) => setRoleHighlight({ nodes, edges }), []); useEffect(() => { - const query = writeRole(window.location.search, roleOpen ? roleId : null); + const query = writeRole(window.location.search, roleOpen ? roleId : null, roleOpen); window.history.replaceState(null, "", `${window.location.pathname}${query ? `?${query}` : ""}`); }, [roleOpen, roleId]); // Famous apps: ?app= reopens an app's stack (?app= alone opens the list). @@ -589,6 +592,14 @@ export default function App() { setJourneyStep(step); navigate(journeys()[index].steps[step].id); }, [navigate, openStack]); + // [ / ] and the โ† Previous / Next โ†’ buttons step through the guided path being followed. + const journeyPrev = useMemo(() => journeyIndex === null || journeyStep === 0 ? null : () => { + setJourneyStep(journeyStep - 1); navigate(journeys()[journeyIndex].steps[journeyStep - 1].id); + }, [journeyIndex, journeyStep, navigate]); + const journeyNext = useMemo(() => journeyIndex === null || journeyStep >= journeys()[journeyIndex].steps.length - 1 ? null : () => { + setJourneyStep(journeyStep + 1); navigate(journeys()[journeyIndex].steps[journeyStep + 1].id); + }, [journeyIndex, journeyStep, navigate]); + useStepKeys(journeyIndex !== null && !xrayOpen && !pathsOpen && !roleOpen && !appsOpen, journeyPrev, journeyNext); const nextPath = useMemo(() => journeyIndex === null || journeyStep !== journeys()[journeyIndex].steps.length - 1 ? null : suggestNextPath(pathEntries, journeys(), journeyIndex, donePaths), [pathEntries, journeyIndex, journeyStep, donePaths]); // A returning visitor with an unfinished path is offered to pick it up from the hero. @@ -682,7 +693,8 @@ export default function App() { )} {/* Atlas tools: one quiet, uniform group. Labels collapse to icons on phones; each keeps its full accessible name. */} -