Add files via upload

This commit is contained in:
NRJ YDV 2023-06-13 15:04:53 +05:30 committed by GitHub
commit 86ecf964f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 461 additions and 0 deletions

105
icons/clear.svg Normal file
View file

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 490.667 490.667" style="enable-background:new 0 0 490.667 490.667;" xml:space="preserve">
<circle style="fill:#FFC107;" cx="245.333" cy="245.333" r="160"/>
<g>
<path style="fill:#FFD54F;" d="M245.333,64C251.224,64,256,59.224,256,53.333V10.667C256,4.776,251.224,0,245.333,0
c-5.891,0-10.667,4.776-10.667,10.667v42.667C234.667,59.224,239.442,64,245.333,64z"/>
<path style="fill:#FFD54F;" d="M245.333,426.667c-5.891,0-10.667,4.776-10.667,10.667V480c0,5.891,4.776,10.667,10.667,10.667
c5.891,0,10.667-4.776,10.667-10.667v-42.667C256,431.442,251.224,426.667,245.333,426.667z"/>
<path style="fill:#FFD54F;" d="M480,234.667h-42.667c-5.891,0-10.667,4.776-10.667,10.667c0,5.891,4.776,10.667,10.667,10.667H480
c5.891,0,10.667-4.776,10.667-10.667C490.667,239.442,485.891,234.667,480,234.667z"/>
<path style="fill:#FFD54F;" d="M64,245.333c0-5.891-4.776-10.667-10.667-10.667H10.667C4.776,234.667,0,239.442,0,245.333
C0,251.224,4.776,256,10.667,256h42.667C59.224,256,64,251.224,64,245.333z"/>
<path style="fill:#FFD54F;" d="M140.096,84.395c1.909,3.307,5.44,5.341,9.259,5.333c1.873,0.007,3.715-0.486,5.333-1.429
c5.102-2.946,6.849-9.469,3.904-14.571l-21.333-36.949c-2.979-5.082-9.514-6.787-14.596-3.808
c-5.035,2.951-6.763,9.401-3.878,14.474L140.096,84.395z"/>
<path style="fill:#FFD54F;" d="M350.571,406.272c-2.98-5.082-9.515-6.786-14.597-3.806c-5.033,2.952-6.761,9.4-3.878,14.473
l21.333,36.949c1.909,3.307,5.44,5.341,9.259,5.333c1.873,0.007,3.715-0.486,5.333-1.429c5.102-2.946,6.849-9.469,3.904-14.571
L350.571,406.272z"/>
<path style="fill:#FFD54F;" d="M411.605,160c1.873,0.007,3.715-0.486,5.333-1.429l36.949-21.333
c5.22-2.731,7.238-9.176,4.507-14.396c-2.731-5.22-9.176-7.238-14.396-4.507c-0.266,0.139-0.525,0.289-0.778,0.45l-36.949,21.333
c-5.102,2.946-6.849,9.47-3.904,14.571c1.905,3.3,5.426,5.333,9.237,5.333V160z"/>
<path style="fill:#FFD54F;" d="M73.728,332.096l-36.949,21.333c-5.102,2.946-6.849,9.469-3.904,14.571
c1.905,3.3,5.426,5.333,9.237,5.333c1.873,0.007,3.715-0.486,5.333-1.429l36.949-21.333c5.22-2.731,7.238-9.176,4.507-14.396
c-2.731-5.22-9.176-7.238-14.396-4.507c-0.266,0.139-0.525,0.289-0.778,0.45L73.728,332.096z"/>
<path style="fill:#FFD54F;" d="M36.779,137.237l36.949,21.333c1.613,0.939,3.446,1.433,5.312,1.429
c5.891,0,10.666-4.776,10.666-10.667c0-3.81-2.033-7.331-5.333-9.237l-36.949-21.333c-4.972-3.16-11.564-1.692-14.724,3.279
s-1.692,11.564,3.279,14.724c0.253,0.161,0.512,0.311,0.778,0.45L36.779,137.237z"/>
<path style="fill:#FFD54F;" d="M453.888,353.429l-36.949-21.333c-4.972-3.16-11.564-1.692-14.724,3.279
c-3.16,4.971-1.692,11.564,3.279,14.724c0.253,0.161,0.513,0.311,0.778,0.45l36.949,21.333c1.619,0.943,3.46,1.436,5.333,1.429
c5.891,0,10.666-4.776,10.666-10.667c0-3.811-2.033-7.332-5.333-9.237V353.429z"/>
<path style="fill:#FFD54F;" d="M336,88.299c1.619,0.943,3.46,1.436,5.333,1.429c3.818,0.008,7.349-2.027,9.259-5.333l21.333-36.949
c2.911-5.121,1.119-11.633-4.002-14.544c-5.073-2.883-11.521-1.156-14.473,3.878l-21.333,36.949
C329.168,78.824,330.906,85.346,336,88.299z"/>
<path style="fill:#FFD54F;" d="M154.667,402.368c-5.102-2.945-11.625-1.198-14.571,3.904l-21.333,36.949
c-2.945,5.102-1.198,11.625,3.904,14.571c1.619,0.943,3.46,1.436,5.333,1.429c3.818,0.008,7.35-2.027,9.259-5.333l21.333-36.949
c2.94-5.105,1.186-11.627-3.919-14.567C154.671,402.37,154.669,402.369,154.667,402.368z"/>
</g>
<path d="M245.333,405.333c-88.366,0-160-71.634-160-160s71.634-160,160-160s160,71.634,160,160
C405.239,333.66,333.66,405.239,245.333,405.333z M245.333,106.667c-76.583,0-138.667,62.083-138.667,138.667
S168.75,384,245.333,384S384,321.917,384,245.333C383.906,168.789,321.878,106.761,245.333,106.667z"/>
<path d="M245.333,64c-5.891,0-10.667-4.776-10.667-10.667V10.667C234.667,4.776,239.442,0,245.333,0C251.224,0,256,4.776,256,10.667
v42.667C256,59.224,251.224,64,245.333,64z"/>
<path d="M245.333,490.667c-5.891,0-10.667-4.776-10.667-10.667v-42.667c0-5.891,4.776-10.667,10.667-10.667
c5.891,0,10.667,4.776,10.667,10.667V480C256,485.891,251.224,490.667,245.333,490.667z"/>
<path d="M480,256h-42.667c-5.891,0-10.667-4.776-10.667-10.667c0-5.891,4.776-10.667,10.667-10.667H480
c5.891,0,10.667,4.776,10.667,10.667C490.667,251.224,485.891,256,480,256z"/>
<path d="M53.333,256H10.667C4.776,256,0,251.224,0,245.333c0-5.891,4.776-10.667,10.667-10.667h42.667
c5.891,0,10.667,4.776,10.667,10.667C64,251.224,59.224,256,53.333,256z"/>
<path d="M149.333,89.728c-3.811,0-7.332-2.033-9.237-5.333l-21.333-36.949c-2.731-5.22-0.713-11.665,4.507-14.396
c4.912-2.569,10.972-0.949,13.946,3.729l21.333,36.949c2.946,5.102,1.198,11.625-3.904,14.571c-1.621,0.936-3.461,1.429-5.333,1.429
H149.333z"/>
<path d="M362.667,459.221c-3.811,0-7.332-2.033-9.237-5.333l-21.333-36.949c-3.16-4.972-1.692-11.564,3.279-14.724
c4.971-3.16,11.564-1.692,14.724,3.279c0.161,0.253,0.311,0.513,0.45,0.778l21.333,36.949c2.946,5.102,1.198,11.625-3.904,14.571
c-1.621,0.936-3.461,1.429-5.333,1.429H362.667z"/>
<path d="M411.605,160c-5.891,0-10.666-4.776-10.666-10.667c0-3.81,2.033-7.331,5.333-9.237l36.949-21.333
c4.972-3.16,11.564-1.692,14.724,3.279s1.692,11.564-3.279,14.724c-0.253,0.161-0.513,0.311-0.778,0.45l-36.949,21.333
C415.319,159.493,413.48,159.993,411.605,160z"/>
<path d="M42.112,373.333c-5.891,0-10.666-4.776-10.666-10.667c0-3.811,2.033-7.332,5.333-9.237l36.949-21.333
c5.22-2.731,11.665-0.713,14.396,4.507c2.569,4.911,0.949,10.972-3.729,13.946l-36.949,21.333
C45.826,372.826,43.986,373.327,42.112,373.333z"/>
<path d="M79.061,160c-1.872,0-3.712-0.493-5.333-1.429l-36.949-21.333c-4.972-3.16-6.44-9.753-3.279-14.724
c2.974-4.678,9.035-6.299,13.946-3.729l36.949,21.333c5.09,2.966,6.812,9.497,3.846,14.587
C86.336,157.972,82.844,159.987,79.061,160z"/>
<path d="M448.555,373.333c-1.872,0-3.712-0.493-5.333-1.429l-36.949-21.333c-5.22-2.731-7.238-9.176-4.507-14.396
s9.176-7.238,14.396-4.507c0.266,0.139,0.525,0.289,0.778,0.45l36.949,21.333c5.102,2.946,6.849,9.469,3.904,14.571
c-1.905,3.3-5.426,5.333-9.237,5.333V373.333z"/>
<path d="M341.333,89.728c-5.891,0-10.667-4.776-10.666-10.667c0-1.872,0.493-3.712,1.429-5.333l21.333-36.949
c3.16-4.972,9.753-6.44,14.724-3.279c4.678,2.974,6.298,9.034,3.729,13.946l-21.333,36.949
C348.648,87.688,345.136,89.72,341.333,89.728z"/>
<path d="M128,459.221c-5.891,0-10.667-4.776-10.666-10.667c0-1.872,0.493-3.712,1.429-5.333l21.333-36.949
c2.731-5.22,9.176-7.238,14.396-4.507s7.238,9.176,4.507,14.396c-0.139,0.266-0.289,0.525-0.45,0.778l-21.333,36.949
C135.314,457.182,131.803,459.214,128,459.221z"/>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.8 KiB

