Repository navigation
Add Edit in Snack buttons to example pages - #26
Merged
Merged
Conversation
A remark plugin adds a button above the code of allowlisted examples that opens an unsaved Snack on web with @rnmapbox/maps 10.3.14, loading the example and its helpers from the release tag.
2 of 8 tasks
rnmapbox/maps writes the example's snackSupported (defaulting to webSupported) to the snack_supported front matter; pages without it fall back to the "Try it on web" link. The web link becomes a "Run on web" button next to "Edit in Snack". CameraAnimation and QueryTerrainElevation now run in Snack with the turf dependencies Snackager leaves out.
mfazekas
marked this pull request as ready for review
October 27, 2026 20:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an "Edit in Snack" button to example pages, next to the existing web example link, which becomes a "Run on web" button in the same row. "Edit in Snack" opens an unsaved Snack in web-only mode with
@rnmapbox/maps@10.3.14andmapbox-gl. The Snack'sApp.jscallssetWorkerUrland fetches the public Snack token from rnmapbox/ci-config at runtime. The example and the shared helpers it imports are loaded by URL from thev10.3.14tag, so the code matches the pinned release. Inlining the examples would push some URLs past snack.expo.dev's ~15k limit, which returns HTTP 431.Which examples get the button comes from rnmapbox/maps: the example's
snackSupportedmetadata (defaulting towebSupported) is written to the page'ssnack_supportedfront matter, see rnmapbox/maps#4416. Until those pages are regenerated, the button follows the "Try it on web" link, so this works with the current docs too (40 pages; GeoJSONSource and ImageOverlay are skipped because their URL can't be built). The build fails if a page hassnack_supported: truebut imports files the Snack can't load.With the docs regenerated from #4416, 49 pages get the button. Each was opened from the locally built page in headless Chromium and showed a rendered map, mapbox tiles returning 200, and no error overlay; TransparentMap requests no tiles by design and was checked visually against the hosted web app. CameraAnimation and QueryTerrainElevation now work:
@turf/bboxneeds@turf/helpersand@turf/metaadded explicitly, and@turf/lengthis pinned to 6.3.0 for Snack because 6.5.0 needs@babel/runtime, which Snackager can't bundle. GeoJSONSource and ImageOverlay opt out in #4416: Snack parses URL-loaded PNGs as code even when passed as assets.When bumping
RNMAPBOX_MAPS_VERSIONinplugins/snack/snackUrl.js, recheck the Snack-enabled examples.