Skip to content

fix: fall back to viewBox when SVG logo lacks width/height - #184

Open
ayushsingh82 wants to merge 1 commit into
monad-crypto:mainfrom
ayushsingh82:fix/svg-viewbox-dimensions
Open

fix: fall back to viewBox when SVG logo lacks width/height#184
ayushsingh82 wants to merge 1 commit into
monad-crypto:mainfrom
ayushsingh82:fix/svg-viewbox-dimensions

Conversation

@ayushsingh82

Copy link
Copy Markdown

Summary

  • get_svg_dimensions() in scripts/validate_tokens.py only read the width/height XML attributes, so a valid square SVG exported with only a viewBox (a common shape from Figma/Illustrator) failed validation with "Could not extract dimensions." This contradicted the function's own error message, which already told contributors a viewBox was acceptable.
  • Adds a fallback that parses viewBox="minX minY width height" when width/height attributes are absent, and uses its width/height for the square/min-size checks.

Test plan

  • Ran get_svg_dimensions() against all 89 existing mainnet/*/logo.svg files — identical output before and after (no regression on width/height-attribute SVGs).
  • Synthetic viewBox-only SVG (viewBox="0 0 256 256", no width/height attrs) now resolves to (256, 256) instead of failing.
  • SVG with no dimensions at all still correctly returns (None, None).
  • uv run ruff check and uv run ruff format --check pass on the changed file.

get_svg_dimensions() only read the width/height XML attributes, so a
valid square SVG with only a viewBox (a common export shape from
design tools) failed validation with "Could not extract dimensions,"
contradicting the function's own error message which already claimed
viewBox support.

Parse viewBox as a fallback when width/height attributes are absent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant