ADDED FEATURES (IMAGES AND ICONS)

 WE DISPLAY DIFFERENT IMAGES FOR DIFFERENT WEATHER CONDITIONS

WE CREATE A CONDITION THAT CHECKS THE HUMIDITY FIRST, AND THE TEMPERATURE NEXT.

export default function InfoBox({ info }) {
  let SUNNY_IMG =
    "https://images.unsplash.com/photo-1604228741406-3faa38f4907a?w=600&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8N3x8c3Vubnl8ZW58MHx8MHx8fDA%3D";
  let COLD_IMG =
    "https://images.unsplash.com/photo-1519944159858-806d435dc86b?w=600&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8N3x8Y29sZHxlbnwwfHwwfHx8MA%3D%3D";
  let RAINY_IMG =
    "https://images.unsplash.com/photo-1519692933481-e162a57d6721?w=600&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Nnx8cmFpbnxlbnwwfHwwfHx8MA%3D%3D";


<CardMedia
            sx={{ height: 140 }}
            image={
              info.humidity > 80
                ? RAINY_IMG
                : info.temp > 15
                ? SUNNY_IMG
                : COLD_IMG
            }






WE ALSO ADD ICONS 

import AcUnitIcon from "@mui/icons-material/AcUnit";
import WbSunnyIcon from "@mui/icons-material/WbSunny";
import ThunderstormIcon from "@mui/icons-material/Thunderstorm";


<CardContent>
            <Typography gutterBottom variant="h5" component="div">
              <p>
               
                {info.city}&nbsp;
                {info.humidity > 80 ? (
                  <ThunderstormIcon />
                ) : info.temp > 15 ? (
                  <WbSunnyIcon />
                ) : (
                  <AcUnitIcon />
                )}
              </p>
            </Typography>









Comments

Popular posts from this blog

DEPENDENCIES IN useEffect()

ACTIVITY1

CONDITIONALS