Skip to content

fix(viewer): apply legend gradient via background-image, not shorthand#9

Merged
MattNotarangelo merged 1 commit into
mainfrom
fix/legend-gradient-shorthand-reset
Jun 27, 2026
Merged

fix(viewer): apply legend gradient via background-image, not shorthand#9
MattNotarangelo merged 1 commit into
mainfrom
fix/legend-gradient-shorthand-reset

Conversation

@MattNotarangelo

Copy link
Copy Markdown
Owner

Background

  • The legend colour bar still showed a thin wrong-colour sliver at the top and bottom (red above the blue top, blue below the red bottom) — the same artifact fix(viewer): stop legend gradient leaking through translucent border #4 was meant to fix.
  • Root cause: fix(viewer): stop legend gradient leaking through translucent border #4 added background-origin: border-box to .legend-bar in CSS, but legend.ts applies the gradient with the background shorthand. The shorthand resets every background sub-property — including background-origin — to its initial padding-box on each render, silently defeating the stylesheet rule. The gradient is then sized to the padding box and tiles under the 1px translucent border, leaking the opposite end's colour.
  • The original verification missed this because the standalone repro used the background-image longhand, so it passed while the real app stayed broken.

What Has Changed

  • legend.ts: set the gradient via background-image: (longhand) instead of the background: shorthand, so the merged background-origin: border-box rule actually applies. One-line change plus an explanatory comment.

Verification

  • Confirmed in the running app (loaded the example cave, Elevation colour mode): computed background-origin is now border-box, and the enlarged legend bar is clean at both ends.
  • npm run build passes; all 80 unit tests pass.

Screenshots/Video

  • {Leave for author}

Checklist

  • Self-review completed
  • Tests added or updated
  • Tested locally

🤖 Generated with Claude Code

The earlier border-box fix (#4) never took effect: the legend bar sets
its gradient with the `background` shorthand, which resets every
background sub-property — including `background-origin` — back to its
initial `padding-box` on each render, overriding the stylesheet's
`background-origin: border-box`. The gradient was sized to the padding
box and tiled under the 1px translucent border, leaking the opposite
end's colour as a sliver at the top and bottom.

Use the `background-image` longhand so the stylesheet's
`background-origin: border-box` survives. Verified in the running app
(elevation legend) that both ends are now clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying caveviewer with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3ba1a16
Status: ✅  Deploy successful!
Preview URL: https://2798c9e8.caveviewer.pages.dev
Branch Preview URL: https://fix-legend-gradient-shorthan.caveviewer.pages.dev

View logs

@MattNotarangelo MattNotarangelo merged commit d6ae308 into main Jun 27, 2026
2 checks passed
@MattNotarangelo MattNotarangelo deleted the fix/legend-gradient-shorthand-reset branch June 27, 2026 01:52
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