Skip to main content
All work

Token Adventure

Personal project · Interactive learning

Learning design tokens one level at a time.

A browser game where you write tokens, run them in a sandbox, and pass checks against the 2025.10 Design Tokens Format. I designed the curriculum and interface, and built the editor, execution sandbox, and assertion engine.

My role
Designer and engineer
Built with
Astro, React, CodeMirror
Scope
Learning game and test engine
20
coding levels
3
learning arcs, beginner to expert
Token Adventure game screenshot with a retro arcade interface and design token coding curriculum
Game screenshot · Token Adventure

Live game

Pick a sector from the star chart, write your tokens, run them in the sandbox, and clear the sector when every check passes. You can load the game below and play it on this page.

live interactive
Token Adventure: a retro arcade cabinet UI with a pilot dossier, a high score, and a 'Press Start' to begin the design-tokens curriculum
Token Adventure

Scope and results

Skills
  • Interactive learning & curriculum design
  • In-browser code execution & sandboxing
  • Test-harness engineering
  • W3C Design Tokens Format
  • Accessibility engineering
  • Motion design
Stack
  • Astro 5
  • React island
  • CodeMirror
  • Sandboxed iframe
  • axe-core
  • Netlify
Quality
  • Faithful to the stable 2025.10 spec
  • Grading based on spec rules, such as resolved aliases
  • Reduced-motion honored on every effect
  • astro check and a clean build before each release
Outcomes
  • 20 sectors across three arcs
  • A serializable assertion engine
  • Companion to Rudiment UI

I came up with the idea while playing Galaga Wars on my phone. Watching the ship rank up wave after wave, I realized I should be leveling up on the W3C Design Tokens Format instead. It had just become stable at version 2025.10, and I wanted to understand it properly instead of skimming it. The spec is useful but a dry read, so I built a game around it.

Each sector you clear covers one more part of the spec, and your code has to pass a real grader to clear it, so finishing the game shows you can apply the format.

Why a game

Design tokens are table stakes for any serious design system, but the W3C format is hard to internalize from the source material. The spec is precise by necessity: $value, $type, group inheritance, aliases, composite types. That precision makes it a good reference but hard to learn from: after reading it, you know the terms but not how to apply them.

In the game, you learn aliases by using one to clear a sector. Each rule is a sector you can't pass until your code applies it, the fixed sequence gives you a path, and pass-or-fail results tell you what to fix. By the end, you have written spec-correct tokens yourself.

How it works

Token Adventure looks like a deep-space arcade cabinet. You select sectors from a star chart, clear waves, log intel to a pilot log, and rank up from Recruit to Ace. Under that presentation, every sector is a small coding exercise. The preview shows your code running, and a pass means your tokens meet the spec.

  1. 01

    An NPC frames the problem

    A story panel states the real failure the concept prevents: a brand color hardcoded in five places, a dangling alias that locks a team out of a build.

  2. 02

    You write real code

    A CodeMirror editor with the right language modes (JSON for tokens.json, plus CSS, HTML, and JS where the sector calls for it). Only the tabs a sector needs are shown.

  3. 03

    It runs in a sandbox

    The host builds an srcdoc document from your editor and loads it with sandbox="allow-scripts" and no same-origin access, so player code cannot reach the host page.

  4. 04

    A test runner grades it

    Assertions are posted into the iframe over postMessage, evaluated against the live DOM and your parsed token tree, then posted back. Pass them all and the wave clears.

  5. 05

    You earn rewards

    XP, a badge, and a pilot-log entry that distills the lesson into a reusable snippet. Clear a full arc and a celebration interstitial fires.

Architecture

  • Astro 5 renders the static surfaces (star chart, story panels, one route per sector). No client JS ships for these.
  • One React island carries the sector runner: editor, sandbox, and test list. It loads only on quest pages.
  • The sandbox is an iframe srcdoc with sandbox="allow-scripts". Player code cannot reach the host page.
  • The test runtime speaks to the host over postMessage, with a request-id handshake and a timeout so a broken script cannot hang the grader.
  • axe-core is pulled into the sandbox to run real accessibility audits against the player’s rendered output.
  • Progress is saved in localStorage. There is no backend and no account.

The assertion engine

Grading the exercises means inspecting code that runs in an isolated sandbox the host page can't reach directly. The solution is a fully serializable assertion DSL: every check is a plain data object, so it crosses the postMessage boundary into the sandbox, runs there against the live DOM and parsed token tree, and returns a plain result.

DOM & accessibility checks

  • selectorExists · tagName · notTagName

    Structure and semantics

  • computedStyle

    Resolved CSS values: exact, regex, or one-of a set

  • contrast

    WCAG contrast ratios (AA normal, AA large, AAA)

  • axe

    Runs axe-core, optionally scoped to specific rule ids

  • keyboardReachable

    Tab-order reachability

  • hasAttribute · textMatches

    ARIA and content

