diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dde92bd..3cc6faa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,3 +2,4 @@ 1. zetabug 2. AnthonyHad +3. AngeloTree diff --git a/src/App.js b/src/App.js index 99bd8f3..38bf226 100644 --- a/src/App.js +++ b/src/App.js @@ -1,16 +1,17 @@ -import React, { useCallback } from 'react'; -import { useState, useEffect } from 'react'; +import React, { useCallback } from "react"; +import { useState, useEffect } from "react"; +import SunnyImage from "./weather_images/Sunny.jpeg"; +import Rain from "./weather_images/Rain.jpeg"; +import Weather from "./components/Weather"; +import LoadingIndicator from "./UI/LoadingIndicator"; -import Weather from './components/Weather'; -import LoadingIndicator from './UI/LoadingIndicator'; - -import './app.css'; +import "./app.css"; function App() { const [data, setData] = useState(null); const [place, setPlace] = useState(null); - const [search, setSearch] = useState(''); - const [location, setLocation] = useState(''); + const [search, setSearch] = useState(""); + const [location, setLocation] = useState(""); const [isLoading, setIsLoading] = useState(false); function handleSearch(e) { @@ -18,7 +19,7 @@ function App() { } async function geoHandler() { - setSearch(''); + setSearch(""); setIsLoading(true); await navigator.geolocation.getCurrentPosition((position) => { const crd = position.coords; @@ -30,10 +31,10 @@ function App() { const fetchData = useCallback(async (search, location) => { const options = { - method: 'GET', + method: "GET", headers: { - 'X-RapidAPI-Key': '0173291af0msh62b3ca25953f210p13d732jsn66b4d9f97708', - 'X-RapidAPI-Host': 'weatherapi-com.p.rapidapi.com', + "X-RapidAPI-Key": "0173291af0msh62b3ca25953f210p13d732jsn66b4d9f97708", + "X-RapidAPI-Host": "weatherapi-com.p.rapidapi.com", }, }; const url = `https://weatherapi-com.p.rapidapi.com/current.json?q=${ @@ -44,6 +45,19 @@ function App() { return responseData; }, []); + const settingBackgroundImage = () => { + let text; + document.body.style.backgroundImage = `url(${SunnyImage})`; + if (isLoading === false) { + setTimeout(() => { + text = data.condition.text; + if (text.includes("rain")) { + document.body.style.backgroundImage = `url(${Rain})`; + } + }, 1000); + } + }; + useEffect(() => { fetchData(search, location).then((responseData) => { setPlace(responseData.location); @@ -61,6 +75,7 @@ function App() { return ( <>