local-weather/components/WeatherHero.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

23 lines
575 B
TypeScript

import Image from "next/image";
import { useContext } from "react";
import { WeatherContext } from "./WeatherNow";
import { weatherIcons } from "@/app/weatherIcons";
export default function WeatherHero() {
const { weather } = useContext(WeatherContext);
const weatherCode = weather.current.weather_code;
const currentWeather = weatherIcons.filter((weather) => {
return weather.code === weatherCode;
});
return (
<>
<Image
className="h-44 w-auto mx-auto"
src={currentWeather[0].url}
alt="Weather icon"
/>
</>
);
}