1
icons/cloud.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 7.1 KiB

1
icons/haze.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 6.7 KiB

1
icons/rain.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 7.2 KiB

1
icons/snow.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 9.1 KiB

1
icons/storm.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.3 KiB

62
index.html Normal file
View file

@ -0,0 +1,62 @@
<!DOCTYPE html>
<!-- Coding By CodingNepal - youtube.com/codingnepal -->
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Weather</title>
<link rel="stylesheet" href="style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Setting Icon of Website -->
<link rel="icon" type="image/png" href="https://www.pngitem.com/pimgs/m/178-1780549_circle-icons-weather-weather-icon-png-circle-transparent.png">
<!-- Linking BoxIcon for Icon -->
<link href='https://unpkg.com/boxicons@2.0.9/css/boxicons.min.css' rel='stylesheet'>
</head>
<body>
<div class="wrapper">
<header><i class='bx bx-left-arrow-alt'></i>Weather App</header>
<section class="input-part">
<p class="info-txt"></p>
<div class="content">
<input type="text" spellcheck="false" placeholder="Enter city name & Hit Enter" required>
<div class="separator"></div>
<button>Get Device Location</button>
</div>
</section>
<section class="weather-part">
<img src="" alt="Weather Icon">
<div class="temp">
<span class="numb">_</span>
<span class="deg">°</span>C
</div>
<div class="weather">_ _</div>
<div class="location">
<i class='bx bx-map'></i>
<span>_, _</span>
</div>
<div class="bottom-details">
<div class="column feels">
<i class='bx bxs-thermometer'></i>
<div class="details">
<div class="temp">
<span class="numb-2">_</span>
<span class="deg">°</span>C
</div>
<p>Feels like</p>
</div>
</div>
<div class="column humidity">
<i class='bx bxs-droplet-half'></i>
<div class="details">
<span>_</span>
<p>Humidity</p>
</div>
</div>
</div>
</section>
</div>
<script src="script.js"></script>
</body>
</html>