Design-token checks

  • tokenJsonValid

    Confirms it parses at all

  • tokenHasPath · tokenFieldEquals

    Structure and field values

  • tokenTypeMatches

    Honors $type inheritance from ancestor groups

  • tokenAliasResolves

    Follows {alias} reference chains to a final value

  • cssVarFromToken

    Reads a CSS custom property to confirm a token wired through

The design-token checks follow the spec's rules instead of matching text. tokenAliasResolves doesn’t look for the string {color.brand.primary} in your file. It follows the reference chain the way a translation tool would and checks the resolved value, so players can't pass by pattern-matching.

The final sector is a broken tokens.json file with four realistic 2025.10 violations, and the player has to find and fix all four. It is the closest the game gets to real design system work.

Curriculum

Twenty sectors are grouped into three arcs, in the order the spec has to be learned: foundations first, then aliases and composite types, then build, theming, migration, and audit work. You can’t reason about aliases until you can name a single token, and you can’t audit a broken library until you understand the types it’s supposed to honor.

Arc I Beginner

The foundations: why tokens exist, the file, naming, color, groups, consuming.

  • 01 The Hardcoded Hellscape Why tokens exist: a named decision gets one home
  • 02 The Registry Awakens tokens.json, $value and $type
  • 03 The Cartographer's Codex Naming and path rules
  • 04 Color the 2025 Way Object-form color: colorSpace, components, alpha, hex
  • 05 Forge a Group Groups and $type inheritance
  • 06 Self-Documenting Tokens $description
  • 07 Reading the Registry Consuming semantic tokens
Arc II Intermediate

Relationships and composites: aliases, layering, types, and the composite shapes.

  • 08 Echoes and Aliases Alias references
  • 09 Three-Tier Architecture Global, semantic, and component layers
  • 10 Types of the Realm Token types and their canonical value shapes
  • 11 Composite Constructs The typography composite
  • 12 Border Composite The border composite
  • 13 Shadow Composite Shadow, including multi-shadow arrays
  • 14 Gradient and Transition The gradient and transition composites
Arc III Expert

Production, theming, and audit: the pipeline, integrity, color spaces, migration, the boss.

  • 15 The Translation Pipeline tokens.json to CSS custom properties
  • 16 Alias Integrity Detecting dangling and circular references
  • 17 Color Spaces Color spaces and wide-gamut output
  • 18 Theming and Modes Modes as a tooling convention, flagged as not in the spec
  • 19 The Great Reformation Migrating a legacy file to 2025.10
  • 20 Audit the Library The final audit boss

Accessibility

Token Adventure builds accessibility into the game and also teaches it. In the game itself, every motion effect becomes static under prefers-reduced-motion, and the celebration interstitial is a real dialog with focus management, Escape and backdrop dismissal, and a scroll lock.

In the lessons, several sectors grade the player’s rendered output with axe, contrast, and keyboardReachable assertions, holding the player to the same WCAG AA ratios and axe-core rules the app holds itself to. You learn to ship tokens that produce accessible interfaces.

Accessibility features

  • Every motion effect gated behind prefers-reduced-motion
  • Celebration modal: role="dialog", aria-modal, focus management
  • Escape and backdrop dismissal, background scroll lock
  • Parallax disables itself on coarse and touch pointers
  • Sectors grade output with the same contrast math the app holds itself to
  • Sectors run axe and keyboardReachable against the player’s UI

Visual design and motion

The arcade is built entirely from CSS and the Web Animations API, with no game loop and no canvas. The constraint was deliberate: keep the bundle small and the Core Web Vitals clean while still feeling like an arcade game. Difficulty is color-coded throughout, cyan for beginner, yellow for intermediate, and magenta for expert, so color always signals which arc you are in.

A CRT boot sequence

A one-shot scanline sweep across the cabinet plus a marquee-title power-on flicker, built in CSS and the Web Animations API.

Dual-layer neon glow

A tight tube core plus a soft bloom, over a corner-vignetted field, so lit elements look like neon tubes instead of flat drop shadows.

Animated star chart

A scout ship follows the mission route via CSS offset-path while a nebula drifts opposite the cursor through a transform-only, rAF-throttled handler.

The game is built on the same kind of token system it teaches: three tiers, with light, dark, and high-contrast modes, matching the architecture in sector 9.

Because the refresh was motion-heavy, I built a precision feedback loop instead of eyeballing changes: a headless-Chrome screenshot harness captures every key screen at desktop and mobile for before-and-after diffing, and a ?nomotion escape hatch freezes the reveal animations so full-page captures show the settled layout. I also held the source to zero em-dashes and en-dashes anywhere, verified by grep, and shipped only after astro check and a clean build pass.

Token Adventure is a companion to Rudiment UI. This game teaches the token format, and Rudiment UI shows how to build a component library on top of those tokens.