diff --git a/dashboard/src/components/dashboard/DateTime.jsx b/dashboard/src/components/dashboard/DateTime.jsx index 648c154..ffc07c8 100644 --- a/dashboard/src/components/dashboard/DateTime.jsx +++ b/dashboard/src/components/dashboard/DateTime.jsx @@ -122,35 +122,37 @@ const DateTimeWeatherDisplay = ({ scaleFactor = 1 }) => { if (!weatherCode) return ; const code = parseInt(weatherCode, 10); const iconProps = small ? "w-8 h-8" : "w-12 h-12"; + const isNight = currentTime.getHours() >= 18 || currentTime.getHours() < 6; + switch (true) { case code >= 200 && code < 300: - return ; + return ; case code >= 300 && code < 500: - return ; + return ; case code >= 500 && code < 600: - return ; + return ; case code >= 600 && code < 700: - return ; + return ; case code >= 700 && code < 721: - return ; + return ; case code === 721: - return ; + return ; case code >= 722 && code < 781: - return ; + return ; case code === 781: - return ; + return ; case code === 800: return currentTime.getHours() >= 6 && currentTime.getHours() < 18 ? ( - + ) : ( - + ); case code >= 800 && code < 803: - return ; + return ; case code >= 803: - return ; + return ; default: - return ; + return ; } }; @@ -159,66 +161,68 @@ const DateTimeWeatherDisplay = ({ scaleFactor = 1 }) => { // Thunderstorm (200-299) if (code >= 200 && code < 300) { - return "bg-gradient-to-br from-slate-900 via-purple-900 to-slate-800"; + return "bg-gradient-to-br from-slate-900 to-purple-800"; } // Drizzle (300-399) if (code >= 300 && code < 400) { - return "bg-gradient-to-br from-slate-700 via-blue-800 to-slate-700"; + return "bg-gradient-to-br from-slate-800 to-blue-800"; } // Rain (500-599) if (code >= 500 && code < 600) { - return "bg-gradient-to-br from-slate-800 via-blue-900 to-slate-700"; + return "bg-gradient-to-br from-slate-800 to-blue-800"; } // Snow (600-699) if (code >= 600 && code < 700) { - return "bg-gradient-to-br from-slate-200 via-blue-100 to-slate-100"; + return "bg-gradient-to-br from-slate-700 to-blue-800"; } // Atmosphere (700-799: mist, smoke, haze, fog, etc.) if (code >= 700 && code < 800) { - return "bg-gradient-to-br from-slate-600 via-slate-500 to-slate-400"; + return "bg-gradient-to-br from-slate-700 to-slate-500"; } // Clear (800) if (code === 800) { if (isNight) { - return "bg-gradient-to-br from-slate-900 via-blue-950 to-slate-800"; + return "bg-gradient-to-br from-slate-900 to-blue-900"; } - return "bg-gradient-to-br from-sky-400 via-blue-400 to-sky-500"; + return "bg-gradient-to-br from-blue-600 to-sky-400"; } // Clouds (801-804) if (code > 800) { if (isNight) { - return "bg-gradient-to-br from-slate-800 via-slate-700 to-slate-600"; + return "bg-gradient-to-br from-slate-800 to-slate-600"; } - return "bg-gradient-to-br from-slate-400 via-slate-500 to-slate-400"; + return "bg-gradient-to-br from-slate-600 to-slate-400"; } // Default fallback - return "bg-gradient-to-br from-slate-700 via-slate-600 to-slate-500"; + return "bg-gradient-to-br from-slate-700 to-slate-500"; }; const getTemperatureColor = (weatherCode, isNight) => { const code = parseInt(weatherCode, 10); - // Use dark text for light backgrounds - if (code >= 600 && code < 700) { // Snow - return "text-slate-900"; + // Snow - dark background, light text + if (code >= 600 && code < 700) { + return "text-white"; } - if (code === 800 && !isNight) { // Clear day - return "text-slate-900"; + // Clear day - light background, dark text + if (code === 800 && !isNight) { + return "text-white"; } - if (code > 800 && !isNight) { // Cloudy day - return "text-slate-900"; + // Cloudy day - medium background, ensure contrast + if (code > 800 && !isNight) { + return "text-white"; } - // Default to white text for all other (darker) backgrounds + // All other cases (darker backgrounds) return "text-white"; }; @@ -236,213 +240,217 @@ const DateTimeWeatherDisplay = ({ scaleFactor = 1 }) => { }; const WeatherDetails = () => ( -
-
- -
- -
- High - {Math.round(weather.main.temp_max)}°F +
+
+ +
+ +
+ High + {Math.round(weather.main.temp_max)}°F +
-
- - - -
- -
- Low - {Math.round(weather.main.temp_min)}°F + + + +
+ +
+ Low + {Math.round(weather.main.temp_min)}°F +
-
- + - -
- -
- Humidity - {weather.main.humidity}% + +
+ +
+ Humidity + {weather.main.humidity}% +
-
- + - -
- -
- Wind - {Math.round(weather.wind.speed)} mph + +
+ +
+ Wind + {Math.round(weather.wind.speed)} mph +
-
- + - -
- -
- Sunrise - {formatTime(weather.sys?.sunrise)} + +
+ +
+ Sunrise + {formatTime(weather.sys?.sunrise)} +
-
- + - -
- -
- Sunset - {formatTime(weather.sys?.sunset)} + +
+ +
+ Sunset + {formatTime(weather.sys?.sunset)} +
-
- -
- - {forecast && ( -
-
- {forecast.map((day, index) => ( - -
- - {new Date(day.dt * 1000).toLocaleDateString('en-US', { weekday: 'short' })} - - {getWeatherIcon(day.weather[0].id, new Date(day.dt * 1000), true)} -
- - {Math.round(day.main.temp_max)}° - - - {Math.round(day.main.temp_min)}° - -
-
- {day.rain?.['3h'] > 0 && ( -
- - {day.rain['3h'].toFixed(2)}" -
- )} - {day.snow?.['3h'] > 0 && ( -
- - {day.snow['3h'].toFixed(2)}" -
- )} - {!day.rain?.['3h'] && !day.snow?.['3h'] && ( -
- - 0" -
- )} -
-
-
- ))} -
+
- )} -
-); -return ( -
- {/* Time Display */} - - -
-
- {hours} - : - {minutes} - {ampm} + {forecast && ( +
+
+ {forecast.map((day, index) => { + const forecastTime = new Date(day.dt * 1000); + const isNight = forecastTime.getHours() >= 18 || forecastTime.getHours() < 6; + return ( + +
+ + {forecastTime.toLocaleDateString('en-US', { weekday: 'short' })} + + {getWeatherIcon(day.weather[0].id, forecastTime, true)} +
+ + {Math.round(day.main.temp_max)}° + + + {Math.round(day.main.temp_min)}° + +
+
+ {day.rain?.['3h'] > 0 && ( +
+ + {day.rain['3h'].toFixed(2)}" +
+ )} + {day.snow?.['3h'] > 0 && ( +
+ + {day.snow['3h'].toFixed(2)}" +
+ )} + {!day.rain?.['3h'] && !day.snow?.['3h'] && ( +
+ + 0" +
+ )} +
+
+
+ ); + })}
- - + )} +
+ ); - {/* Date and Weather Display */} -
- - -
- - {dateInfo.day} - - - {dateInfo.weekday} - + return ( +
+ {/* Time Display */} + + +
+
+ {hours} + : + {minutes} + {ampm} +
- {weather?.main && ( - - - = 18 || datetime.getHours() < 6 - ), - "flex items-center justify-center cursor-pointer hover:brightness-110 transition-all relative" - )}> - -
- {getWeatherIcon(weather.weather[0]?.id, datetime)} - = 18 || datetime.getHours() < 6 - ) - )}> - {Math.round(weather.main.temp)}° - -
-
- {weather.alerts && ( -
- -
- )} -
-
- - {weather.alerts && ( - - - - {weather.alerts[0].event} - - - )} - - -
- )} -
+ {/* Date and Weather Display */} +
+ + +
+ + {dateInfo.day} + + + {dateInfo.weekday} + +
+
+
- {/* Calendar Display */} - - - - - -
-); + {weather?.main && ( + + + = 18 || datetime.getHours() < 6 + ), + "flex items-center justify-center cursor-pointer hover:brightness-110 transition-all relative backdrop-blur-sm" + )}> + +
+ {getWeatherIcon(weather.weather[0]?.id, datetime)} + + {Math.round(weather.main.temp)}° + +
+
+ {weather.alerts && ( +
+ +
+ )} +
+
+ + {weather.alerts && ( + + + + {weather.alerts[0].event} + + + )} + + +
+ )} +
+ + {/* Calendar Display */} + + + + + +
+ ); }; export default DateTimeWeatherDisplay; \ No newline at end of file