From 1f4b0af36a0afacf6005ce3be2d93077701af43c Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Tue, 27 Oct 2026 20:42:12 +0100 Subject: [PATCH] Fix the padded yellow progress bars The slow-city warning box used a plain .warn class, which also matched the yellow .bar.warn progress bars and gave them its padding and border. The box is .latwarn now; a test checks a yellow bar has no padding. --- CHANGELOG.md | 1 + src/game/80-simulation/90-sites-and-service.js | 2 +- src/styles/20-drawers.css | 2 +- tests/latency.test.js | 10 ++++++++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c296c5..9765bff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +- Yellow progress bars are slim again, like the green and red ones, instead of padded boxes. - Sponsor a conference: some peering meetings sell sponsorships, and while the glow lasts more customers from that region come knocking (#168). - Capacity conferences arrive: PTC in Honolulu and Capacity Europe in London, once a year from customer level 3. Attend, and carriers ask for huge deals (waves, subsea capacity, whole fiber pairs) that you sign first and build afterwards, with months to deliver and a penalty if you miss the date (#168). - Big POPs can now run up to 16 routers (#157). The standard cage still holds six: each router past that costs half again to install and adds rent for a cage extension. diff --git a/src/game/80-simulation/90-sites-and-service.js b/src/game/80-simulation/90-sites-and-service.js index 8b38896..6f13db9 100644 --- a/src/game/80-simulation/90-sites-and-service.js +++ b/src/game/80-simulation/90-sites-and-service.js @@ -20,7 +20,7 @@ function routerModels(c){const p=S.pops[c],g=p.rgen||0,rt=p.routers||1; function portNote(c){const p=S.pops[c];if(!p)return '';const g=p.rgen||0;return RG[g].maxP${tr('sites_and_service.your_model_here_tops_out_at',{model:esc(RG[g].n),pn:RG[g].pn})}

`:'';} // Service: what you deliver, times how it feels. Traffic backhauled far to transit is slow, and users notice. const latSlow=c=>!!(R&&R.latF&&R.latF[c]<0.97&&R.latFar[c]); -function latNote(c){if(!latSlow(c))return '';const f=R.latFar[c];return `
🐢 ${tr('sites_and_service.p_of_city_s_traffic_is',{p:pct(Math.min(1,f.share)),city:esc(CITY[c].name),to:esc(CITY[f.to].name),ms:Math.round(f.ms)})}
`;} +function latNote(c){if(!latSlow(c))return '';const f=R.latFar[c];return `
🐢 ${tr('sites_and_service.p_of_city_s_traffic_is',{p:pct(Math.min(1,f.share)),city:esc(CITY[c].name),to:esc(CITY[f.to].name),ms:Math.round(f.ms)})}
`;} const LAT_OK=20,LAT_BAD=50,latLoss=rtt=>rtt<=LAT_OK?0:rtt<=LAT_BAD?0.2*(rtt-LAT_OK)/(LAT_BAD-LAT_OK):0.5; function sfOf(r,c){const d=r.cityDem[c]||0;return d<=1e-6?1:clamp(r.citySrv[c]/d,0,1)*((r.latF&&r.latF[c])??1);} diff --git a/src/styles/20-drawers.css b/src/styles/20-drawers.css index 1f5d1f5..cf5509c 100644 --- a/src/styles/20-drawers.css +++ b/src/styles/20-drawers.css @@ -15,7 +15,7 @@ .x{margin-left:auto;border:2.5px solid var(--ink);background:var(--paper);border-radius:10px;width:32px;height:32px;font-size:20px;line-height:1;cursor:pointer;font-weight:900;flex:none} .facts{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px} .fact{background:var(--soft);border:2px solid var(--ink);border-radius:9px;padding:1px 8px;font-size:12px;font-weight:700} -.fact.bad{background:#FFE3E3}.warn{background:#FFF1F1;border:2px solid #FF5A5F;border-radius:10px;padding:8px 10px;margin:6px 0;font-size:13px;line-height:1.4} +.fact.bad{background:#FFE3E3}.latwarn{background:#FFF1F1;border:2px solid #FF5A5F;border-radius:10px;padding:8px 10px;margin:6px 0;font-size:13px;line-height:1.4} .fact.ixf{background:#FFF3C4} .fact.mine{background:var(--me);color:#fff} .fact.down{background:var(--bad);color:#fff} diff --git a/tests/latency.test.js b/tests/latency.test.js index 6b870c5..5a4714e 100644 --- a/tests/latency.test.js +++ b/tests/latency.test.js @@ -52,3 +52,13 @@ test('the penalty is on a curve, and traffic that needs no transit is never pena assert.equal(ev("sfOf(R,'lon')"), ev("clamp(R.citySrv.lon/R.cityDem.lon,0,1)")); assert.deepEqual(errors, []); }); + +test('the slow-city warning box does not restyle the yellow progress bars', () => { + const { ev, errors } = load(); + // .bar.warn is the yellow bar; the latency box once used a plain .warn class and padded every yellow bar + const st = JSON.parse(ev(`(()=>{const b=document.createElement('div');b.className='bar warn';const w=document.createElement('div');w.className='latwarn';document.body.append(b,w); + const a=getComputedStyle(b),c=getComputedStyle(w);return JSON.stringify({bar:a.paddingTop+a.paddingLeft,box:c.paddingTop});})()`)); + assert.ok(!st.bar || st.bar === '0px0px', `yellow bars have no padding (${st.bar})`); + assert.equal(st.box, '8px', 'the warning box keeps its own'); + assert.deepEqual(errors, []); +});