Fix Meteocons gradient ID collisions across icons#12
Conversation
Meteocons SVGs reuse generic gradient IDs (a, b, c…). When multiple icons are inlined on one page (hourly strip, 10-day forecast) the IDs collide and icons render with another icon's gradient. prefixIds() gives each icon a private id namespace (id + url(#…) + xlink:href/href). Also: - neutralMoon(): recolor the night moon from Meteocons' icy blue to a white/silver so the crescent reads as a moon, not an ice crystal (clear-night, partly-cloudy-night only — fog-night keeps the icy palette) - map WMO code 48 (icy/depositing fog) to a dedicated fog-night icon Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Claude finished @cph5236's task in 2m 17s —— View job Code Review
The fix is correct and the approach is solid. A couple of things worth noting: 1. Daytime display of
if (code === 48) return 'fog-night'This means during daytime, users see a night-themed icon for icy/depositing fog. The intent (use the icy palette to convey rime fog) is reasonable, but it breaks the visual convention that night icons only appear after dark, and could look jarring on a daytime forecast strip. A minor nit — the PR explicitly documents the choice — but worth a second look if it ever gets user feedback. 2. Comment verbosity (CLAUDE.md style)
3. Everything else looks correct
✅ No bugs found. Approve once the comment style is addressed (or accepted as-is). |
Preview deployedhttps://cph5236.github.io/SimpleWeatherService/pr-previews/67f39bf47716bbfe6a36f2513c4e4ada4026af90/ Commit:
|
Problem
Meteocons SVGs reuse generic gradient IDs (
a,b,c…). EachWeatherIconinlines its SVG viadangerouslySetInnerHTML, so when several icons render on the same page — the 24-hour strip and 10-day forecast both render many at once — those IDs collide in the document and icons pick up another icon's gradient.Fix
prefixIds()— gives every icon a private id namespace by prefixing eachid,url(#…), andxlink:href/hrefwith the icon name, so gradients can't collide across icons.neutralMoon()— recolors the night moon from Meteocons' icy blue (#86c3db/#5eafcf/#72b9d5) to a white/silver so the crescent reads as a moon rather than an ice crystal. Applied only toclear-night/partly-cloudy-night(fog-night intentionally keeps the icy palette).fog-nighticon.Updated the
getWeatherIconNametest to cover the 45 vs 48 split.Verification
vite buildsucceeds (validates the newfog-night?rawimport)Notes
This is web-only and independent of the Android widget. These changes were developed locally (via a throwaway icon-gallery preview page that is not included here) and are validated by the build + test suite; I have not separately rendered the gradients in a browser as part of this PR.
Also includes a small chore: a root
.gitignorefor.playwright-mcp/output.🤖 Generated with Claude Code