revamp weather UI: cards, meteograms, units in header, location favorites and range controls
This commit is contained in:
@@ -38,9 +38,9 @@ const weatherCodes: Record<number, string> = {
|
||||
51: 'sprinkle',
|
||||
52: 'rain',
|
||||
53: 'rain',
|
||||
54: 'snowflake-cold',
|
||||
55: 'snowflake-cold',
|
||||
56: 'snowflake-cold',
|
||||
54: 'sprinkle',
|
||||
55: 'rain',
|
||||
56: 'rain-mix',
|
||||
57: 'sprinkle',
|
||||
58: 'rain',
|
||||
60: 'sprinkle',
|
||||
@@ -56,11 +56,11 @@ const weatherCodes: Record<number, string> = {
|
||||
71: 'snow',
|
||||
72: 'snow',
|
||||
73: 'snow',
|
||||
74: 'snowflake-cold',
|
||||
75: 'snowflake-cold',
|
||||
76: 'snowflake-cold',
|
||||
74: 'snow',
|
||||
75: 'snow',
|
||||
76: 'snow',
|
||||
77: 'snow',
|
||||
78: 'snowflake-cold',
|
||||
78: 'snow',
|
||||
80: 'rain',
|
||||
81: 'sprinkle',
|
||||
82: 'rain',
|
||||
@@ -80,10 +80,13 @@ const weatherCodes: Record<number, string> = {
|
||||
99: 'tornado'
|
||||
};
|
||||
|
||||
// These conditions ship only as a single neutral glyph (no day/night variant).
|
||||
const NEUTRAL_ICONS = new Set(['snowflake-cold', 'strong-wind', 'dust', 'tornado']);
|
||||
|
||||
export function getWeatherIconName(code: number, daytime: boolean): string {
|
||||
const prefix = daytime ? 'day' : 'night';
|
||||
const name = weatherCodes[code as keyof typeof weatherCodes] ?? 'clear';
|
||||
return `wi-${prefix}-${name}`;
|
||||
if (NEUTRAL_ICONS.has(name)) return `wi-${name}`;
|
||||
return `wi-${daytime ? 'day' : 'night'}-${name}`;
|
||||
}
|
||||
|
||||
export default weatherCodes;
|
||||
|
||||
Reference in New Issue
Block a user