Context
Prerequisite engine leaf for the standalone-examples theme switcher Engine 14 release blocker (@tobiu, 2026-11-21). Today apps/portal/view/ViewportController.mjs:302, apps/workstation/view/Workspace.mjs:882, examples/code/livePreview/MainContainer.mjs:102, and eight examples/grid/*/MainContainer.mjs files each hand-roll Neo.main.DomAccess.startViewTransition for binary light/dark toggling, while 5-theme examples (board/*, scheduler/*, gantt/*, timeline/*) and 4-theme examples (menu/context) have no reusable multi-theme dropdown switcher at all.
The Problem
- Without a first-class engine button component, adding theme switching across ~80+ non-workbench examples would duplicate
startViewTransition + icon/label sync logic dozens of times.
- Binary toggles (
neo-theme-neo-light ↔ neo-theme-neo-dark) cannot switch among 3+ themes (neo-theme-neo-light, neo-theme-neo-dark, neo-theme-light, neo-theme-dark, neo-theme-cyberpunk), whereas 2-theme apps should keep the fast 1-click sun/moon circular-wave toggle rather than requiring two clicks in a dropdown.
The Architectural Reality
src/main/DomAccess.mjs:1321 already provides Neo.main.DomAccess.startViewTransition({delay, reveal: {x, y}, windowId}) in the main thread, gracefully resolving when document.startViewTransition or prefers-reduced-motion skips animation.
src/button/Base.mjs (Neo.button.Base) already supports menu (Neo.menu.List lazy-created via beforeSetMenu / afterSetMenu), iconCls, text, ariaLabel, and ui.
- Sibling placement (
structural-pre-flight Stage 1 fast-path): src/button/ThemeSwitcher.mjs (ntype: 'theme-switcher') sits directly beside src/button/{Base,Split,Menu,Effect}.mjs, with structural styles in resources/css/src/button/ThemeSwitcher.css and theme tokens in resources/css/theme-{neo-light,neo-dark,light,dark,cyberpunk}/button/ThemeSwitcher.css.
- Design authority:
n/a — new engine button subclass encapsulating the established Portal/Workstation view-transition wave + multi-theme menu pattern.
The Fix
- Create
src/button/ThemeSwitcher.mjs (className: 'Neo.button.ThemeSwitcher', ntype: 'theme-switcher', extending Neo.button.Base):
themes_ reactive config (String[]|null, defaulting to null -> reads Neo.config.themes).
- Canonical theme label/icon map (
'neo-theme-neo-light': 'Neo Light', 'neo-theme-neo-dark': 'Neo Dark', 'neo-theme-light': 'Light', 'neo-theme-dark': 'Dark', 'neo-theme-cyberpunk': 'Cyberpunk', with clean fallback formatting for custom theme names).
- Resolves target component via
resolveThemeTarget() (this.target ? Neo.getComponent(this.target) : this.up('viewport')), reading current theme via target.getTheme() || themes[0] and observing target's theme config (observeConfig) so external or URL theme changes keep the button/menu state synchronized.
- 2-theme mode (
effectiveThemes.length === 2): Clicking toggles directly to the other theme after awaiting Neo.main.DomAccess.startViewTransition({delay: 100, reveal: {x: data?.clientX, y: data?.clientY}, windowId: this.windowId}).catch(() => {}); updates sun/moon icon (fa-solid fa-sun / fa-solid fa-moon or crisp inline CSS/glyph fallback when FontAwesome is not loaded in standalone examples — critical: standalone examples like gantt/basic and scheduler/basic do NOT load FontAwesome in index.html, so ThemeSwitcher.css MUST render crisp pure-CSS/SVG sun, moon, palette, and chevron indicators without depending on external icon fonts!).
- Multi-theme mode (
effectiveThemes.length > 2): Opens a floating Neo.menu.List (or lightweight anchored dropdown list) showing all configured themes with the active theme marked (aria-checked / active indicator); selecting a theme runs Neo.main.DomAccess.startViewTransition from the pointer coordinates (falling back to button center on keyboard Enter) and sets target.theme = selectedTheme.
- Add
resources/css/src/button/ThemeSwitcher.css and resources/css/theme-{neo-light,neo-dark,light,dark,cyberpunk}/button/ThemeSwitcher.css so ThemeSwitcher looks polished out of the box in any toolbar across all 5 themes at both desktop and 390 × 844 mobile widths (compact icon+label or icon-only compact option for narrow mobile toolbars!).
- Add unit/component + E2E tests (
test/playwright/unit/button/ThemeSwitcher.spec.mjs and/or test/playwright/component/button/ThemeSwitcher.spec.mjs) covering 2-theme wave toggle, 5-theme dropdown selection, keyboard operation, font-free icon rendering, and observeConfig sync.
Contract Ledger Matrix
| Target Surface |
Source of Authority |
Proposed Behavior |
Fallback |
Docs |
Evidence |
Neo.button.ThemeSwitcher (ntype: 'theme-switcher', src/button/ThemeSwitcher.mjs) |
src/button/Base.mjs, src/main/DomAccess.mjs:1321, apps/portal/view/ViewportController.mjs:302 |
themes.length === 2 toggles light↔dark on click with startViewTransition circular wave; themes.length > 2 opens theme dropdown and applies selected theme with circular wave |
Instant target.theme = nextTheme when startViewTransition is unsupported or useViewTransition: false; pure-CSS/SVG icons requiring no FontAwesome stylesheet |
JSDoc @class + @summary on src/button/ThemeSwitcher.mjs |
Playwright unit/component spec + 5-theme build guard |
Decision Record impact: none.
Acceptance Criteria
Out of Scope
- Mounting
ThemeSwitcher across the ~80 standalone examples (handled by the parallel family rollout leaves blocked by this ticket so peers can land all examples cleanly once this merges).
Avoided Traps
- Relying on
fa-solid fa-sun / fa-moon: most standalone examples (examples/gantt/*, examples/scheduler/*, examples/board/*) do NOT load FontAwesome CSS in index.html, so fa-* classes render nothing or tofu! Use pure CSS / inline data-URI / VDOM SVG glyphs inside ThemeSwitcher.
- Assuming
viewport.theme is non-null before first switch: per apps/portal/view/ViewportController.mjs:285, read target.getTheme() || effectiveThemes[0] so the first click always switches away from the rendered boot theme.
Related
- Blocks the family rollout leaves under the standalone-examples theme switcher epic.
- Existing wave callers:
apps/portal/view/ViewportController.mjs:302 · apps/workstation/view/Workspace.mjs:882
unowned-rationale: Engine 14 release-blocker prerequisite leaf open for immediate maintainer pickup so downstream example rollout leaves unblock quickly.
Live latest-open + closed sweep: checked latest 25 open (79 open total, red band — foundational leaf of new v14 release-blocker epic) + open and closed search (ThemeSwitcher, theme switcher examples, startViewTransition, Out of Scope read on #20879, #20932, #20635) at 2026-11-21T01:44Z; no equivalent found.
A2A in-flight sweep: scanned latest 30 messages across all read states (00:58Z–01:44Z); zero competing claim.
MC sweep: query_raw_memories + ask_knowledge_base (standalone examples theme switcher dropdown startViewTransition, 5 refs); no conflicting decision.
Own-assignment sweep: 1 open (#21621, PR #21694), disjoint.
Origin Session ID: 59ca0d8c-dfdf-4d07-aefe-8ec5c658a398
Retrieval Hint: "Neo.button.ThemeSwitcher theme-switcher 2-theme toggle 5-theme dropdown startViewTransition font-free SVG"
Context
Prerequisite engine leaf for the standalone-examples theme switcher Engine 14 release blocker (
@tobiu,2026-11-21). Todayapps/portal/view/ViewportController.mjs:302,apps/workstation/view/Workspace.mjs:882,examples/code/livePreview/MainContainer.mjs:102, and eightexamples/grid/*/MainContainer.mjsfiles each hand-rollNeo.main.DomAccess.startViewTransitionfor binary light/dark toggling, while5-theme examples (board/*,scheduler/*,gantt/*,timeline/*) and4-theme examples (menu/context) have no reusable multi-theme dropdown switcher at all.The Problem
startViewTransition+ icon/label sync logic dozens of times.neo-theme-neo-light↔neo-theme-neo-dark) cannot switch among3+themes (neo-theme-neo-light,neo-theme-neo-dark,neo-theme-light,neo-theme-dark,neo-theme-cyberpunk), whereas2-theme apps should keep the fast 1-click sun/moon circular-wave toggle rather than requiring two clicks in a dropdown.The Architectural Reality
src/main/DomAccess.mjs:1321already providesNeo.main.DomAccess.startViewTransition({delay, reveal: {x, y}, windowId})in the main thread, gracefully resolving whendocument.startViewTransitionorprefers-reduced-motionskips animation.src/button/Base.mjs(Neo.button.Base) already supportsmenu(Neo.menu.Listlazy-created viabeforeSetMenu/afterSetMenu),iconCls,text,ariaLabel, andui.structural-pre-flightStage 1 fast-path):src/button/ThemeSwitcher.mjs(ntype: 'theme-switcher') sits directly besidesrc/button/{Base,Split,Menu,Effect}.mjs, with structural styles inresources/css/src/button/ThemeSwitcher.cssand theme tokens inresources/css/theme-{neo-light,neo-dark,light,dark,cyberpunk}/button/ThemeSwitcher.css.n/a — new engine button subclass encapsulating the established Portal/Workstation view-transition wave + multi-theme menu pattern.The Fix
src/button/ThemeSwitcher.mjs(className: 'Neo.button.ThemeSwitcher',ntype: 'theme-switcher', extendingNeo.button.Base):themes_reactive config (String[]|null, defaulting tonull-> readsNeo.config.themes).'neo-theme-neo-light': 'Neo Light','neo-theme-neo-dark': 'Neo Dark','neo-theme-light': 'Light','neo-theme-dark': 'Dark','neo-theme-cyberpunk': 'Cyberpunk', with clean fallback formatting for custom theme names).resolveThemeTarget()(this.target ? Neo.getComponent(this.target) : this.up('viewport')), reading current theme viatarget.getTheme() || themes[0]and observingtarget'sthemeconfig (observeConfig) so external or URL theme changes keep the button/menu state synchronized.effectiveThemes.length === 2): Clicking toggles directly to the other theme after awaitingNeo.main.DomAccess.startViewTransition({delay: 100, reveal: {x: data?.clientX, y: data?.clientY}, windowId: this.windowId}).catch(() => {}); updates sun/moon icon (fa-solid fa-sun/fa-solid fa-moonor crisp inline CSS/glyph fallback when FontAwesome is not loaded in standalone examples — critical: standalone examples likegantt/basicandscheduler/basicdo NOT load FontAwesome inindex.html, soThemeSwitcher.cssMUST render crisp pure-CSS/SVG sun, moon, palette, and chevron indicators without depending on external icon fonts!).effectiveThemes.length > 2): Opens a floatingNeo.menu.List(or lightweight anchored dropdown list) showing all configured themes with the active theme marked (aria-checked/ active indicator); selecting a theme runsNeo.main.DomAccess.startViewTransitionfrom the pointer coordinates (falling back to button center on keyboardEnter) and setstarget.theme = selectedTheme.resources/css/src/button/ThemeSwitcher.cssandresources/css/theme-{neo-light,neo-dark,light,dark,cyberpunk}/button/ThemeSwitcher.csssoThemeSwitcherlooks polished out of the box in any toolbar across all 5 themes at both desktop and390 × 844mobile widths (compact icon+label or icon-onlycompactoption for narrow mobile toolbars!).test/playwright/unit/button/ThemeSwitcher.spec.mjsand/ortest/playwright/component/button/ThemeSwitcher.spec.mjs) covering 2-theme wave toggle, 5-theme dropdown selection, keyboard operation, font-free icon rendering, andobserveConfigsync.Contract Ledger Matrix
Neo.button.ThemeSwitcher(ntype: 'theme-switcher',src/button/ThemeSwitcher.mjs)src/button/Base.mjs,src/main/DomAccess.mjs:1321,apps/portal/view/ViewportController.mjs:302themes.length === 2toggles light↔dark on click withstartViewTransitioncircular wave;themes.length > 2opens theme dropdown and applies selected theme with circular wavetarget.theme = nextThemewhenstartViewTransitionis unsupported oruseViewTransition: false; pure-CSS/SVG icons requiring no FontAwesome stylesheet@class+@summaryonsrc/button/ThemeSwitcher.mjsDecision Record impact: none.
Acceptance Criteria
Neo.button.ThemeSwitcher(ntype: 'theme-switcher') works with zero external icon-font dependency (no broken squares in examples whoseindex.htmlloads onlyMicroLoader.mjs).viewport.themebetween them afterNeo.main.DomAccess.startViewTransitioncircular reveal from click coordinates, and reflects URL?theme=boot state accurately.viewport.themewithstartViewTransitioncircular reveal on selection.showText: falseor automatic compact styling below768px) so narrow390 × 844example toolbars do not overflow.node ./buildScripts/build/themes.mjs -f -n -e dev -t all,npm run check-theme-surfaces,check-theme-value-files.mjs,check-theme-var-references.mjs, and new Playwright specs pass.Out of Scope
ThemeSwitcheracross the ~80 standalone examples (handled by the parallel family rollout leaves blocked by this ticket so peers can land all examples cleanly once this merges).Avoided Traps
fa-solid fa-sun/fa-moon: most standalone examples (examples/gantt/*,examples/scheduler/*,examples/board/*) do NOT load FontAwesome CSS inindex.html, sofa-*classes render nothing or tofu! Use pure CSS / inline data-URI / VDOM SVG glyphs insideThemeSwitcher.viewport.themeis non-null before first switch: perapps/portal/view/ViewportController.mjs:285, readtarget.getTheme() || effectiveThemes[0]so the first click always switches away from the rendered boot theme.Related
apps/portal/view/ViewportController.mjs:302·apps/workstation/view/Workspace.mjs:882unowned-rationale: Engine 14 release-blocker prerequisite leaf open for immediate maintainer pickup so downstream example rollout leaves unblock quickly.
Live latest-open + closed sweep: checked latest 25 open (
79open total, red band — foundational leaf of new v14 release-blocker epic) + open and closed search (ThemeSwitcher,theme switcher examples,startViewTransition, Out of Scope read on#20879,#20932,#20635) at2026-11-21T01:44Z; no equivalent found. A2A in-flight sweep: scanned latest 30 messages across all read states (00:58Z–01:44Z); zero competing claim. MC sweep:query_raw_memories+ask_knowledge_base(standalone examples theme switcher dropdown startViewTransition, 5 refs); no conflicting decision. Own-assignment sweep: 1 open (#21621, PR#21694), disjoint.Origin Session ID: 59ca0d8c-dfdf-4d07-aefe-8ec5c658a398
Retrieval Hint: "Neo.button.ThemeSwitcher theme-switcher 2-theme toggle 5-theme dropdown startViewTransition font-free SVG"