Skip to content

Stop the flex row resizing the badges - #33

Merged
barkz merged 1 commit into
mainfrom
fix/badge-scaling
Sep 12, 2026
Merged

barkz merged 1 commit into
mainfrom
fix/badge-scaling

Conversation

@barkz

@barkz barkz commented Sep 12, 2026

Copy link
Copy Markdown
Owner

The bug

The badge strip is a flex row, and flex defaults to align-items: stretch. Replaced elements get stretched too, so the badges grew vertically while their widths stayed at the intrinsic value — distorted. The widest badge couldn't follow: growing its height would have grown its width past the space left on the line, so it stayed at its natural size and sat noticeably shorter than its neighbours.

Measured from a 2× render by decoding the PNG and reading the debug-outline extents, rather than eyeballing it:

Badge Before After
GLEAN 69.0 × 37.5 69.0 × 30.0
PYTHON 3.9+ 146.5 × 37.5 146.5 × 30.0
DEPENDENCIES 0 152.5 × 37.5 152.5 × 30.0
RELEASE PASSING 180.5 × 30.0 180.5 × 30.0

(30.0 is the 28px badge plus a 1px debug outline top and bottom. Natural height is 28px, so the first three were stretched by 9.5px.)

Rendering the same five badges outside any flex row produced five identical 28px-tall images, which is what isolated the cause to the row rather than the badge service.

The fix

  • Image rows no longer stretch their items (align-items: center)
  • Badge images pin height: 28px; width: auto; flex: 0 0 auto — shields.io's own for-the-badge height, so each badge renders 1:1 with no scaling at all

Two tests guard those rules. The failure was invisible in the markup and only appeared once rendered, so a markup-level test would never have caught it; asserting the stylesheet keeps the rules from being quietly dropped.

Ran 1102 tests — OK (1,100 before).

🤖 Generated with Claude Code

The badge strip is a flex row, and flex defaults to align-items:
stretch. Replaced elements get stretched too, so the badges grew
vertically while their widths stayed at the intrinsic value — the
first three rendered 37.5px tall against a natural 28px. The widest
badge could not follow: growing its height would have grown its width
past the space left on the line, so it stayed at 28px and sat 7.5px
shorter than its neighbours.

Measured from a 2x render, decoding the PNG and reading the outline
extents rather than eyeballing it:

  before   69.0x37.5   146.5x37.5   152.5x37.5   180.5x30.0
  after    69.0x30.0   146.5x30.0   152.5x30.0   180.5x30.0

(30.0 is the 28px badge plus the 1px debug outline top and bottom.)

Image rows no longer stretch their items, and badge images pin
height: 28px with width: auto and flex: 0 0 auto — shields.io's own
for-the-badge height, so every badge renders 1:1 with no scaling at
all. Two tests guard the rules, since the failure was invisible in the
markup and only showed up rendered.

Tests: 1,100 -> 1,102.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@barkz
barkz merged commit 954addd into main Sep 12, 2026
7 checks passed
@barkz
barkz deleted the fix/badge-scaling branch September 12, 2026 02:55
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