Fix tables colours and moon phase
This commit is contained in:
fraxle
2026-05-24 01:21:14 +01:00
parent 7824ceb9f6
commit 0853b9852b
3 changed files with 75 additions and 78 deletions
+27 -16
View File
@@ -24,24 +24,35 @@
// ------------------------------------------------------------------------
// -------------------------------------------------------------------
// UTCI THERMAL STRESS BANDS - the coloured pills in the table.
// UTCI THERMAL STRESS BANDS - single source of truth.
// -------------------------------------------------------------------
// To recolour any band, change its bg/fg hex code. To shift the
// boundary between bands (e.g. make "Comfortable" wider), change the
// 'if (u < -)' thresholds. Order matters - they're checked top-down.
// Edit this array to change labels, colours or thresholds.
// Each entry: { max, label, bg, fg }
// max - upper boundary (exclusive). Omit on the last entry.
// bg - background hex for table cells and legend.
// fg - foreground hex for text on that background.
// utciCategory() reads from this array - do not duplicate elsewhere.
// -------------------------------------------------------------------
export const UTCI_BANDS = [
{ max: -20, label: 'Extreme cold', bg: '#0e1a50', fg: '#c8d4f0' },
{ max: -10, label: 'Arctic', bg: '#2a52b0', fg: '#dce8ff' },
{ max: 0, label: 'Freezing', bg: '#5c90cc', fg: '#ffffff' },
{ max: 5, label: 'Very cold', bg: '#90bcd8', fg: '#08182e' },
{ max: 10, label: 'Cold', bg: '#b8d4dc', fg: '#08182e' },
{ max: 15, label: 'Chilly', bg: '#c8dfc0', fg: '#082010' },
{ max: 19, label: 'Cool', bg: '#8aca78', fg: '#082010' },
{ max: 24, label: 'Comfortable', bg: '#157018', fg: '#b8f0b8' },
{ max: 29, label: 'Warm', bg: '#e8d840', fg: '#201800' },
{ max: 34, label: 'Hot', bg: '#eca030', fg: '#201800' },
{ max: 39, label: 'Very hot', bg: '#d84818', fg: '#ffffff' },
{ max: 44, label: 'Extremely hot', bg: '#a81810', fg: '#ffc8b8' },
{ label: 'Danger', bg: '#3a0404', fg: '#ffffff' },
];
export function utciCategory(u) {
if (u < -40) return { label: 'Extreme cold', bg: '#1a1438', fg: '#fff' };
if (u < -27) return { label: 'Very strong cold', bg: '#23408f', fg: '#fff' };
if (u < -13) return { label: 'Arctic', bg: '#3f73c4', fg: '#fff' };
if (u < 0) return { label: 'Freezing', bg: '#7eb0e0', fg: '#1a1612' };
if (u < 9) return { label: 'Cold', bg: '#bcd9ec', fg: '#1a1612' };
if (u < 18) return { label: 'Chilled', bg: '#c8dcc0', fg: '#1a1612' };
if (u < 26) return { label: 'Comfortable', bg: '#4a8a3a', fg: '#fff' };
if (u < 32) return { label: 'Moderate heat', bg: '#e8c547', fg: '#1a1612' };
if (u < 38) return { label: 'Strong heat', bg: '#dc8a3a', fg: '#1a1612' };
if (u < 46) return { label: 'Very strong heat', bg: '#c44a3a', fg: '#fff' };
return { label: 'Extreme heat', bg: '#7a1a1a', fg: '#fff' };
for (const band of UTCI_BANDS) {
if (band.max === undefined || u < band.max) return band;
}
}
// -------------------------------------------------------------------
@@ -367,4 +378,4 @@ 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
}
}