5.0.3
The Week Ahead - Best Times Out
This commit is contained in:
+32
-1
@@ -515,4 +515,35 @@ export function grassFillForElev(e) {
|
||||
if (e > -8) return { top: '#665884', bot: '#3e3556' }; // civil twilight purple
|
||||
if (e > -14) return { top: '#363356', bot: '#1c1a34' }; // nautical night
|
||||
return { top: '#201d3a', bot: '#0d0b20' }; // astronomical night
|
||||
}
|
||||
}
|
||||
// --- scoreFillColor --------------------------------------------------------
|
||||
// Colour for the "Best Days Out" score bar, so the hue carries the same
|
||||
// message as the length: red at 0, amber through the middle, green at 100.
|
||||
//
|
||||
// Straight hue interpolation across the red-yellow-green arc (0 deg to 120)
|
||||
// rather than blending between three fixed hex stops - the blend route in RGB
|
||||
// dips through brown around the midpoint, which reads as a fault rather than
|
||||
// a middling day. Saturation and lightness stay put so the bar keeps one
|
||||
// weight across the range instead of the yellow end glaring.
|
||||
export function scoreFillColor(score) {
|
||||
const pct = Math.max(0, Math.min(100, score ?? 0));
|
||||
return `hsl(${Math.round(pct * 1.2)} 68% 44%)`;
|
||||
}
|
||||
|
||||
// --- titleCaseText ---------------------------------------------------------
|
||||
// Insight-panel labels and values were written ad hoc over time, so the rail
|
||||
// mixed "Peak felt temp" with "Air quality" with "+9.0° warmer". Rather than
|
||||
// hand-editing every string (many are built at runtime, and app.js matches
|
||||
// some of them by exact text when ordering rows), the panels title-case at
|
||||
// render time.
|
||||
//
|
||||
// Only capitalises a letter that STARTS a word - one preceded by nothing,
|
||||
// whitespace or punctuation. A letter run glued to a number is a unit, not a
|
||||
// word, so "6am" and "10°C" survive as written rather than becoming "6Am".
|
||||
// Letters already capitalised are never touched, which keeps UV and AQI whole.
|
||||
export function titleCaseText(s) {
|
||||
return String(s ?? '').replace(
|
||||
/(^|[^A-Za-z0-9°'])([a-z])/g,
|
||||
(_, before, ch) => before + ch.toUpperCase(),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user