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