feat(modules/desktop): addweather SVG icon mapping and improve condition label handling
Why: replaced emoji-based weather icons with a dynamic SVG mapping, introduced WEATHER_ICON_MAP, updated format_weather_data and Weather class to use icon names and svg_file, removed unused constants and clarified day/night variant handling. - New Features - Added WEATHER_ICON_MAP linking weather codes to SVG identifiers and supporting night variants. - Updated format_weather_data to return icon_name and use svg_file for dynamic icon resolution. - Modified Weather widget to set condition label via dynamic SVG files instead of emoji. - Enhancements - Implemented day/night icon variant logic using optimistic naming based on known variants. - Removed unused constant imports and simplified label update logic. - Improved error handling with explicit fallbacks for missing weather fields. - Bug Fixes - Fixed potential missing icon fallback by using .get with default values. - Corrected label assignment order to match new data structure.
This commit is contained in:
2 files changed
+62
-14
No files matched your search
@@ -87,6 +87,38 @@ WEATHER_EMOJI_MAP = {
|
||||
99: "⛈️", # Thunderstorm with heavy hail
|
||||
}
|
||||
|
||||
# Weather condition to SVG icon mapping
|
||||
WEATHER_ICON_MAP = {
|
||||
0: "weather-clear",
|
||||
1: "weather-few-clouds",
|
||||
2: "weather-clouds",
|
||||
3: "weather-overcast",
|
||||
45: "weather-fog",
|
||||
48: "weather-fog",
|
||||
51: "weather-showers-scattered",
|
||||
53: "weather-showers",
|
||||
55: "weather-showers",
|
||||
61: "weather-showers-scattered",
|
||||
80: "weather-showers-scattered",
|
||||
63: "weather-showers",
|
||||
65: "weather-showers",
|
||||
81: "weather-showers",
|
||||
82: "weather-storm",
|
||||
56: "weather-freezing-rain",
|
||||
57: "weather-freezing-rain",
|
||||
66: "weather-freezing-rain",
|
||||
67: "weather-freezing-rain",
|
||||
71: "weather-snow",
|
||||
73: "weather-snow",
|
||||
75: "weather-snow",
|
||||
77: "weather-hail",
|
||||
85: "weather-snow-scattered",
|
||||
86: "weather-snow-scattered",
|
||||
95: "weather-storm",
|
||||
96: "weather-storm",
|
||||
99: "weather-storm",
|
||||
}
|
||||
|
||||
# Weather condition descriptions
|
||||
WEATHER_DESC_MAP = {
|
||||
0: "Clear sky",
|
||||
|
||||
Reference in new issue
Block a user