mue/src/components/widgets/weather/WeatherIcon.jsx

57 lines
1.3 KiB
React
Raw Normal View History

2022-10-30 16:56:26 +00:00
import { memo } from 'react';
import {
WiDaySunny,
WiNightClear,
WiDayCloudy,
WiNightCloudy,
WiCloud,
WiCloudy,
WiDayShowers,
WiNightShowers,
WiRain,
WiThunderstorm,
WiSnow,
WiFog,
} from 'react-icons/wi';
2022-10-30 16:56:26 +00:00
function WeatherIcon({ name }) {
// name is the openweathermap icon name, see https://openweathermap.org/weather-conditions
switch (name) {
case '01d':
2022-11-06 11:59:59 +00:00
return <WiDaySunny className="weatherIcon" />;
case '01n':
2022-11-06 11:59:59 +00:00
return <WiNightClear className="weatherIcon" />;
case '02d':
return <WiDayCloudy className="weatherIcon" />;
case '02n':
2022-11-06 11:59:59 +00:00
return <WiNightCloudy className="weatherIcon" />;
case '03d':
case '03n':
2022-11-06 11:59:59 +00:00
return <WiCloud className="weatherIcon" />;
case '04d':
case '04n':
2022-11-06 11:59:59 +00:00
return <WiCloudy className="weatherIcon" />;
case '09d':
2022-11-06 11:59:59 +00:00
return <WiDayShowers className="weatherIcon" />;
case '09n':
return <WiNightShowers className="weatherIcon" />;
case '10d':
case '10n':
return <WiRain className="weatherIcon" />;
case '11d':
case '11n':
return <WiThunderstorm className="weatherIcon" />;
case '13d':
case '13n':
return <WiSnow className="weatherIcon" />;
case '50d':
case '50n':
return <WiFog className="weatherIcon" />;
default:
2022-08-25 16:07:35 +00:00
return null;
}
}
2022-10-30 16:56:26 +00:00
2022-11-06 11:59:59 +00:00
export default memo(WeatherIcon);