Commit Graph
7 Commits
Author SHA1 Message Date
FantasticSPMandFantasticSPM 648831ac67 fix: improve previews for small sprites (#2370)
# 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.

![Small oneway sprite before the
change](https://github.com/user-attachments/assets/91c353fc-2ea0-4550-9554-94dcf83ad4fa)

### After

The same sprites are scaled to fit the fixed-size preview using the
`@2x` atlas.

![Larger oneway sprite after the
change](https://github.com/user-attachments/assets/aab062a8-13b4-4e2a-8d59-8652be7d731f)

## 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>
2026-11-26 23:09:35 +02:00
Grimace (奶昔大哥)andCodex 54f0ba140a feat: preview sprites in the icon-image picker (#2359)
## Description

Add a dedicated sprite autocomplete for literal `icon-image` values.
Each searchable option shows its thumbnail and name, and selection keeps
the original sprite ID in the style. Keyboard selection and free-form
text remain available; expressions continue to use the existing
expression editor. Pattern fields keep their existing inputs.

The preview uses atlas bounds and pixel ratios. SDF sprites are decoded
into neutral black silhouettes using MapLibre's distance-field contour,
rather than displaying the distance bitmap. This is a catalog preview,
not a rendering of the layer's data/zoom-dependent paint or halos.
Sprite arrays retain MapLibre namespaces, and URL query parameters
remain after the JSON/PNG extension.

Metadata responses from a previous style are ignored after the sprite
source changes. Missing atlas images leave the names usable. The menu
opens above the field when there is not enough space below it.

Fixes #1294. Implements the scope proposed in the issue and welcomed by
CommanderStorm; follows #1792's request for a separate sprite input with
images in the option rows. No new dependencies or changes to the generic
`InputAutocomplete` component.

## Visuals

| Before | After |
| --- | --- |
| ![Text-only sprite
menu](https://raw.githubusercontent.com/jjohnnystwsss/maputnik/d368f3509fbb7c308ecdce6c97701af982bff14c/before.png)
| ![Sprite menu with
thumbnails](https://raw.githubusercontent.com/jjohnnystwsss/maputnik/d368f3509fbb7c308ecdce6c97701af982bff14c/after.png)
|

SDF preview beside the actual MapLibre render of the selected fixture:

![SDF preview and map
rendering](https://raw.githubusercontent.com/jjohnnystwsss/maputnik/d368f3509fbb7c308ecdce6c97701af982bff14c/after-sdf.png)

[Isolated screenshots and
provenance](https://github.com/jjohnnystwsss/maputnik/tree/d368f3509fbb7c308ecdce6c97701af982bff14c)
(not part of the feature diff).

## Verification

- Five new pure-logic tests cover URL handling, metadata
namespaces/bounds, empty sources and SDF alpha conversion; all 55 unit
tests pass.
- Fifteen new driver-based browser cases cover actual option pixels,
search, mouse/keyboard selection, viewport placement, persisted style
values, expression editing, sprite replacement/removal, namespaces,
broken images and delayed old responses.
- On the untouched base, the thumbnail assertion fails while all four
text options are present.
- Deliberately changing the expected thumbnail color fails; disabling
the stale-response guard also fails. Both mutations were reverted.
- Full official `npm test -- --workers 2`: all 199 cases pass (184
existing + 15 new). Lint, SCSS lint and type-checked production build:
passed.

Small sprite fixtures were authored for this change and carry the
repository's MIT license. No external tile, sprite or paid service is
required by the new cases.

Codex assisted with the design, implementation and tests; the preview
and actual map output were inspected locally.

## 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: Codex <noreply@openai.com>
2026-11-24 10:07:05 +02:00
Harel Mandpre-commit-ci[bot] 0fbba4b362 Fix missing font auto complete menu (#1491)
## Launch Checklist

This fixes the position of the autocomplete list - CSS fix mostly.
It also changes the loading of the metadata to be using promises instead
of callbacks.

I couldn't reproduce the following issue, so I'll be closing it for now.
- Fixes #945

Before:
<img width="563" height="577" alt="image"
src="https://github.com/user-attachments/assets/6ea264e1-cb85-4a8a-8df5-ab50e7815333"
/>

After:
<img width="563" height="577" alt="image"
src="https://github.com/user-attachments/assets/27fa2901-dd96-44fd-9774-363fd4c5ed98"
/>


 - [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.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-11-06 16:31:14 +02:00
dependabot[bot]andHarel M 5fe38bb6ff chore(deps-dev): Bump typescript from 5.8.3 to 5.9.2 (#1301)
Bumps [typescript](https://github.com/microsoft/TypeScript) from 5.8.3
to 5.9.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/microsoft/TypeScript/releases">typescript's
releases</a>.</em></p>
<blockquote>
<h2>TypeScript 5.9</h2>
<p>Release notes pending.</p>
<!-- raw HTML omitted -->
<ul>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+5.9.0%22+is%3Aclosed+">fixed
issues query for Typescript 5.9.0 (Beta)</a>.</li>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+5.9.1%22+is%3Aclosed+">fixed
issues query for Typescript 5.9.1 (RC)</a>.</li>
<li>[[No specific changes for TypeScript 5.9.2 (Stable)]]</li>
</ul>
<p>Downloads are available on:</p>
<ul>
<li><a href="https://www.npmjs.com/package/typescript">npm</a></li>
</ul>
<h2>TypeScript 5.9 RC</h2>
<p>For release notes, check out the <a
href="https://devblogs.microsoft.com/typescript/announcing-typescript-5-9-rc/">release
announcement</a></p>
<ul>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+5.9.0%22+is%3Aclosed+">fixed
issues query for Typescript 5.9.0 (Beta)</a>.</li>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+5.9.1%22+is%3Aclosed+">fixed
issues query for Typescript 5.9.1 (RC)</a>.</li>
</ul>
<p>Downloads are available on:</p>
<ul>
<li><a href="https://www.npmjs.com/package/typescript">npm</a></li>
</ul>
<h2>TypeScript 5.9 Beta</h2>
<p>For release notes, check out the <a
href="https://devblogs.microsoft.com/typescript/announcing-typescript-5-9-beta/">release
announcement</a>.</p>
<ul>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+5.9.0%22+is%3Aclosed+">fixed
issues query for Typescript 5.9.0 (Beta)</a>.</li>
</ul>
<p>Downloads are available on:</p>
<ul>
<li><a href="https://www.npmjs.com/package/typescript">npm</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/microsoft/TypeScript/commit/be8678315541e814da14316848a9468e8f90ab11"><code>be86783</code></a>
Give more specific errors for <code>verbatimModuleSyntax</code> (<a
href="https://redirect.github.com/microsoft/TypeScript/issues/62113">#62113</a>)</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/22ef57786f5ca99837c430439bc6003c068fe1d2"><code>22ef577</code></a>
LEGO: Pull request from
lego/hb_5378966c-b857-470a-8675-daebef4a6da1_20250714...</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/d5a414cd1dceb209fd2569e89d1096812218e8c5"><code>d5a414c</code></a>
Don't use <code>noErrorTruncation</code> when printing types with
<code>maximumLength</code> set (#...</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/f14b5c8a2f0be503ac455054a91573c63f0e5088"><code>f14b5c8</code></a>
Remove unused and confusing dom.iterable.d.ts file (<a
href="https://redirect.github.com/microsoft/TypeScript/issues/62037">#62037</a>)</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/2778e84ed88894156e2c5a17d74a25c73cc96ffe"><code>2778e84</code></a>
Restore AbortSignal.abort (<a
href="https://redirect.github.com/microsoft/TypeScript/issues/62086">#62086</a>)</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/65cb4bd2d52cd882f2c3a503681479eb2ed291ca"><code>65cb4bd</code></a>
LEGO: Pull request from
lego/hb_5378966c-b857-470a-8675-daebef4a6da1_20250710...</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/9e20e032effad965567d4a1e1c30d5433b0a3332"><code>9e20e03</code></a>
Clear out checker-level stacks on pop (<a
href="https://redirect.github.com/microsoft/TypeScript/issues/62016">#62016</a>)</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/87740bc7fe3d8d2af47d767db081491f40b8a90d"><code>87740bc</code></a>
Fix for Issue 61081 (<a
href="https://redirect.github.com/microsoft/TypeScript/issues/61221">#61221</a>)</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/833a8d492c728d606454865e8c0fee84842f9f10"><code>833a8d4</code></a>
Fix Symbol completion priority and cursor positioning (<a
href="https://redirect.github.com/microsoft/TypeScript/issues/61945">#61945</a>)</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/0018c9ff12e657b84997dc1843818fea0a2ce850"><code>0018c9f</code></a>
LEGO: Pull request from
lego/hb_5378966c-b857-470a-8675-daebef4a6da1_20250702...</li>
<li>Additional commits viewable in <a
href="https://github.com/microsoft/TypeScript/compare/v5.8.3...v5.9.2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=typescript&package-manager=npm_and_yarn&previous-version=5.8.3&new-version=5.9.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

You can trigger a rebase of this PR by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

> **Note**
> Automatic rebases have been disabled on this pull request as it has
been open for over 30 days.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Harel M <harel.mazor@gmail.com>
2025-09-13 18:45:03 +00:00
Harel M b429bb16d7 Fix network issue (#944)
## Launch Checklist

<!-- Thanks for the PR! Feel free to add or remove items from the
checklist. -->
In case of non 200 response the font and glyphs metadata would return
the ajax error object instead of the default value.

Fixes #935

- #935

 - [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.
 - [ ] Write tests for all new functionality.
 - [x] Add an entry to `CHANGELOG.md` under the `## main` section.
2025-01-21 14:25:03 +00:00
Harel MandYuri Astrakhan a22476cab2 Add lint to CI and fix errors (#853)
Adds lint to CI and fixes errors.
I'm not sure I'm fully proud of all the solutions there.
But there's no lint issues and the lint is being checked as part of the
CI.

---------

Co-authored-by: Yuri Astrakhan <yuriastrakhan@gmail.com>
2023-12-26 23:13:22 +02:00
Harel M 3bf0e510e6 Migrate all the non react components code to typescript (#847)
This completes the migration to typescript of all the non react
components code.
The only changes introduced besides types are the type checks using
`"something" in object` which narrows down types in typescript.
2023-12-21 00:07:53 +02:00