fix(board): kpi chips strictly one line — nowrap, compact durations (5d/3h/25m), no prefix

This commit is contained in:
chahinebrini 2026-07-22 19:10:31 +02:00
parent c9e240b068
commit 97db2358bb
4 changed files with 19 additions and 2 deletions

View File

@ -46,6 +46,13 @@ ${backlogSeries.toString()}
${areaPath.toString()}
${laneChips.toString()}
window.__b2UpdateKpis = function (tasks, agentColor) {
// Compact durations keep chips short: 25m → 3h → 4d.
function fmtMin(m) {
if (m < 60) return m + 'm';
var h = Math.round(m / 60);
if (h < 48) return h + 'h';
return Math.round(h / 24) + 'd';
}
var kpiPrev = window.__b2KpiPrev || (window.__b2KpiPrev = {});
function flashKpi(card, value) {
if (kpiPrev[card] !== undefined && kpiPrev[card] !== value) {
@ -82,7 +89,9 @@ window.__b2UpdateKpis = function (tasks, agentColor) {
el.innerHTML = capped.visible.map(function (c) {
var color = agentColor ? agentColor(c.name) : '#a5b4fc';
var initial = c.name.charAt(0).toUpperCase();
var time = c.minutes == null ? '' : (status === 'review' ? 'prüft ' : '') + c.minutes + 'm';
// No text prefix — keeps chips narrow enough for a single line (the
// card label already says REVIEW / IN PROGRESS).
var time = c.minutes == null ? '' : fmtMin(c.minutes);
var dot = status === 'in_progress' ? '<span class="b2-cdot"></span>' : '';
return '<span class="b2-achip"><i style="background:' + color + '">' + initial + '</i>' + dot + time + '</span>';
}).join('') + (capped.hidden > 0 ? '<span class="b2-achip b2-more">+' + capped.hidden + '</span>' : '');

View File

@ -95,7 +95,7 @@ export function boardV2Css(): string {
.b2-val small { font-size: 13px; color: var(--b2-muted); font-weight: 500; }
.b2-miniarea { margin-top: 8px; }
.b2-spark { stroke-dasharray: 400; stroke-dashoffset: 400; animation: b2-draw 1.6s .3s forwards ease-out; }
.b2-chips { display: flex; gap: 6px; margin-top: 10px; align-items: center; flex-wrap: wrap; min-height: 24px; }
.b2-chips { display: flex; gap: 6px; margin-top: 10px; align-items: center; flex-wrap: nowrap; overflow: hidden; min-height: 24px; }
.b2-achip {
display: inline-flex; align-items: center; gap: 5px;
font: 11px/1 var(--mono); padding: 3px 9px 3px 4px;

View File

@ -27,4 +27,7 @@ describe('kpiJs', () => {
expect(js).toContain('DAY_MS');
expect(js).toContain('function dayStart');
});
it('keeps chips single-line friendly (no wide text prefix)', () => {
expect(kpiJs()).not.toContain('prüft ');
});
});

View File

@ -13,4 +13,9 @@ describe('boardV2Css', () => {
it('respects prefers-reduced-motion', () => {
expect(boardV2Css()).toContain('@media (prefers-reduced-motion: reduce)');
});
it('keeps kpi chips on a single line', () => {
const css = boardV2Css();
expect(css).toMatch(/\.b2-chips \{[^}]*flex-wrap: nowrap/);
expect(css).toMatch(/\.b2-chips \{[^}]*overflow: hidden/);
});
});