render flat delta pill for null values per design spec

This commit is contained in:
Samuel Enocsson
2026-05-21 15:51:17 +02:00
parent 96ae7d7dac
commit 4b145094bf
3 changed files with 15 additions and 18 deletions
+5 -5
View File
@@ -4,15 +4,15 @@ let openPdgaNumber = null;
// ── Delta-pill helper ─────────────────────────────
function renderDeltaPill(value, extraClass) {
if (value == null) return null;
const cls = value > 0 ? 'up' : value < 0 ? 'down' : 'flat';
const glyph = value > 0 ? '' : value < 0 ? '' : '';
const num = value > 0 ? '+' + value : String(value);
const isNull = (value == null);
const cls = isNull ? 'flat' : value > 0 ? 'up' : value < 0 ? 'down' : 'flat';
const glyph = (isNull || value === 0) ? '' : value > 0 ? '' : '';
const num = isNull ? '—' : value > 0 ? '+' + value : String(value);
return { glyph, num, cls };
}
function applyDeltaPill(pillEl, value) {
if (!pillEl || value == null) return;
if (!pillEl) return;
const pill = renderDeltaPill(value);
pillEl.className = 'delta-pill ' + pill.cls;
while (pillEl.firstChild) pillEl.removeChild(pillEl.firstChild);