local-weather/components/WeatherIcon.tsx
ChrQR dc6882cf71
All checks were successful
Docker Build & Publish / Build Docker (push) Successful in 1m4s
moved weathericon logic out of components as it
was needed in multiple places.
2024-05-17 22:55:48 +02:00

21 lines
628 B
TypeScript

import Image from "next/image";
import { weatherIcons } from "@/app/weatherIcons";
// this component takes WeatherIconPropType as props and shows the weather icon for the hour index it is given in timeIndex prop.
export default function WeatherIcon(props: { weatherCode: number }) {
const currentWeather = weatherIcons.filter((weather) => {
return weather.code === props.weatherCode;
});
return (
<div className="h-12">
<Image
className="mt-2 max-h-12 mx-auto w-auto"
src={currentWeather[0].url}
alt="Weather icon"
width={100}
height={100}
/>
</div>
);
}