-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from mdsiaofficial/main
Project 19 added feat: added Weather App UI and functionality
- Loading branch information
Showing
15 changed files
with
286 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Weather App</title> | ||
<link rel="stylesheet" href="style.css"> | ||
|
||
</head> | ||
<body> | ||
|
||
<div class="AppCard"> | ||
|
||
<!-- input --> | ||
<div class="title"> | ||
<h1>Weather App</h1> | ||
<p>Check Weather searching <span>City Name</span></p> | ||
</div> | ||
<div class="searchArea"> | ||
|
||
<input id="impTXT" type="text" placeholder="enter city name" spellcheck="false"> | ||
<!-- search button --> | ||
<button type="submit"><img src="img/search.png"></button> | ||
|
||
</div> | ||
<!-- | ||
<div> | ||
<h4 class="error">Error Finding the city...Search Again</h4> | ||
</div> | ||
--> | ||
|
||
<!-- display --> | ||
<div class="WeatherDisplay"> | ||
|
||
<img src="" class="Weather-Icon"> | ||
|
||
<h1 class="temperature"></h1> | ||
<h2 class="city"></h2> | ||
|
||
<!-- details here --> | ||
<div class="detailsInfo"> | ||
<div class="column"> | ||
|
||
<img src="img/humidity.png"> | ||
<div> | ||
<p class="humidity"></p> | ||
<p>Humidity</p> | ||
</div> | ||
|
||
</div> | ||
|
||
<div class="column"> | ||
|
||
<img src="img/wind.png"> | ||
<div> | ||
<p class="wind"></p> | ||
<p>Wind</p> | ||
</div> | ||
|
||
</div> | ||
|
||
|
||
</div> | ||
</div> | ||
|
||
|
||
|
||
</div> | ||
|
||
|
||
|
||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
"use strict"; | ||
|
||
const apiURL = `https://api.openweathermap.org/data/2.5/weather?units=metric`; | ||
const appKey = `&appid=1dc02c2cda3d32eda98eede7405d0e42`; | ||
|
||
const searchField = document.querySelector(".searchArea input"); | ||
const searchBtn = document.querySelector(".searchArea button"); | ||
const weatherIcon = document.querySelector(".Weather-Icon"); | ||
|
||
|
||
function city() { | ||
const inputName = document.querySelector("#impTXT"); | ||
const city = `&q=${inputName.value}`; | ||
checkWeather(city); | ||
} | ||
|
||
// document.querySelector(".WeatherDisplay").style.display = "block"; | ||
|
||
|
||
async function checkWeather(city) { | ||
const response = await fetch(apiURL + appKey + city); | ||
var data = await response.json(); | ||
console.log(data); | ||
|
||
document.querySelector(".city").innerHTML = data.name; | ||
document.querySelector(".temperature").innerHTML = Math.round(data.main.temp) + "°C"; | ||
document.querySelector(".humidity").innerHTML = data.main.humidity + "%"; | ||
document.querySelector(".wind").innerHTML = data.wind.speed + "km/h"; | ||
|
||
if (data.weather[0].main == "Clouds") { | ||
weatherIcon.src = "img/clouds.png"; | ||
} | ||
|
||
if (data.weather[0].main == "Mist") { | ||
weatherIcon.src = "img/Mist.png"; | ||
} | ||
|
||
if (data.weather[0].main == "Rain") { | ||
weatherIcon.src = "img/rain.png"; | ||
} | ||
|
||
if (data.weather[0].main == "Drizzle") { | ||
weatherIcon.src = "img/drizzle.png"; | ||
} | ||
|
||
if (data.weather[0].main == "Clear") { | ||
weatherIcon.src = "img/clear.png"; | ||
} | ||
|
||
if (data.weather[0].main == "Snow") { | ||
weatherIcon.src = "img/snow.png"; | ||
} | ||
|
||
if (data.weather[0].main == "Haze") { | ||
weatherIcon.src = "img/haze.png"; | ||
} | ||
|
||
document.querySelector(".WeatherDisplay").style.display = "block"; | ||
}; | ||
|
||
searchBtn.addEventListener("click", city); // addEventlistener e funcion call korle () lage na | ||
|
||
|
||
// const input = document.getElementById("impTXT"); | ||
searchField.addEventListener("keypress", function (event) { | ||
if (event.key === "Enter") { | ||
event.preventDefault(); | ||
city(); | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
|
||
*{ | ||
margin: 0; | ||
padding: 0; | ||
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; | ||
box-sizing: border-box; | ||
} | ||
|
||
body{ | ||
background: #222; | ||
} | ||
.AppCard{ | ||
width: 90%; | ||
max-width: 470px; | ||
background: linear-gradient(200deg, #fe9000, #8a5469); | ||
color: #fefffe; | ||
margin: 100px auto 0; | ||
|
||
border-radius: 15px; | ||
|
||
padding: 40px 40px; | ||
|
||
text-align: center; | ||
border: 1px solid white; | ||
} | ||
|
||
.searchArea{ | ||
|
||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
|
||
|
||
} | ||
|
||
.searchArea input{ | ||
border: 0; | ||
outline: 0; | ||
background: #35282d; | ||
color: #7a7171; | ||
|
||
padding: 15px 25px; | ||
|
||
height: 60px; | ||
|
||
border-radius: 30px; | ||
flex: 1; | ||
/* This property is used to make the input field flexible, | ||
so that it can adjust its size according to the available space. */ | ||
|
||
margin-right: 16px; | ||
font-size: large; | ||
|
||
|
||
} | ||
|
||
|
||
.Weather-Icon{ | ||
|
||
width: 170px; | ||
margin-top: 30px; | ||
} | ||
|
||
.searchArea button{ | ||
border: 0; | ||
outline: 0; | ||
background: #35282d; | ||
border-radius: 50%; | ||
width: 60px; | ||
height: 60px; | ||
cursor: pointer; | ||
} | ||
.searchArea button img{ | ||
width: 20px; | ||
padding-top: 5px; | ||
} | ||
|
||
.WeatherDisplay h1{ | ||
font-size: 80px; | ||
font-weight: 500; | ||
} | ||
.WeatherDisplay h2{ | ||
font-size: 45px; | ||
font-weight: 400; | ||
margin-top: -10px; | ||
} | ||
|
||
|
||
.detailsInfo{ | ||
display: flex; | ||
|
||
align-items: center; | ||
justify-content: space-between; | ||
padding: 0 20px; | ||
margin-top: 50px; | ||
|
||
} | ||
|
||
.column{ | ||
display: flex; | ||
align-items: center; | ||
text-align: left; | ||
} | ||
|
||
.column img{ | ||
width: 50px; | ||
margin-right: 10px; | ||
} | ||
|
||
.humidity, .wind{ | ||
font-size: larger; | ||
margin-top: -5px; | ||
} | ||
|
||
|
||
.WeatherDisplay{ | ||
display: none; | ||
} | ||
|
||
.title{ | ||
margin-top: -30px; | ||
margin-bottom: 15px; | ||
} | ||
|
||
.title p{ | ||
font-size: 18px; | ||
} | ||
|
||
.title p span{ | ||
color:#35282d; | ||
font-weight: 800; | ||
} | ||
|
||
|