Stats: GitHub-style watch-time heatmap

- api/stats gains by_day: local-date -> seconds (same watch-time
  heuristic as by_weekday)
- ?stats renders a Mon..Sun x week grid (30d window, matches the
  page header) with 4 intensity levels + tooltip per cell + legend;
  replaces the by-weekday bar chart the heatmap subsumes
- test_stats covers by_day (sums, slug-scoped, empty case)
This commit is contained in:
jozamudi committed 2026-08-24 22:24:16 +00:00
1 parent 7d9fab6bd9
commit 7b670cff24
4 files changed
+52 -20

No files matched your search

+8 -4
View File
@@ -56,10 +56,14 @@ h2 { margin: 0.4rem 0; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.card.stat { padding: .8rem; gap: .2rem; }
.stat-value { font-size: 1.3rem; font-weight: 700; }
.wk { display: flex; gap: .5rem; align-items: flex-end; margin: .4rem 0 .8rem; }
.wk-col { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.wk-bar { width: 26px; background: var(--acc); border-radius: 4px; }
.wk-day { font-size: .7rem; color: var(--muted); }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 11px); gap: 3px; width: fit-content; margin: .5rem 0 .3rem; }
.heat i, .heat-lg i { width: 11px; height: 11px; border-radius: 2px; background: var(--bd); }
.heat i.none { background: transparent; }
.heat i.l1, .heat-lg i.l1 { background: color-mix(in srgb, var(--acc) 30%, var(--bd)); }
.heat i.l2, .heat-lg i.l2 { background: color-mix(in srgb, var(--acc) 55%, var(--bd)); }
.heat i.l3, .heat-lg i.l3 { background: color-mix(in srgb, var(--acc) 78%, var(--bd)); }
.heat i.l4, .heat-lg i.l4 { background: var(--acc); }
.heat-lg { display: flex; align-items: center; gap: 3px; font-size: .75rem; color: var(--muted); }
.chip { font-size: .7rem; padding: .1rem .5rem; border-radius: 99px; border: 1px solid var(--bd);
color: var(--muted); white-space: nowrap; }
.chip.on { color: var(--acc); border-color: var(--acc); }