Now panel: show day's high + its feels-like, and peak rain chance with time

Was showing right-now's temp/feels-like/rain% under a headline that's
already a whole-day summary -- mismatched framing (a day-level
headline next to point-in-time numbers).

- Big temp is now today's forecast high, with a small 'High' label.
- Feels-like is paired with that same high-temp hour, not right now.
- Rain% is the day's peak chance, shown as 'X% chance of rain around
  HH:00' instead of the current hour's (often much lower) number.

summarizeToday() now returns highTemp/highFeelsLike/rainChance
alongside the existing headline/note/umbrella, computed from the same
already-fetched hourly points. Frontend falls back to currentPoint's
own values only if summary is unexpectedly null.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-08-31 11:56:43 +00:00
parent 997ea817cb
commit 335e6e31a8
4 changed files with 47 additions and 7 deletions

View file

@ -81,7 +81,16 @@ html, body, #root { height: 100%; margin: 0; font-size: 14px; }
flex-wrap: wrap;
gap: clamp(10px, 1.8vw, 24px);
}
.wx-now-temp-block { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.wx-now-temp { font-size: clamp(2.4rem, 5.5vw, 4.6rem); font-weight: 700; line-height: 1; }
.wx-now-temp-label {
margin-top: 2px;
font-size: clamp(0.65rem, 0.85vw, 0.85rem);
font-weight: 600;
text-transform: uppercase;
letter-spacing: .06em;
color: var(--text-muted);
}
.wx-now-meta { display: flex; flex-direction: column; gap: 4px; color: var(--text-muted); font-size: clamp(0.8rem, 1.05vw, 1.05rem); }
.wx-summary-headline { color: var(--text); font-weight: 600; font-size: clamp(0.95rem, 1.3vw, 1.3rem); }
.wx-summary-note { color: #fbbf24; }

View file

@ -95,6 +95,15 @@ export default function Display() {
const currentPoint = data.hourly.find(p => hourOf(p.ts) === nowHour) ?? data.hourly[0]
const todayKey = data.hourly[0] ? dateKeyOf(data.hourly[0].ts) : null
// The "now" panel shows the day's high (not the current temp) and pairs
// "feels like" with that same hour rather than right now — falls back to
// currentPoint's own values only if summary is unexpectedly null (no hourly
// data yet, which currentPoint being defined already makes unlikely).
const displayHighTemp = data.summary?.highTemp ?? currentPoint?.temp_c ?? null
const displayFeelsLike = data.summary?.highFeelsLike ?? currentPoint?.feels_like_c ?? null
const displayRainChance = data.summary?.rainChance
?? (currentPoint?.precip_prob != null ? { prob: currentPoint.precip_prob, ts: currentPoint.ts } : null)
const dayKeys = [...new Set(data.threeHourly.map(p => dateKeyOf(p.ts)))].slice(0, 2)
const nextDayGroups = dayKeys.map(key => ({
key,
@ -120,13 +129,16 @@ export default function Display() {
{currentPoint && (
<div className="wx-now">
<WeatherIcon icon={currentPoint.icon} size={72} />
<div className="wx-now-temp">{roundTemp(currentPoint.temp_c)}</div>
<div className="wx-now-temp-block">
<span className="wx-now-temp">{displayHighTemp != null && roundTemp(displayHighTemp)}</span>
<span className="wx-now-temp-label">High</span>
</div>
<div className="wx-now-meta">
{data.summary && <span className="wx-summary-headline">{data.summary.headline}</span>}
<span>
{currentPoint.feels_like_c != null && <>Feels like {roundTemp(currentPoint.feels_like_c)}</>}
{currentPoint.feels_like_c != null && currentPoint.precip_prob != null && ' · '}
{currentPoint.precip_prob != null && <>{Math.round(currentPoint.precip_prob)}% chance of rain</>}
{displayFeelsLike != null && <>Feels like {roundTemp(displayFeelsLike)}</>}
{displayFeelsLike != null && displayRainChance && ' · '}
{displayRainChance && <>{Math.round(displayRainChance.prob)}% chance of rain around {formatHour(displayRainChance.ts)}</>}
</span>
{data.summary?.note && <span className="wx-summary-note">{data.summary.note}</span>}
</div>

View file

@ -27,6 +27,9 @@ export interface Summary {
headline: string // "Scattered showers today", "Rain likely later", ...
note: string | null // e.g. "Thunderstorms possible", alongside the headline
umbrella: boolean // real rain chance now or later today
highTemp: number // today's forecast high (°C)
highFeelsLike: number | null // feels-like at the same hour as highTemp, not "now"
rainChance: { prob: number; ts: string } | null // today's peak precip% + when it falls
}
export type Provider = 'met_office' | 'open_meteo'