Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ARRY7686 authored Sep 7, 2024
0 parents commit 8e7d3d0
Show file tree
Hide file tree
Showing 11 changed files with 193 additions and 0 deletions.
Binary file added images/clear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/clouds.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/drizzle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/humidity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/mist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/rain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/snow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/wind.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 84 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Weatherify</title>

<link rel="stylesheet" href="./styles.css" />
</head>
<body>
<div class="card">
<div class="search">
<input type="text" placeholder="Enter City Name:" spellcheck="false" />
<button>
<img src="./images/search.png" alt="Search_Icon" />
</button>
</div>
<div class="error">
<p>Invalid City Name</p>
</div>
<div class="weather">
<img src="./images/rain.png" alt="defaultweather" class="weatherIcon" />
<h1 class="temp">22°C</h1>
<h2 class="city">New York</h2>
<div class="details">
<div class="col">
<img src="./images/humidity.png" alt="humidity" />
<div>
<p class="humidity">50%</p>
<p>Humidity</p>
</div>
</div>
<div class="col">
<img src="./images/wind.png" alt="humidity" />
<div>
<p class="wind">15kmph</p>
<p>Wind Speed</p>
</div>
</div>
</div>
</div>
</div>
<script>
const apikey = "4f4cc76fd920f5f1322e6daf978016cf";
const apiurl =
"https://api.openweathermap.org/data/2.5/weather?units=metric&q=";
const search = document.querySelector(".search input");
const btn = document.querySelector(".search button");
async function checkWeather(city) {
const response = await fetch(apiurl + city + `&appid=${apikey}`);
if (response.status == 404) {
document.querySelector(".error").style.display = "block";
document.querySelector(".weather").style.display = "none";
} else {
var data = await response.json();
document.querySelector(".city").innerHTML = data.name;
document.querySelector(".temp").innerHTML =
Math.round(data.main.temp) + "°C";
document.querySelector(".humidity").innerHTML =
data.main.humidity + "%";
document.querySelector(".wind").innerHTML = data.wind.speed + "kmph";
if (data.weather[0].main == "Clouds") {
document.querySelector(".weatherIcon").src = "./images/clouds.png";
} else if (data.weather[0].main == "Rain") {
document.querySelector(".weatherIcon").src = "./images/rain.png";
} else if (data.weather[0].main == "Clear") {
document.querySelector(".weatherIcon").src = "./images/clear.png";
} else if (data.weather[0].main == "Drizzle") {
document.querySelector(".weatherIcon").src = "./images/drizzle.png";
} else if (data.weather[0].main == "Mist") {
document.querySelector(".weatherIcon").src = "./images/mist.png";
} else if (data.weather[0].main == "Snow") {
document.querySelector(".weatherIcon").src = "./images/snow.png";
}
document.querySelector(".weather").style.display = "block";
document.querySelector(".error").style.display = "none";
}
}
btn.addEventListener("click", () => {
checkWeather(search.value);
});
</script>
</body>
</html>
109 changes: 109 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
color: #ffffff;
}

body {
background: #222;
}

.card {
background: linear-gradient(135deg, #3494E6, #EC6EAD);
width: 90%;
max-width: 470px;
margin: 100px auto 0;
border-radius: 20px;
padding: 40px 35px;
text-align: center;
}

.search {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
}

.search input {
height: 60px;
padding: 10px 25px;
border: 0;
outline: 0;
background: #ebfffc;
color: #555;
border-radius: 30px;
flex: 1;
margin-right: 16px;
font-size: 18px;
}

.search button {
border: 0;
outline: 0;
background: #ebfffc;
border-radius: 50%;
width: 60px;
height: 60px;
cursor: pointer;
}

.search button img {
width: 16px;
}

.weatherIcon {
width: 170px;
margin-top: 30px;
}

.weather h1 {
font-size: 80px;
font-weight: 500;
}

.weather h2 {
font-size: 45px;
font-weight: 400;
margin-top: -10px;
}

.details {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20px;
margin-top: 50px;
}

.col {
display: flex;
align-items: center;
text-align: left;

}

.col img {
width: 20px;

margin-right: 10px;
}

.humidity .wind {
font-size: 28px;
margin-top: -6px;
}

.weather {
display: none;
}

.error {
display: none;
text-align: left;
margin-left: 10px;
font-size: 14px;
margin-top: 10px;
}

0 comments on commit 8e7d3d0

Please sign in to comment.