From fa5b28ea69f3bff0941f8a097a9746b7a67fa900 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Wed, 24 Jun 2026 14:44:28 -0400 Subject: feat(theme-studio): nerd-icons gallery as a hue-ordered icon grid The nerd-icons pane is now a grid: one row per color face, the rows ordered by hue so families cluster, distinct icons (deduped within a color) drawn in their color with the icon's nerd-font name beneath. A "preview:" dropdown above the grid picks the glyph size in points, with Left/Right arrows to step it. Single-pane apps show it disabled, naming the preview. This replaces the v1 legend in the pane, whose data is still captured for round-trip. build-nerd-icons-legend.el is now a library. A cj/nerd-icons-write-legend entry point requires nerd-icons only at write time, so the capture logic loads and unit-tests without it. It dedupes icons by name within a face, computes each face's native hue, and orders the groups by hue. Writing the test surfaced a latent bug: face-hsl used (cadr (assoc t spec)), which grabs the first keyword instead of the plist. It only worked because the real faces fall through to the face-foreground branch. I fixed it to a correct t-clause parse. Coverage: 7 ERT capture tests (dedupe, hue order, lightness tiebreak, name sort, skip rules), 4 Python validator edges, and browser gates for the grid and the size dropdown. Locate stays color-level: clicking a color flashes its icons, and clicking an icon flashes its color row. Icons aren't individually editable, so there's nothing per-icon to select. --- scripts/theme-studio/app_inventory.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'scripts/theme-studio/app_inventory.py') diff --git a/scripts/theme-studio/app_inventory.py b/scripts/theme-studio/app_inventory.py index 09e2ed0a0..ade71a0ef 100644 --- a/scripts/theme-studio/app_inventory.py +++ b/scripts/theme-studio/app_inventory.py @@ -50,15 +50,19 @@ def add_inventory_apps(apps: dict[str, Any], inventory_path: str) -> dict[str, A return apps -def add_nerd_icons_app(apps: dict[str, Any], inventory_path: str, legend: Any) -> dict[str, Any]: +def add_nerd_icons_app(apps: dict[str, Any], inventory_path: str, legend: Any, + gallery: Any = None) -> dict[str, Any]: """Register nerd-icons as a bespoke legend app from its inventory faces. The 34 nerd-icons color faces stay editable rows; LEGEND (the validated rows from generate.load_nerd_icons_legend) rides the app so the bespoke previews.js - renderer can draw each filetype glyph in its mapped face color. A no-op when - LEGEND is falsy or the inventory lacks nerd-icons -- the caller guards on a - valid legend, and add_inventory_apps then creates the generic fallback app. - Must run before add_inventory_apps so the generic path skips nerd-icons. + renderer can draw each filetype glyph in its mapped face color. GALLERY (the + full colored catalog grouped by face, from generate.load_nerd_icons_gallery) + rides alongside when present so the same renderer can draw the gallery section; + a falsy GALLERY simply omits it (legend-only). A no-op when LEGEND is falsy or + the inventory lacks nerd-icons -- the caller guards on a valid legend, and + add_inventory_apps then creates the generic fallback app. Must run before + add_inventory_apps so the generic path skips nerd-icons. """ if not legend or not os.path.exists(inventory_path): return apps @@ -66,12 +70,15 @@ def add_nerd_icons_app(apps: dict[str, Any], inventory_path: str, legend: Any) - faces = json.load(src).get("nerd-icons") if not faces: return apps - apps["nerd-icons"] = { + app = { "label": "nerd-icons", "preview": "nerdicons", "faces": [[face, face_label(face, "nerd-icons-"), {}] for face in faces], "legend": legend, } + if gallery: + app["gallery"] = gallery + apps["nerd-icons"] = app return apps -- cgit v1.2.3