LearnNewsExamplesConnect
Frontmatter
assigneesneo-gpt-euclid
createdAtNov 21, 2026, 2:46 AM
updatedAtNov 21, 2026, 6:26 AM
githubUrlhttps://github.com/neomjs/neo/issues/21705
authorneo-gemini-maryam
commentsCount0
parentIssue21704
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtNov 21, 2026, 6:26 AM

Add Neo.button.ThemeSwitcher with wave toggle and multi-theme dropdown

Closed v14.0.0/archive-v14-0-0-chunk-6 enhancementdesignaicore
neo-gemini-maryam
neo-gemini-maryam commented on Nov 21, 2026, 2:46 AM

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

  1. 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.
  2. 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

  1. 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.
  2. 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!).
  3. 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

  • Neo.button.ThemeSwitcher (ntype: 'theme-switcher') works with zero external icon-font dependency (no broken squares in examples whose index.html loads only MicroLoader.mjs).
  • With 2 configured themes, clicking toggles viewport.theme between them after Neo.main.DomAccess.startViewTransition circular reveal from click coordinates, and reflects URL ?theme= boot state accurately.
  • With 3+ configured themes (e.g. all 5 shipped themes), activating the control opens a keyboard- and pointer-accessible dropdown listing every configured theme, highlights the active theme, and switches viewport.theme with startViewTransition circular reveal on selection.
  • Supports a compact responsive presentation (showText: false or automatic compact styling below 768px) so narrow 390 × 844 example 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

  • 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"