Weather Card Components
These components form the core weather visualization system of SkyCast IA, displaying current conditions, hourly forecasts, and detailed metrics.MainWeatherCard
The hero component displaying current weather conditions with AI analysis.Props
OpenWeather API response object containing current weather data.Key fields:
name(string) - City namesys.country(string) - Country codemain.temp(number) - Temperature in Celsiusmain.feels_like(number) - Perceived temperatureweather[0].main(string) - Weather condition (Rain, Snow, Clear, etc.)weather[0].description(string) - Detailed descriptionweather[0].icon(string) - Icon code from OpenWeather
Formatted local time string (HH:MM:SS format) calculated from timezone offset.
Loading state for AI analysis. Shows animated sparkle icon when
true.AI-generated weather insight text. Displayed in italic formatting.
Function returning Tailwind CSS color class for temperature display.Signature:
(temp: number) => stringUsage Example
Weather Icon Logic
The component dynamically selects icons based on weather conditions:Adaptive Theming
Colors automatically adjust based on temperature:Snow Theme (≤0°C)
Snow Theme (≤0°C)
- Background:
bg-black/5 - Text:
text-slate-900 - Icons:
text-slate-800 - Border:
border-black/10
Hot Theme (>28°C)
Hot Theme (>28°C)
- Glow effect:
bg-orange-500/20 - Sun icon:
text-orange-300 - Enhanced brightness
Default Theme
Default Theme
- Background:
bg-white/10 - Text:
text-white - Glass morphism effects
Custom Animations
The component includes three custom CSS animations:ForecastCard
Displays 8-hour forecast with temperature chart and precipitation probabilities.Props
Array of forecast objects from OpenWeather 5-day/3-hour forecast API.Each object contains:
dt(number) - Unix timestampmain.temp(number) - Temperatureweather[0].main(string) - Weather conditionweather[0].icon(string) - Weather icon codepop(number) - Probability of precipitation (0-1)
Usage Example
Precipitation Intelligence
The component analyzes forecast data to provide contextual messages:Chart Visualization
Temperature trend displayed using Recharts AreaChart:Responsive Design
The forecast card uses horizontal scrolling on mobile:WeatherStats
Grid display of four key weather metrics with icon-based visualization.Props
Current weather data object containing:
main.feels_like- Perceived temperaturemain.humidity- Humidity percentagewind.speed- Wind speed in m/s (converted to km/h)main.pressure- Atmospheric pressure in hPa
Layout variant. Currently only
horizontal is used in production.Usage Example
Statistics Displayed
Feels Like Temperature
Feels Like Temperature
Icon: Thermometer
Label: “Sensación”
Value: Rounded temperature in °C
Calculation: Direct from
Label: “Sensación”
Value: Rounded temperature in °C
Calculation: Direct from
weather.main.feels_likeHumidity
Humidity
Icon: Droplets
Label: “Humedad”
Value: Percentage (0-100%)
Calculation: Direct from
Label: “Humedad”
Value: Percentage (0-100%)
Calculation: Direct from
weather.main.humidityWind Speed
Wind Speed
Icon: Wind
Label: “Viento”
Value: Speed in km/h
Calculation:
Label: “Viento”
Value: Speed in km/h
Calculation:
Math.round(weather.wind.speed * 3.6)Atmospheric Pressure
Atmospheric Pressure
Icon: Gauge
Label: “Presión”
Value: Pressure in hPa
Calculation: Direct from
Label: “Presión”
Value: Pressure in hPa
Calculation: Direct from
weather.main.pressureGrid Layout
Responsive grid adjusts column count:Icon Theming
Icon containers adapt to weather conditions:Styling Best Practices
When customizing these components:- Maintain adaptive theming - Check for
isSnowcondition - Preserve animations - Keep existing animation classes
- Test responsive layouts - Verify mobile and desktop views
- Use consistent spacing - Follow 2rem/3rem border radius pattern
- Respect glass morphism - Keep backdrop-blur and transparency
Performance Tips
- ForecastCard limits to 8 forecast items to prevent excessive rendering
- Chart animations only run once on mount
- Weather icons use SVG for crisp scaling
- Temperature updates don’t trigger full re-renders
Accessibility
- All icons have semantic meaning through labels
- Temperature values are readable by screen readers
- High contrast maintained in all themes
- Hover states provide visual feedback
