Merge pull request #3 from griffemi/worktree-dry-period-visual

Weekly page: no-rain visuals adopt the dry-streak look
This commit is contained in:
Emi Griffith 2026-07-10 18:31:13 -07:00 committed by GitHub
commit 0571fe8aaa

View file

@ -169,11 +169,11 @@ function render(data) {
// One tinted value cell: background + value colored by the day's grade tier for
// that metric (the same diverging scale as everywhere else). Carries the date so
// tapping any cell opens that day's full breakdown.
function rdCell(g, fmt, date, isFc, isToday) {
function rdCell(g, fmt, date, isFc, isToday, override) {
const dd = date ? ` data-date="${date}"` : "";
const cls = "rd-c" + (isFc ? " rd-fc" : isToday ? " rd-today" : "");
if (!g) return `<span class="${cls}"${dd}>—</span>`;
const col = TIER_COLORS[g.class] || "";
const col = override || TIER_COLORS[g.class] || "";
return `<span class="${cls}"${dd} style="--c:${col}">${fmt(g.value)}</span>`;
}
@ -197,7 +197,14 @@ function daysTable(rows, todayDate) {
}).join("");
const body = RD_METRICS.map(([key, label, fmt]) =>
`<div class="rd-mlabel">${label}</div>` +
rows.map((d) => rdCell(d[key], fmt, d.date, isFc(d), d.date === todayDate)).join("")
rows.map((d) => {
// No-rain days in the Rain row take the dry-streak warmth (tan→red, deepening
// with the streak) — matching the Dry chart and calendar — instead of one flat
// "dry" tint. Falls back to the flat dry color when the streak is unknown.
const dry = key === "precip" && d.precip && d.precip.class === "dry";
const override = dry ? drynessColor(d.dsr) : null;
return rdCell(d[key], fmt, d.date, isFc(d), d.date === todayDate, override);
}).join("")
).join("");
return `<div class="rd-scroll"><div class="rd-grid" style="${cols}">${header}${body}</div></div>`;
}
@ -578,7 +585,9 @@ function precipChart(days, n, xFor, C) {
days, n, xFor, C, key: "precip", color: C.precip, fan: RAIN_FAN, hasNormals: true, baseZero: true,
getVal: (d) => (d.precip ? d.precip.value : null),
getPct: (d) => (d.precip ? d.precip.percentile : null),
dotColor: (d) => (d.precip && d.precip.value > 0 ? (TIER_COLORS[d.precip.class] || C.precip) : C.precip),
// Rain days take their intensity-tier color; no-rain days warm with the dry
// streak (tan→red) so a dry spell reads as dry, matching the Dry chart.
dotColor: (d) => (d.precip && d.precip.value > 0 ? (TIER_COLORS[d.precip.class] || C.precip) : (drynessColor(d.dsr) || C.precip)),
fmtAxis: (v) => `${v.toFixed(2)}"`,
fmtLabel: (v) => `${v.toFixed(2)}"`,
labelOn: (v) => v > 0, // only label rain days; dry days rest on the baseline