Skip to content

Map: colours follow the nearest StyleScope - #619

Merged
lorant-one merged 2 commits into
previewfrom
fix/map-colours-follow-style-scope
Nov 25, 2026
Merged

lorant-one merged 2 commits into
previewfrom
fix/map-colours-follow-style-scope

Conversation

@lorant-one

Copy link
Copy Markdown
Member

Requested by Lorant · project thread

I found this while building a film over the Studio MCP. In the film's map flyover, <MapRoute tone="accent"> drew its route orange, which is once-ui.com's page accent. It should have been the film's own accent, which comes from the StyleScope the film plays in.

Cause

MapLibre's paint properties need plain colours, so tokenColor() resolves each token to an rgb() string. It always read the token from document.documentElement. That means any map inside a StyleScope (another brand, accent or theme) painted in the page's colours.

Fix

  • tokenColor(variable, fallback, from?) now reads the token from the element it's given.
  • Every caller passes map.getContainer(): MapRoute, MapArea, MapCircle, the dark basemap tint in Map.impl and the 3D buildings in scene.
  • tokenColor is internal to the map module and isn't exported, so nothing public changes.
  • There's a CHANGELOG entry under Unreleased › Fixed.

Checks

  • pnpm typecheck in packages/core is clean.
  • Biome on src/modules/map reports only the one warning that's already on preview (an unused React type import in MapCircle).
  • I haven't checked it in a browser. Studio picks it up after the next core release; then the flyover's route takes the film's accent, and I'll confirm it in the film.

This is a non-breaking patch fix, a candidate for the next 3.1.x.


Generated by Claude Code

tokenColor() read every token on the page root, so a Map inside a
StyleScope painted routes, areas, circles, 3D buildings and the basemap
tint in the page's colours. It now takes the element to read on, and
every caller passes the map's container.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtzVFyZmmZBfzzYmfhr
Test doubles for the map (and any map-like object an app passes) have no
getContainer, which made MapRoute throw. Fall back to the page root.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtzVFyZmmZBfzzYmfhr
@lorant-one
lorant-one merged commit 545e510 into preview Nov 25, 2026
9 checks passed
@lorant-one lorant-one added the approved label Nov 26, 2026 — with Claude
@lorant-one lorant-one mentioned this pull request Nov 26, 2026
7 tasks done
@lorant-one
lorant-one deleted the fix/map-colours-follow-style-scope branch November 29, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants