diff --git a/ui/src/views/Baseline.jsx b/ui/src/views/Baseline.jsx index 23611bd..c145c03 100644 --- a/ui/src/views/Baseline.jsx +++ b/ui/src/views/Baseline.jsx @@ -165,6 +165,19 @@ export default function Baseline({ sources = [], sourceId, versions = [], versio } catch (err) { flash(err.message, 'error') } } + // Column widths read off the content rather than guessed. ch is the width of a + // '0', so for proportional text it runs slightly generous -- which is what is + // wanted for an input you are about to type a longer name into. The floors keep + // an empty table from collapsing its headers; the ceilings keep one long note + // from pushing the numbers off the side. + function widthCh(values, min, max) { + const longest = values.reduce((n, v) => Math.max(n, String(v || '').length), 0) + return `${Math.min(max, Math.max(min, longest + 2))}ch` + } + const labelW = widthCh(log.map(e => e.label || e.tag || e.note), 18, 40) + const bucketW = widthCh(log.map(e => e.bucket), 16, 28) + const noteW = widthCh(log.map(e => e.note), 24, 60) + function loadLog() { fetch(`/api/versions/${versionId}/log`).then(r => r.json()).then(data => { setLog(data.filter(e => e.operation === 'baseline' || e.operation === 'reference')) @@ -341,7 +354,10 @@ export default function Baseline({ sources = [], sourceId, versions = [], versio return (