Skip to content

Commit

Permalink
Merge pull request #728 from saketh-05/fixes
Browse files Browse the repository at this point in the history
Added Weatherly Project
  • Loading branch information
SUGAM-ARORA authored Aug 10, 2024
2 parents a5a3178 + a5cd53b commit 0935d8f
Show file tree
Hide file tree
Showing 8 changed files with 223 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Components/CardMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ const features = [
pro: icon1,
hearts: 77,
title: "WeatherLy",
dev: "AlexJohnson",
dev: "Saketh D.Surya",
type: "Weather",
github: "https://github.com/saketh-05/WeatherLy",
role: "Full Stack Developer, UX Specialist",
about:
"I'm a dynamic professional skilled in both front-end and back-end development, with a keen eye for designing intuitive user interfaces and user experiences.",
Expand Down
Binary file modified src/Components/projects/card6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/Components/projects/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ export const features = [
pro: icon1,
hearts: 77,
title: "WeatherLy",
dev: "AlexJohnson",
dev: "Saketh D.Surya",
type: "Weather",
github: "https://github.com/saketh-05/WeatherLy",
role: "Full Stack Developer, UX Specialist",
about: "I'm a dynamic professional skilled in both front-end and back-end development, with a keen eye for designing intuitive user interfaces and user experiences.",
text: "WeatherLy is your ultimate destination for accurate and up-to-date weather information. This sleek and user-friendly website offers comprehensive weather forecasts and real-time data to help you plan your day with confidence. With WeatherLy, you can quickly access current conditions, including temperature, humidity, wind speed, and visibility. Detailed hourly, daily, and weekly forecasts keep you prepared for any weather changes. The platform also provides timely severe weather alerts, ensuring your safety during extreme conditions. Interactive maps let you explore weather patterns with dynamic radar visuals showing precipitation, cloud cover, and temperature variations. Additionally, WeatherLy allows you to save custom locations, making it easy to check the weather for your favorite places. Whether on a desktop or mobile device, WeatherLy delivers reliable and precise weather data, helping you make informed decisions and stay prepared for whatever the weather brings."
Expand Down
22 changes: 22 additions & 0 deletions src/Projects/WeatherLy/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover"
/>
<title>Weather</title>
<link href="style.css" rel="stylesheet" />
</head>
<body>
<form class="inputForm">
<input type="text" class="inputcity" placeholder="Enter name of City" />
<button type="submit" onclick="getWeather()">GetWeather</button>
</form>
<div class="display" style="display: none"></div>
<footer class="footer">All Rights Reserved ||</footer>
<!-- @SakethSurya 😜 -->
<script src="script.js"></script>
</body>
</html>
Binary file added src/Projects/WeatherLy/scenery.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 105 additions & 0 deletions src/Projects/WeatherLy/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
const city = document.querySelector(".inputcity");

const inputform = document.querySelector(".inputForm");

const card = document.querySelector(".display");

const apikey = "4ff8a6dd831902dadd5a06c8aca75468";

inputform.addEventListener("submit", async (event) => {
event.preventDefault();
const inputCity = city.value;

if (inputCity) {
try {
const wdata = await getWeather(inputCity);
displayCard(wdata);
} catch (error) {
dispError(error);
}
} else {
dispError("Please enter a city");
}
});

async function getWeather(city) {
const apifetch = `https://api.openweathermap.org/data/2.5/weather?q=${city}&appid=${apikey}`;

const response = await fetch(apifetch);
console.log(response);

if (!response.ok) {
throw new Error("Could not Fetch the weather data");
}
return response.json();
}

function displayCard(data) {
console.log(data);
const {
name: value,
main: { temp, humidity },
weather: [{ description, id }],
} = data;

const city = document.createElement("h2");
const temprature = document.createElement("p");
const fahrenhiet = document.createElement("p");
const humidityDisp = document.createElement("p");
const descrip = document.createElement("p");
const emoji = document.createElement("p");

city.textContent = value;
temprature.textContent = `${(temp - 273.15).toFixed(1)}°C`;
fahrenhiet.textContent = `${(((temp - 273.15) * 9) / 5 + 32).toFixed(1)}°F`;
humidityDisp.textContent = `Humidity: ${humidity}%`;
descrip.textContent = description;
emoji.textContent = getWeatherEmoji(id);

city.classList.add("city");
//temprature.classList.add("display");
//fahrenhiet.classList.add("display");
humidityDisp.classList.add("humidityDisp");
descrip.classList.add("decrip");
emoji.classList.add("emoji");

card.textContent = "";
card.style.display = "flex";
card.appendChild(city);
card.appendChild(temprature);
card.appendChild(fahrenhiet);
card.appendChild(humidityDisp);
card.appendChild(descrip);
card.appendChild(emoji);
}

function getWeatherEmoji(weatherId) {
switch (true) {
case weatherId >= 200 && weatherId < 300:
return "⛈️";
case weatherId >= 300 && weatherId < 400:
return "🌦️";
case weatherId >= 500 && weatherId < 600:
return "🌧️";
case weatherId >= 600 && weatherId < 700:
return "🌨️";
case weatherId == 701:
return "🌁";
case weatherId == 800:
return "☀️";
case weatherId > 800:
return "⛅";
default:
return "❓";
}
}

function dispError(message) {
const error = document.createElement("p");
error.textContent = message;
error.classList.add("errorDisplay");

card.textContent = "";
card.style.display = "flex";
card.appendChild(error);
}
92 changes: 92 additions & 0 deletions src/Projects/WeatherLy/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@

body{
margin: 0;
background-color: rgb(32, 54, 151);
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 5%;
}

.inputForm{
margin: 5%;
}
.display{
position: relative;
font-size: 2rem;
background:linear-gradient(rgb(216, 202, 202),crimson);
display: flex;
flex-direction: column;
align-items: center;
padding: 2% 7% 2% 7%;
border-radius: 5px;
box-shadow: 5px 5px 10px 1px rgb(10, 224, 231),
5px 5px 5px 0px rgb(215, 53, 13) ,
1px 1px 10px 5px rgb(181, 26, 26) inset;
}

.city{
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande';
}

.humidityDisp{
font-family:'Trebuchet MS', 'Lucida Sans Unicode';
font-size: 35px;
}

.descrip{
font-family: 'Lucida Sans Regular', 'Lucida Grande';
font-size: 35px;
}

.emoji{
font-size: 400%;
margin: 0;
}

.inputcity{
font-size: 1.8rem;
color: brown;
max-width: 300px;
padding: 5px;
border-radius: 5px;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande';
}

.errorDisplay{
font-size: 1.8rem;
color: rgb(255, 255, 1);
font-weight: bold;
font-style: italic;
}

button[type="submit"]{
font-weight: bold;
cursor: pointer;
font-size: 1.8rem;
background-color: rgb(1, 255, 242);
color: rgb(83, 13, 83);
padding: 5px 10px 5px 10px;
font-family: 'Gill Sans MT';
border-radius: 7px;
}
button[type="submit"]:hover{
background-color: rgb(40, 172, 161);
transition: .25s ease-in-out;
}

.footer{
font-size: 30px;
color: rgb(255, 255, 0);
margin: 2%;
}

@media screen and (max-width: 700px){
.inputForm{
margin:5%;
display: flex;
align-items: center;
justify-content: center;

}
}
Binary file modified src/img/card6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0935d8f

Please sign in to comment.