From 024934f09f487dd7525efa179c7b1fb189fbfdba Mon Sep 17 00:00:00 2001 From: Bashy Date: Sun, 22 Nov 2026 17:53:18 +0200 Subject: [PATCH] Stats: tidy leaderboards (even rows, aligned values and level pills, wider Points board) Co-Authored-By: Claude Opus 5.5 --- views/stats.ejs | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/views/stats.ejs b/views/stats.ejs index 9b46da9..27a26a3 100644 --- a/views/stats.ejs +++ b/views/stats.ejs @@ -14,14 +14,24 @@ .chart .ax { fill:var(--pico-muted-color); font-size:10px; } .tip { position:absolute; pointer-events:none; background:var(--pico-card-background-color); border:1px solid var(--pico-muted-border-color); border-radius:8px; padding:.25rem .5rem; font-size:.8rem; box-shadow:0 4px 12px rgba(0,0,0,.35); white-space:nowrap; display:none; z-index:5; } - .boards { display:grid; grid-template-columns:repeat(auto-fit, minmax(260px, 1fr)); gap:1rem; } + .boards { display:grid; grid-template-columns:repeat(auto-fill, minmax(320px, 1fr)); gap:1rem; } .board { border:1px solid var(--pico-muted-border-color); border-radius:12px; padding:.6rem .8rem; } .board h4 { margin:0 0 .3rem; font-size:.95rem; } - .board table { margin:0; font-size:.85rem; } - .board td, .board th { padding:.2rem .35rem; } - .board td.n { text-align:right; font-variant-numeric:tabular-nums; } - .board td.r { width:1.6em; color:var(--pico-muted-color); } - .board a { text-decoration:none; } + .board ol { list-style:none; margin:0; padding:0; } + .board li { list-style:none; display:grid; grid-template-columns:1.6rem minmax(0, 1fr) var(--nw, 4.6rem); align-items:center; gap:.5rem; + height:2rem; margin:0; padding:0 .2rem; border-bottom:1px solid var(--pico-muted-border-color); font-size:.88rem; } + .board li:last-child { border-bottom:0; } + .board .r { color:var(--pico-muted-color); text-align:right; font-variant-numeric:tabular-nums; } + .board .who { display:flex; align-items:center; gap:.4rem; min-width:0; } + .board .who a { text-decoration:none; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; } + .board .lvl { flex:none; font-size:.66rem; padding:.02rem .45rem; border-radius:99px; border:1px solid var(--pico-muted-border-color); + color:var(--pico-muted-color); white-space:nowrap; } + .board .n { text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap; } + /* points: the main board, twice as wide, level in its own column so the pills line up */ + .board.wide { grid-column:span 2; } + .board.wide li { grid-template-columns:1.6rem minmax(0, 1fr) 8.5rem var(--nw, 4.6rem); } + .board.wide .lvl { justify-self:start; } + @media (max-width: 700px) { .board.wide { grid-column:auto; } } .emotes { display:flex; flex-wrap:wrap; gap:.5rem; } .emote { display:flex; align-items:center; gap:.35rem; border:1px solid var(--pico-muted-border-color); border-radius:99px; padding:.15rem .6rem .15rem .25rem; font-size:.8rem; } .emote img { width:26px; height:26px; object-fit:contain; } @@ -89,20 +99,22 @@

Leaderboards

<% - const board = (title, rows, fmt, extra) => { - let s = `

${title}

`; + const board = (title, rows, fmt, extra, nw) => { + let s = `

${title}

`; if (!rows.length) return s + '

nothing yet

'; - s += ''; + s += '
    '; rows.forEach((r, i) => { - s += `
`; + const name = (r.name || r.login || '?').replace(/[<>&"]/g, ''); + s += `
  • ${i + 1}${name}` + + `${extra ? `${extra(r)}` : ''}${fmt(r.n)}
  • `; }); - return s + '
    ${i + 1}${(r.name || r.login || '?').replace(/[<>&"]/g, '')}${extra ? `
    ${extra(r)}` : ''}
    ${fmt(r.n)}
    '; + return s + ''; }; const hm = m => m >= 60 ? `${Math.floor(m / 60)} h ${m % 60} m` : `${m} m`; %>
    <%- board('Points', boards.points, n => n.toLocaleString(), r => r.level) %> - <%- board('Watch time', boards.watch, hm) %> + <%- board('Watch time', boards.watch, hm, null, '6.4rem') %> <%- board('Chat messages', boards.chat, n => n.toLocaleString()) %> <%- board('Bits', boards.bits, n => n.toLocaleString()) %> <%- board('Channel points spent', boards.channelPoints, n => n.toLocaleString()) %>