Typeset a weather value's unit against its numbers

Aperta
#1,301 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Attiva
Stack tecnologico
next.js, typescript
Ambito
frontend

Direzione di ricerca

Read src/components/forecast/weatherUnits.ts, WeatherValue.tsx, and __tests__/server/weatherUnits.server.test.ts; the issue describes a measured implementation on the beyond-parity-weather-units branch. First get a forecaster's opinion on the open choice among the three display options, then compare the selected behavior with the listed real-world value shapes and tests. Done means the display decision is settled and the chosen behavior is verified across both table formats, with prose and other non-simple values unchanged.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement needs-triage

Attach a weather table's unit to the numbers it measures, instead of trailing the whole value.

today proposed
20 to 25 F 20° to 25° F
5 to 8 " 5" to 8"
0.4 to 0.9 " 0.4" to 0.9"

The dangling inch mark is the case that prompted this — 5 to 8 " reads as a typo.

Filed separately because this changes how forecaster-entered data is displayed. #1135's approach is re-implementation, not redesign: "Holding presentation constant means any difference is a defect — a question we can answer." This is a deliberate difference, so it needs its own decision rather than riding along in a parity PR.

Approach, already built and measured

Branch: beyond-parity-weather-units — one commit on top of the parity work in #1219. Cherry-pick or rebase it; it is not abandoned spike code.

The wire data is semi-structured. value is free text a forecaster typed; unit is a separate field on the row. Surveyed across real products:

center unit value looks like
SNFAC F 20 to 25, -3 to 3
SNFAC " 0, 0 to 1, 5-10
SAC none Cloudy. Snow levels Below 5500 feet. Chance of precipitation is 95%.
BTAC F / mph 0, -1, 17
BTAC in 6.0 / 0.36 — a snow/water pair in one cell

So the split is on the unit, not the value. Some units read as a symbol on each number; others are words that belong after the whole value.

  • Tight (", %, F, C, °F, °C) → threaded into the numbers. For the temperature scales the degree sign is ours and the scale letter still trails, muted: 20° to 25° F.
  • Everything else (mph, in, …) → unchanged, trailing and muted.
  • Fires only when the whole value is a bare number or a simple A to B / A-B range. Prose, 6.0 / 0.36, blanks and - pass through untouched.

Rebuilding the string from the captured parts rather than replacing numbers in place keeps a negative low legible — -3-2 stays -3°-2° instead of flipping the sign on the high end.

src/components/forecast/weatherUnits.ts is the pure helper; WeatherValue.tsx is shared by both table formats so a temperature reads the same whichever shape a center's product arrives in. 19 tests in __tests__/server/weatherUnits.server.test.ts pin the real-world shapes above, including every one that must pass through unchanged.

The open question

The degree sign is inferred. The wire sends F, not °F — we add the ° because a row whose unit is F is a temperature. Defensible, but it is a glyph the forecaster did not type.

Three ways to go, in order of how much they touch:

  1. As built — degree signs on temperatures, inch marks on snow.
  2. Inch marks only. 5" to 8" uses the unit character the wire already sends and invents nothing; temperatures stay 20 to 25 F.
  3. 20 to 25 °F — no per-number sign, but the unit reads as one token instead of a bare trailing letter.

Option 2 is the conservative pick and still fixes the case that prompted this.

Worth a forecaster's opinion before shipping any of them.

Lingua principale
TypeScript
Stelle
6
Fork
2
Merge medio
1g 11h
PR unite (30g)
35

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NWACus/web

Tutte le issue di NWACus/web

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.