Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 74 additions & 50 deletions style.css
Original file line number Diff line number Diff line change
@@ -1,63 +1,87 @@
.grid-container {

display: grid;
grid-template-columns: 50% 50%;
background-color: white;
padding: 5px;
height: 100%;
* {
padding: 0;
margin: 0;
}
.grid-item1{

background-color: royalblue;
display: grid;
.app-wrap {
background: linear-gradient(180deg, #7802ae, #460166);
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.grid-item{

background-color: lightgrey;
display: grid;
.search-box {
height: 61px;
width: 217px;
border-top-left-radius: 30px;
border: none;
border-bottom-right-radius: 30px;
border-bottom: 4px solid #d5820c;
background: #9d4ec2;
outline: none;
padding: 0 5%;
font-size: larger;
color: #000000a6;
transition: 0.5s ease;
}
h1, h3{
color: white;
font-weight: bolder;
margin-top: 25%;
}
span{
color: black;
font-weight: bolder;
}
p{
color: white;

}
li{
color: white;


.search-box::placeholder {
color: #000000a6;
transition: 0.5s ease;
}
.bdy{
margin-left: 20%;

.search-box:focus::placeholder {
color: #9d4ec2;
}
.dd{
margin-left: 25%;
margin-top: 10%;

header {
display: flex;
flex-direction: column;
align-items: center;
}
#pp{
color: black;

.search {
height: 6vh;
width: 7vw;
border: none;
border-top-right-radius: 25px;
border-bottom-left-radius: 25px;
margin: 10% 0;
font-size: medium;
box-shadow: 0px 0px 12px 1px rgb(0 0 0 / 48%);
transition: 0.5s ease-out;
background: aliceblue;
}
#show{
color: black;
font-size: xx-large;

:is(.location, .current) {
display: flex;
flex-direction: column;
align-items: center;
color: aliceblue;
}
#show1,#show3{
color: black;
font-size: medium;

.city {
font-size: x-large;
}
#show2{
color: black;
font-size: xx-large;

.temp {
font-size: 6em;
margin: 20% 0;
text-shadow: 0px 8px 1px rgb(0 0 0);
font-weight: bold;
}
#tt{
margin-left: 20%;
margin-top: 20%;

.weather {
font-size: xx-large;
font-style: italic;
font-weight: 600;
text-shadow: 0px 1px 5px black;
}



.hi-low {
font-size: xx-large;
font-weight: 100;
text-shadow: 0px 1px 5px black;
}
58 changes: 31 additions & 27 deletions weather.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Weather app</title>
<link rel="stylesheet" href="main.css" />
</head>
<body>
<div class="app-wrap">
<header>
<input type="text" autocomplete="on" class="search-box"
placeholder="Search for a city..." />
</header>
<main>
<section class="location">
<div class="city"></div>
<div class="date"></div>
</section>
<div class="current">
<div class="temp"><span>°c</span></div>
<div class="weather"></div>
<div class="hi-low">°c / °c</div>
</div>
</main>
</div>
<script src="main.js"></script>
</body>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Weather app</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="app-wrap">
<header>
<input
type="text"
autocomplete="on"
class="search-box"
placeholder="Search for a city..."
/>
</header>
<main>
<section class="location">
<div class="city"></div>
<div class="date"></div>
</section>
<div class="current">
<div class="temp"><span>°c</span></div>
<div class="weather"></div>
<div class="hi-low">°c / °c</div>
</div>
</main>
</div>
<script src="weather.js"></script>
</body>
</html>
50 changes: 50 additions & 0 deletions weather.js
Original file line number Diff line number Diff line change
@@ -1 +1,51 @@
//Complete the Weather API Backend part using openweathermap api
document.querySelector(".search-box").addEventListener("input", async (e) => {
const days = [
"sunday",
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
]
const months = [
"january",
"february",
"march",
"april",
"may",
"june",
"july",
"august",
"september",
"october",
"november",
"december",
]
const today = new Date()
const search_city = e.target.value
console.log(search_city)
const url = `https://api.openweathermap.org/data/2.5/weather?q=${search_city}&units=metric&appid=01525b1923322486597bf9c18edb85a3`
try {
const res = await fetch(url)
const output = await res.json()
console.log(output)
document.querySelector(".city").innerHTML =
output.name + " , " + output.sys.country
document.querySelector(".date").innerHTML =
days[today.getDay()] +
" " +
today.getDate() +
" " +
months[today.getMonth()] +
" " +
today.getFullYear()
document.querySelector(".temp").innerHTML = output.main.temp + "°c"
document.querySelector(".weather").innerHTML = output.weather[0].main
document.querySelector(".hi-low").innerHTML =
output.main.temp_min + "°c / " + output.main.temp_max + "°c"
} catch (e) {
console.log(e.message)
}
})