Repository navigation
fix: underscored Material icons render; evaluate warns on unknown icons - #215
Merged
Merged
Conversation
…known icons Closes #214.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #214.
The bug
Material Symbols icons with more than one word in the name rendered nothing. Material names multi-word icons with underscores (
chevron_right,arrow_back,group_off), and the name check insrc/icons.tsallowed only letters, digits and hyphens. Those names were rejected before the file lookup, so in practice only single-word Material icons worked.The check now also allows
_. Names containing.or/are still rejected, so the guard against path-like names is unchanged. The-fillsuffix keeps working, including on underscored names (material:chevron_right-fill).Why it went unnoticed, and the warning that fixes that
When an icon name doesn't resolve, the renderer outputs only an HTML comment. The result is an empty slot that doesn't show up in a screenshot, and
canvas_evaluatesaid nothing about it, so a canvas could carry many blank icons and still score as clean.canvas_evaluatenow reports every icon node whose name resolves in neither bundled set as a warning in thestructurecategory. A warning blocks the "ready to present" directive, and each one costs 10 points of structure score. Icon nodes with no name at all are reported too.The warning's suggestion names the spellings that do resolve. It tries swapping hyphens and underscores, and adding the missing
material:prefix to a bare Material-style name likecloud_off, which is otherwise looked up in Lucide and renders nothing.When exactly one spelling resolves, the warning includes a fix that
canvas_autofixcan apply. When more than one resolves (cloud_offexists as Lucidecloud-offand asmaterial:cloud_off), the fix picks the set the rest of the canvas already uses. If the canvas has no other icons, or mixes both sets, there is no fix and the suggestion lists both options.Icons inside component instances are checked as well. Their warning says to fix the component definition and carries no fix, because the node isn't in the canvas tree that autofix edits.
Docs
The agent-facing text in
src/index.ts(server instructions, gotchas, thebatch_designicon section, and thecanvas_evaluateandcanvas_autofixdescriptions),docs/GUIDELINES.mdandREADME.mdnow explain the spelling difference between the two sets and the new warning.Tests
test-material-icons.tsadds the cases suggested in the issue: an underscored name resolves, its-fillvariant resolves and is the filled glyph, andmaterial:../xandmaterial:a/bare still rejected.test-unknown-icons.ts(no browser needed) covers the warning: valid icons stay silent, the fix ops (including keeping-fill), the tie-break by icon set, typos with no candidate, empty names, and icons inside components.npm run test:full: 101/101 passed.