Skip to content

feat(docs): syntax highlighting palette for code samples - #246

Merged
pbroom merged 1 commit into
mainfrom
docs/syntax-colors
Oct 10, 2026
Merged

pbroom merged 1 commit into
mainfrom
docs/syntax-colors

Conversation

@pbroom

@pbroom pbroom commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Stack Context

Part of the docs overhaul stack (S1–S5). This PR sits on #245 and replaces the gray-only syntax styling with a hue palette.

What?

  • Adds five syntax roles to src/styles/tokens.ts: keyword (330°), function (255°), type (195°), constant (55°) and string (145°). Each theme uses one lightness and chroma: L 0.5 / C 0.16 in light, L 0.8 / C 0.12 in dark.
  • The roles are generated into tokens.css like the accent: sRGB fallbacks come from toSrgbGamut, and a display-p3 override applies when a role falls outside sRGB.
  • Punctuation, parameters and comments stay gray.
  • The Shiki CSS-variables theme gets a separate token-type scope, so types and functions read differently.
  • API signatures use the same palette:
    • The declared name is colored as a function, or as a type for classes, interfaces and type aliases.
    • Type references are colored as types.
    • The import line is highlighted.
  • Removes the font-weight emphasis on code tokens.
  • tokens.test.ts now holds every syntax role to 4.5:1 contrast on --code-bg in both themes.

Why?

Review feedback: code samples should have real syntax highlighting. Swatch chips still mark color literals as data.

Validation

  • pnpm lint, pnpm build, pnpm test (docs 844, core 904, driver 150, react 217), pnpm format:check and pnpm agents:check:strict all pass. The docs typecheck also passes.
  • A scan of the prerendered dist found token colors in all 826 <pre> blocks.
  • Checked in the browser, in light and dark themes, on /start, /api/core/toCss and /guides/react.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
color-kit Ready Ready Preview Oct 10, 2026 2:47am UTC

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-08T12:29:22.274900Z d515f1a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This was referenced Oct 8, 2026

pbroom commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@greptile-apps

greptile-apps Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Low risk] Updates syntax highlighting colors in the docs site.

The PR appears safe to merge, with a non-blocking gap in the syntax contrast tests.

Fix All in CursorFindings

  1. P2 Rendered contrast goes unchecked ▶

Summary

Adds a generated syntax palette for code samples and API signatures.

  • Gives keywords, functions, types, constants, and strings distinct colors.
  • Provides sRGB colors and wider-gamut P3 overrides for both themes.
  • Expands contrast checks, but those checks should also cover the generated colors.

Reviews (1) · Last reviewed commit: "feat(docs): syntax highlighting palette ..." · Reviewed by Greptile

Comment thread apps/docs/src/styles/tokens.ts

@pbroom pbroom left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the full incremental PR and its corrections at 3e002262154e09706505b57bf4389f457ff335b3. Syntax palette reviewed; all36 emitted syntax contrast combinations pass. No remaining actionable findings in the reviewed scope.

Independent correction re-reviews and stack preservation verification passed. At the integrated tip, lint, full build/DTS, 2,208 tests, formatting, strict agent checks and 14 built-site Chrome tests passed. All recorded actionable review threads are addressed. Hosted CI is being verified separately; this review does not authorize merge or release.

@pbroom
pbroom force-pushed the docs/syntax-colors branch from 3e00226 to 8c6ff55 Compare October 8, 2026 18:54
@pbroom
pbroom force-pushed the docs/s5-react-map-search branch from d031ce6 to bcfcfe9 Compare October 8, 2026 18:54

@pbroom pbroom left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final re-review at 8c6ff553c5d215e53a3d08d66d18f2b775b57634: Syntax palette reviewed; all36 emitted syntax contrast combinations pass. The hosted dependency-test follow-up is included; no remaining actionable findings in scope.

All 12 final stack heads now pass CI, including Node 20/22 and the plane benchmark. Final local lint, build/DTS, 2,209 tests, formatting and strict agent checks pass. The 14 built-site browser checks passed on unchanged application code; the follow-up changes only the regression test and archive lesson. Vercel previews are tracked separately while pending.

pbroom commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner Author