92
script.js Normal file
View file

@ -0,0 +1,92 @@
const wrapper = document.querySelector(".wrapper"),
inputPart = wrapper.querySelector(".input-part"),
infoTxt = inputPart.querySelector(".info-txt"),
inputField = inputPart.querySelector("input"),
locationBtn = inputPart.querySelector("button"),
wIcon = wrapper.querySelector(".weather-part img"),
arrowBack = wrapper.querySelector("header i");
const apiKey = "c97161f5ff5a992afb41796b30adc57f";
let api;
inputField.addEventListener("keyup", (e) => {
if (e.key == "Enter" && inputField.value != "") {
requestApi(inputField.value);
}
});
locationBtn.addEventListener("click", () => {
if (navigator.geolocation) {
//if browser supports geolocation
navigator.geolocation.getCurrentPosition(onSuccess, onError);
} else {
alert("your browser does not support geolocation api");
}
});
function onSuccess(position) {
const { latitude, longitude } = position.coords; //getting latitue and longitude of use device from coords obj
api = `https://api.openweathermap.org/data/2.5/weather?lat=${latitude}&lon=${longitude}&units=metric&appid=${apiKey}`;
fecthData();
}
function onError(error) {
infoTxt.innerText = error.message;
infoTxt.classList.add("error");
}
function requestApi(city) {
api = `https://api.openweathermap.org/data/2.5/weather?q=${city}&units=metric&appid=${apiKey}`;
fecthData();
}
function fecthData() {
infoTxt.innerText = "Getting Weather details....";
infoTxt.classList.add("pending");
// getting api response and returning it with parsing into js obj and in another
// then function calling weatherDetails() with passing api result as an argument
fetch(api)
.then((response) => response.json())
.then((result) => weatherDetails(result));
}
function weatherDetails(info) {
if (info.cod == "404") {
infoTxt.innerText = `${inputField.value} isn't a valid city name`;
infoTxt.classList.replace("pending", "error");
} else {
// lets gets
const city = info.name;
const country = info.sys.country;
const { description, id } = info.weather[0];
const { feels_like, humidity, temp } = info.main;
if (id == 800) {
wIcon.src = "icons/clear.svg";
} else if (id >= 200 && id <= 232) {
wIcon.src = "icons/storm.svg";
} else if (id >= 600 && id <= 622) {
wIcon.src = "icons/snow.svg";
} else if (id >= 701 && id <= 781) {
wIcon.src = "icons/haze.svg";
} else if (id >= 801 && id <= 804) {
wIcon.src = "icons/cloud.svg";
} else if ((id >= 500 && id <= 531) || (id >= 300 && id <= 321)) {
wIcon.src = "icons/rain.svg";
}
// lets pass thes values to partivular html element
wrapper.querySelector(".temp .numb").innerText = Math.floor(temp);
wrapper.querySelector(".weather").innerText = description;
wrapper.querySelector(".location span").innerText = `${city}, ${country}`;
wrapper.querySelector(".temp .numb-2").innerText = Math.floor(feels_like);
wrapper.querySelector(".humidity span").innerText = `${humidity}%`;
infoTxt.classList.remove("pending", "error");
wrapper.classList.add("active");
console.log("info", info);
}
}
arrowBack.addEventListener("click", () => {
wrapper.classList.remove("active");
});

