Skip to content

Commit b235af9

Browse files
KaylinCHCHclaude
andcommitted
Fix grape range bar overflowing when a value is pinned at the max
A single value at the top of the scale (e.g. Cabernet Sauvignon's High tannin/acidity) was positioned at 100% and rendered off the right edge of the track, so the fill looked empty. Clamp the fill so it stays inside the track and shows at the High end. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 56e277e commit b235af9

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

index.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,8 +1642,10 @@ <h2>Quiz Complete!</h2>
16421642
function bar(range, scale) {
16431643
// range = [min, max] on 1–3; render filled segment across a 3-step track
16441644
const pct = v => ((v - 1) / 2) * 100;
1645-
const left = pct(range[0]);
1646-
const width = Math.max(pct(range[1]) - pct(range[0]), 8);
1645+
let left = pct(range[0]);
1646+
let width = Math.max(pct(range[1]) - pct(range[0]), 8);
1647+
// Keep the fill inside the track (a value pinned at the max would otherwise overflow off the right edge)
1648+
if (left + width > 100) left = 100 - width;
16471649
return `
16481650
<div class="grape-bar-row">
16491651
<span class="bar-label">${scale.title}</span>

0 commit comments

Comments
 (0)