local-weather/components/WeatherHero.tsx

23 lines
575 B
TypeScript
Raw Normal View History

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