mirror of
https://github.com/maputnik/editor.git
synced 2026-11-27 04:23:45 +00:00
# fix: improve previews for small sprites ## Description Small sprites appeared at their original display size in the sprite picker, making them difficult to recognize when choosing an icon or pattern. - Render previews in a fixed 36 × 36 CSS pixel canvas. Scale and center each sprite while preserving its aspect ratio. - Prefer matching `@2x.json` metadata and `@2x.png` atlas for previews. Use the base atlas when `@2x` metadata is unavailable. - Size the canvas backing store for the display's device pixel ratio. Preserve query strings and fragments when building sprite URLs. Follow-up to [#2364](https://github.com/maplibre/maputnik/pull/2364), which extended sprite previews to all sprite-backed fields as part of [#1294](https://github.com/maplibre/maputnik/issues/1294). ## Visuals ### Before Small sprites appear at their original display size in the picker.  ### After The same sprites are scaled to fit the fixed-size preview using the `@2x` atlas.  ## Verification All checks for this change passed. - Playwright covers the `@2x` atlas, the centered 36 × 36 preview for a small rectangular sprite, the 72 × 72 canvas at device pixel ratio 2, and the base atlas fallback. Existing coverage exercises SDF, sprite selection, image failures, and catalog updates. - `npm run lint` - `npm run lint-css` - `npm run build` - `npm run test-unit -- --run` (55 passed) - `npm run test -- e2e/sprite-picker.spec.ts --workers=2` (21 passed) - Confirmed that deliberately changing the expected CSS width, backing canvas width, and fallback pixel color fails the corresponding tests. Restored the correct assertions. ## Launch Checklist - [x] Briefly describe the changes in this PR. - [x] Link to related issues. - [x] Include before/after visuals or GIFs if this PR includes visual changes. - [x] Write tests for all new functionality. - [x] Add an entry to `CHANGELOG.md` under the `## main` section. Co-authored-by: FantasticSPM <asd507172@gmail.com>