197
style.css Normal file
View file

@ -0,0 +1,197 @@
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
body{
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
background: linear-gradient(to right, #000428, #004e92);
}
::selection{
color: #fff;
background: #43AFFC;
}
.wrapper{
width: 400px;
background: #fff;
border-radius: 7px;
box-shadow: 7px 7px 20px rgba(0, 0, 0, 0.05);
}
.wrapper header{
display: flex;
font-size: 21px;
font-weight: 500;
color: #000428;
padding: 16px 15px;
align-items: center;
border-bottom: 1px solid #ccc;
}
header i{
font-size: 0em;
cursor: pointer;
margin-right: 8px;
}
.wrapper.active header i{
margin-left: 5px;
font-size: 30px;
}
.wrapper .input-part{
margin: 20px 25px 30px;
}
.wrapper.active .input-part{
display: none;
}
.input-part .info-txt{
display: none;
font-size: 17px;
text-align: center;
padding: 12px 10px;
border-radius: 7px;
margin-bottom: 15px;
}
.input-part .info-txt.error{
color: #721c24;
display: block;
background: #f8d7da;
border: 1px solid #f5c6cb;
}
.input-part .info-txt.pending{
color: #0c5460;
display: block;
background: #d1ecf1;
border: 1px solid #bee5eb;
}
.input-part :where(input, button){
width: 100%;
height: 55px;
border: none;
outline: none;
font-size: 18px;
border-radius: 7px;
}
.input-part input{
text-align: center;
padding: 0 15px;
border: 1px solid #ccc;
}
.input-part input:is(:focus, :valid){
border: 2px solid #000428;
}
.input-part input::placeholder{
color: #bfbfbf;
}
.input-part .separator{
height: 1px;
width: 100%;
margin: 25px 0;
background: #ccc;
position: relative;
display: flex;
align-items: center;
justify-content: center;
}
.separator::before{
content: "or";
color: #b3b3b3;
font-size: 19px;
padding: 0 15px;
background: #fff;
}
.input-part button{
color: #fff;
cursor: pointer;
background: linear-gradient(to left, #000428, #004e92);
transition: 0.3s ease;
}
.input-part button:hover{
background: #000428;
}
.wrapper .weather-part{
display: none;
margin: 30px 0 0;
align-items: center;
justify-content: center;
flex-direction: column;
}
.wrapper.active .weather-part{
display: flex;
}
.weather-part img{
max-width: 125px;
}
.weather-part .temp{
display: flex;
font-weight: 500;
font-size: 72px;
}
.weather-part .temp .numb{
font-weight: 600;
}
.weather-part .temp .deg{
font-size: 40px;
display: block;
margin: 10px 5px 0 0;
}
.weather-part .weather{
font-size: 21px;
text-align: center;
margin: -5px 20px 15px;
}
.weather-part .location{
display: flex;
font-size: 19px;
padding: 0 20px;
text-align: center;
margin-bottom: 30px;
align-items: flex-start;
}
.location i{
font-size: 22px;
margin: 4px 5px 0 0;
}
.weather-part .bottom-details{
display: flex;
width: 100%;
justify-content: space-between;
border-top: 1px solid #ccc;
}
.bottom-details .column{
display: flex;
width: 100%;
padding: 15px 0;
align-items: center;
justify-content: center;
}
.column i{
color: #000428;
font-size: 40px;
}
.column.humidity{
border-left: 1px solid #ccc;
}
.column .details{
margin-left: 3px;
}
.details .temp, .humidity span{
font-size: 18px;
font-weight: 500;
margin-top: -3px;
}
.details .temp .deg{
margin: 0;
font-size: 17px;
padding: 0 2px 0 1px;
}
.column .details p{
font-size: 14px;
margin-top: -6px;
}
.humidity i{
font-size: 37px;
}