Skip to content

feat(editor): adopt Spec design tokens, geometry/motion constants, and zero-literal enforcement (#1002) - #1249

Open
houko wants to merge 2 commits into
mainfrom
feat/editor-spec-tokens-1002
Open

houko wants to merge 2 commits into
mainfrom
feat/editor-spec-tokens-1002

Conversation

@houko

@houko houko commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the NSGo Game Editor design token system from docs/design/editor/Spec.dc.html and docs/design/editor/Viewport3D.dc.html as the editor's single source of truth:

  • Embedded YAML theme (packages/game/editor/spec_theme.yaml) & SpecPalette (spec_theme.go):
    • Parses with core.ParseTheme and attaches at EditorView's root scope via cx.SetTheme(SpecTheme()).
    • Maps every NSGo core.Palette / ui.ColorsOf role (Background, Surface, Raised, Line, Border, Text, TextMuted, Accent, AccentText: #101216, Success, Warning, Danger, Focus) onto the Spec tokens in both dark and light appearances.
    • Adds 3D axis tokens (AxisX, AxisY, AxisZ), Viewport3DGround, Viewport3DGrid, HoverOverlay, ActiveOverlay, and PrimaryHover from Viewport3D.dc.html.
  • Exported Spec geometry, typography, and reduced-motion constants:
    • Type scale (SpecFontTitleSize/Weight 14/600, body 12.5/400, section 11/600 +6% tracking, JetBrains Mono 11.5), spacing scale (4, 8, 12, 16, 24), radii (6, 8, 12, 18), heights (28, 30, 32, 44, minimum hit area 28x28), 1px inner border, and motion durations (120ms, 180ms, 240ms, 1.6s pulse) disabled cleanly under Env.ReduceMotion() (SpecMotionDuration, SpecAgentPulseOpacity).
  • Zero hardcoded UI color literals in packages/game/editor:
    • Replaced all hardcoded UI core.RGB/core.RGBA and hex color literals across panels, 2D/3D viewports, gizmos, handles, overlays, and debug layers with SpecPalette tokens (keeping scene-content defaults such as BackgroundColor as scene data).
    • Updated side panels (scene-tree-panel, layers-panel, asset-browser, file-browser, library-panel) to render in panel (colors.Surface()) with line borders, updated InspectorView to inherit SpecTheme() / Editor.SpecPalette(cx) live in both dark and light modes, and updated the toolbar scene title to 14/600.
  • Automated guardrails & tests (spec_theme_test.go, editorcmd/theme_screenshot_test.go):
    • TestSpecContrastTableDarkAndLight: measures WCAG 2.2 luminance contrast for every pair in the Spec contrast table from spec_theme.yaml (failing below 4.5:1 for text/on-fill or 3.0:1 for UI/overlay edges & 3D axes).
    • TestSpecContrastTableRejectsRetiredMutedColor: verifies mutating dark textMuted/specTextFaint back to #6F7684 fails the contrast table.
    • TestSpecNoHardcodedColorLiteralsInEditor: AST scan refusing core.RGB/core.RGBA calls or hardcoded UI hex literals anywhere in packages/game/editor outside spec_theme.go.
    • TestSpecEditorChromeRegionsAndSelectionOutline: verifies root bg, toolbar/status bar raised + line, toolbar title 14/600, side panels & inspector panel + line, viewport surround, and 2D selection outline in accent across dark and light modes.
    • TestSpecLightAndDarkThemeMacOSScreenshots: real macOS nsgotest screenshots (spec-editor-dark, spec-editor-light, spec-overlay-legend-dark/light, spec-toasts-dark/light).
  • Docs, PR template, notes, changelog:
    • Added "Design tokens" section to docs/en/editor.md and docs/zh/editor.md.
    • Added the Spec "Acceptance for every editor PR" checklist to .github/PULL_REQUEST_TEMPLATE.md.
    • Added agent note (.agents/notes/implemented/feature/2026-11-26-editor-spec-design-tokens.md) and changelog fragment (changelog.d/editor-spec-design-tokens.md).

Related issue

Closes #1002

Verification

  • git ls-files -z -- '*.go' | xargs -0 gofmt -l produced no output
  • go run ./cmd/gameschema -check passed
  • go tool nsgo check -target macos_arm64 passed (Depot CI checks all targets + iOS)
  • go tool nsgo test -run "TestSpec|TestEditorSystemAppearance|TestEditorToast|TestToastView" ./editor/... passed (14/14)
  • go tool nsgo test -target macos -run "TestSpecLightAndDarkThemeMacOSScreenshots" ./editor/editorcmd passed and generated real macOS screenshots
  • go run ./tools/changelog check passed
  • bun run verify-notes passed
  • Both docs/en/editor.md and docs/zh/editor.md updated

Acceptance for every editor PR

  • Real screenshots from nsgotest on macOS, before and after, beside the matching artboard (TestSpecLightAndDarkThemeMacOSScreenshots: spec-editor-dark, spec-editor-light, spec-overlay-legend-dark/light, spec-toasts-dark/light).
  • Uses only the tokens in packages/game/editor/spec_theme.yaml (SpecPalette), and every text pair is in the WCAG 2.2 contrast table.
  • Every control shows the focus ring and is reachable with Tab, F6, or arrow keys.
  • Every action has a shortcut row with a scope and a matching MCP tool (when applicable).
  • Overlays follow the Spec line-style legend; nothing is told apart by hue alone.
  • Reviewed by a person looking at the screenshots, not only by tests.

@github-actions github-actions Bot added enhancement New feature or request size/XL documentation Improvements or additions to documentation pkg/editor area/ci area/agents conflict Conflicts with the target branch; resolve before merging and removed size/XL labels Nov 26, 2026
@houko
houko force-pushed the feat/editor-spec-tokens-1002 branch from 7628d71 to 6f268b6 Compare November 26, 2026 11:37
@github-actions github-actions Bot added conflict Conflicts with the target branch; resolve before merging and removed conflict Conflicts with the target branch; resolve before merging labels Nov 26, 2026
@houko
houko force-pushed the feat/editor-spec-tokens-1002 branch from 6f268b6 to f3467a9 Compare November 26, 2026 12:11
@github-actions github-actions Bot added conflict Conflicts with the target branch; resolve before merging and removed conflict Conflicts with the target branch; resolve before merging labels Nov 26, 2026
@houko
houko force-pushed the feat/editor-spec-tokens-1002 branch from f3467a9 to 49d9a42 Compare November 26, 2026 12:30
@github-actions github-actions Bot added conflict Conflicts with the target branch; resolve before merging and removed conflict Conflicts with the target branch; resolve before merging labels Nov 26, 2026
@houko
houko force-pushed the feat/editor-spec-tokens-1002 branch from 49d9a42 to 4cf7a95 Compare November 26, 2026 12:48
@github-actions github-actions Bot added conflict Conflicts with the target branch; resolve before merging and removed conflict Conflicts with the target branch; resolve before merging labels Nov 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agents area/ci conflict Conflicts with the target branch; resolve before merging documentation Improvements or additions to documentation enhancement New feature or request pkg/editor size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Editor: the Spec's design tokens as the editor's theme, with a measured contrast table

1 participant