openstreetmap-website icon indicating copy to clipboard operation
openstreetmap-website copied to clipboard

Inline SVGs with helper module

Open hlfan opened this issue 8 months ago • 3 comments

Description

Using a basic helper module, this PR resolves most of #5880. To fully conclude that:

  • The changeset icons should be extracted too, but the definitions should also be put outside the list. #5884 aims to do part of this without the helper.
  • The directions sprite could benefit from another method InlineSvg.define that is outside this PR's scope

How has this been tested?

Verifying that the local Rails output matches

hlfan avatar Apr 17 '25 15:04 hlfan

Do you want both optimizing svg by micromanaging their attributes and externalizing them as effectively "binary" data? How is that supposed to work at the same time?

AntonKhorev avatar Apr 17 '25 16:04 AntonKhorev

Neither. You already optimized the SVGs when you added them into the templates[^1]. The additional xmlns is only for increased compatibility during development. Pulling the SVGs out increases the visualizability (file thumbnails you wouldn't get when they're packed into templates) and supports the separation of concerns raised in the original issue.

Just because you understand both SVG internals and layout doesn't mean every contributor should have to. By keeping them separated, layout edits don’t require SVG expertise, and SVG tweaks won’t accidentally break the layout.

[^1]: see, e.g., the original new.svg

hlfan avatar Apr 17 '25 17:04 hlfan

Looks good to me, thanks.

tomhughes avatar Jul 20 '25 11:07 tomhughes