Merge activity

  • Oct 10, 6:47 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Oct 10, 8:32 PM UTC: Graphite rebased this pull request as part of a merge.
  • Oct 10, 8:33 PM UTC: @pbroom merged this pull request with Graphite.

@pbroom
pbroom changed the base branch from docs/s5-react-map-search to graphite-base/246 October 10, 2026 20:28
@pbroom
pbroom changed the base branch from graphite-base/246 to main October 10, 2026 20:30
Give code tokens hue (keyword, function, type, constant, string) generated
with color-kit, with sRGB fallbacks and P3 overrides, and hold each role to
4.5:1 on the code background in both themes. API signatures share the palette.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@pbroom
pbroom force-pushed the docs/syntax-colors branch from b2f627d to 654ae90 Compare October 10, 2026 20:31
@vercel

vercel Bot commented Oct 10, 2026

Copy link
Copy Markdown

Deployment failed for project color-kit with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/pbrooms-projects?upgradeToPro=build-rate-limit

@pbroom
pbroom merged commit 8f74d19 into main Oct 10, 2026
5 of 6 checks passed
@pbroom
pbroom deleted the docs/syntax-colors branch October 10, 2026 20:33
pbroom added a commit that referenced this pull request Oct 10, 2026
…247)

## Stack Context

First of three PRs that cut `color-kit/react` down to state utilities and performance primitives (#247 → #248 → #249). This one sits on #246 (`docs/syntax-colors`) and is additive: the new hooks land next to the existing components, which now delegate to them.

## What?

New headless hooks. They own no DOM and take one plane, `ColorPlaneSpec = { color, axes? }`, where `axes` is the driver's `ColorAreaAxes`.

- **`useColorPlaneRenderer(plane, options)`** is the `ColorPlane` rasterizer reshaped into a hook.
  - It keeps the WebGL path, the CPU fallback, the context-loss / restore handling and GPU cleanup on unmount.
  - It keeps the render-key dedupe (moving along an axis channel does not repaint), the DPR × `resolutionScale` × quality-scaled backing store, and rAF + `ResizeObserver` redraws.
  - It returns a stable callback `ref`, a `canvasKey` and the active `renderer`. The caller must use `canvasKey` as the canvas `key`: a canvas is locked to its first context kind, so the GPU ↔ CPU swap needs a fresh element. The hook warns once if the key is dropped.
- **Geometry hooks** return memoized points plus `toSvgPath` / `toSvgCompoundPath` data for a `0 0 100 100` viewBox. They keep the layers' sync-at-rest / worker-while-dragging behaviour.
  - `useGamutBoundary` and `useChromaBand`. `useChromaBand` takes core's `ChromaBandMode`: `'clamped'` / `'proportional'`.
  - `useContrastRegion` returns `path` (contours) and `fillPath` (closed fill polygons). It keeps frozen drag sampling, the stable-fill fallback, the boundary snapping and closure, and `onMetrics`. Its non-rendering geometry moved out of `contrast-region-layer.tsx` into `contrast-region-geometry.ts`.
  - `useFallbackPoints` returns the sRGB and Display P3 fallback points.
- **`useAdaptiveQuality(profile)`** is `ColorArea`'s frame-cost quality controller, extracted.
- `ColorPlane` and `ColorArea` now run on `useColorPlaneRenderer` and `useAdaptiveQuality`, so the existing component tests cover the hooks too.
- New tests: `use-color-plane-renderer.test.tsx` and `plane-geometry-hooks.test.tsx` (39 cases). They port the WebGL lifecycle, CPU fallback and edge-behaviour cases, and the contrast fill-side, APCA polarity, sampling and worker-metrics cases.
- A changeset (`'color-kit': minor`) for the new hooks.

## Why?

Approved API reduction: `color-kit/react` keeps state and perf primitives, and UI components go. Landing the hooks first keeps every step green and lets #249 delete the components without losing the renderer or the overlay math.

## Validation

- `pnpm lint`, `pnpm build` (including DTS and the docs build), `pnpm test` (core 921, driver 157, react 256, docs 938), `pnpm format:check`, `pnpm agents:check:strict`, `pnpm check:preprod` and `pnpm --filter @color-kit/docs typecheck` all pass.
- `eval-dependencies.test.ts` passes locally on macOS.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant