@hlfan commented on this pull request.
> + if (button.classList.contains("maplibregl-ctrl-zoom-in")) {
+ const icon = document.createElement("i");
+ icon.className = "bi bi-plus-lg";
+ button.appendChild(icon);
+ } else if (button.classList.contains("maplibregl-ctrl-zoom-out")) {
+ const icon = document.createElement("i");
+ icon.className = "bi bi-dash-lg";
+ button.appendChild(icon);
+ } else if (button.classList.contains("maplibregl-ctrl-geolocate")) {
+ const icon = document.createElement("i");
+ icon.className = "bi bi-cursor-fill";
+ button.appendChild(icon);
+ }
Let's remove some repetition:
```js
const iconMap={
"zoom-in": "plus-lg",
"zoom-out": "dash-lg",
"geolocate": "cursor-fill"
}
```
```suggestion
const icon =
iconMap[button.className.match(/maplibregl-ctrl-([\w-]+)/)[1]];
$(button)
.empty()
.append(`<i class="maplibregl-ctrl-icon fs-5 bi bi-${icon}"/>`);
```
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6695#pullrequestreview-3661468291
You are receiving this because you are subscribed to this thread.
Message ID:
<openstreetmap/openstreetmap-website/pull/6695/review/[email protected]>_______________________________________________
rails-dev mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/rails-dev