Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
eefca8a
skeleton of page set up
WinsEdwards Jun 8, 2023
4fecda9
added dropdown html
argoodm Jun 8, 2023
6d5dfef
button html added
argoodm Jun 8, 2023
9183b39
all button html added, arrow styling added
argoodm Jun 8, 2023
00ff4a1
incrementTemp & decrementTemp functions
WinsEdwards Jun 8, 2023
8e23a18
Basic visual formatting
WinsEdwards Jun 11, 2023
4a7d996
Adding css grid
WinsEdwards Jun 11, 2023
b65a22c
Updated row gutters and padding
WinsEdwards Jun 11, 2023
853b550
corrected button styling for up and down arrows
argoodm Jun 11, 2023
f492647
wave 1 and 2 completed, arrow funcitonality
argoodm Jun 11, 2023
0e07293
Added city state, id.
WinsEdwards Jun 12, 2023
31ea1cc
city input test functionality
argoodm Jun 12, 2023
0af5373
new city functionality completed
argoodm Jun 12, 2023
8293aad
Linking locationiq api
WinsEdwards Jun 12, 2023
6dfa35d
Continued API connection
WinsEdwards Jun 12, 2023
66f4354
Trying to figure out axios import
WinsEdwards Jun 12, 2023
290d054
api formatting
argoodm Jun 13, 2023
8fe1887
weather api functionality added pre button
argoodm Jun 13, 2023
1624994
realtimetemp functionality limbo
argoodm Jun 13, 2023
0785f57
Wave 4 API complete
argoodm Jun 13, 2023
cebc963
wave six completed, working reset functionality
argoodm Jun 13, 2023
9e31c87
Wave 5 functionality complete
argoodm Jun 13, 2023
108697b
set up for color change
argoodm Jun 13, 2023
0288140
Formatting cleaned up
WinsEdwards Jun 14, 2023
a6f80e3
More formatting changes
WinsEdwards Jun 14, 2023
82cd795
color change functionality completed
argoodm Jun 14, 2023
2c533f4
wave 2 finished
argoodm Jun 14, 2023
4e3cd7c
formatting html
WinsEdwards Jun 14, 2023
ea0bafb
css format updated
WinsEdwards Jun 14, 2023
55f6e5a
All requirements met
WinsEdwards Jun 14, 2023
838e406
Final formatting
WinsEdwards Jun 14, 2023
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
74 changes: 73 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,79 @@
<link rel="stylesheet" href="styles/index.css" />
</head>
<body>
<script src="./src/index.js"></script>
<main class="container">
<header class="header">
<h1>Weather Report</h1>
<h2 id="city">For the lovely city of Atlanta</h2>
<br>
</header>
<section class="content_container">
<section id="temperature_section">
<h2>Temperature</h2>
<div class="directional_arrow">
<button id="up_arrow">
<span>^</span>
</button>
<section>
<h4 class=green id="currentTemp">50°</h4>
</section>
<button id="down_arrow">
<span>⌄</span>
</button>
</div>
<br>
<div>
<button id="getTemp">
<span>Get real time temperature</span>
</button>
</div>
<br>
</section>
<section id="sky_section">
<h2>Sky</h2>
<div>
<br>
<label for="sky">Choose a sky:
<br>
<br>
<select class="sky_selecting" onchange="skyChange">
<option value="☀️ 🪂 ☀️ 🦜 ☄️ ☀️ 🦜 ☀️ ☁️">Sunny</option>
<option value="☁️ ☁️ ☁️ ☁️ ☁️ 🌤 ☁️ ☁️ ☁️">Cloudy</option>
<option value="🌧 🌈 ⛈ 🌧 💧 ⛈ 🌦 💧 🌧">Rainy</option>
<option value="🌨 ❄️ 🌨 ❄️ 🌨 ❄️ 🌨 ❄️ 🌨">Snowy</option>
</select>
</label>
</div>
<div class="newSky"></div>
<br>
</section>
<section id="city_section">
<h2>City Name</h2>
<div>
<label for="city_input"> Enter your city!</label>
<br>
<br>
<input type="text" id="inputCity" name="Thing"><br><br>
</div>
<div>
<button id="reset">
<span>reset</span>
</button>
</div>
<br>
</section>
<section id="weather_garden_section">
<h2>🌈 Weather Garden 🌤</h2>
<p class="weather_emojis" id="skyChange">☀️ 🪂 ☀️ 🦜 ☄️ ☀️ 🦜 ☀️ ☁️</p>
<br>
<br>
<br>
<p class="weather_emojis">🏡 🏘️ 🐕 🏡 ⛺🧚🏽 🛖 🐈 ⛺</p>
<p class="weather_emojis" id="groundChange">🌱 🐾 🌱 🌷 🌱 🐝 🌱 🍃 🌱</p>
</section>
</section>
</main>
<script src="./node_modules/axios/dist/axios.min.js"></script>
<script src="./src/index.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"dependencies": {
"axios": "^1.2.1"
"axios": "^1.4.0"
}
}
187 changes: 187 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
state = {
temp: 50,
city: "Atlanta",
latitude: 0,
longitude: 0
};
Comment on lines +1 to +6

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job setting up state!


PATH = "http://127.0.0.1:5000/weather"
const findWeather = () => {

axios.get(PATH,
{
params: {
"lat": state.latitude,
"lon": state.longitude
}
})
.then((response) => {
let tempK = response.data.main.temp
state.temp = Math.round(((tempK-273.15)*1.8) + 32)
console.log(response.data.main.temp)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to remove debugging log statements

const tempNumContainer = document.querySelector("#currentTemp")
tempNumContainer.textContent = `${state.temp}°`;
colorChanging();
changeGround();
Comment on lines +24 to +25

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smart approach!

})
.catch((error) => {
console.log('error in findWeather for', state.city);
throw error;
})
}

WeatherPATH = "http://127.0.0.1:5000/location"
const findLatitudeAndLongitude = () => {

axios.get(WeatherPATH,
{
params: {
"q": state.city
},
})
.then((response) => {
state.latitude = response.data[0].lat;
state.longitude = response.data[0].lon;
Comment on lines +43 to +44

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏾

console.log('success', state.city, state.latitude, state.longitude);
findWeather();
colorChanging();
changeGround();
})
.catch((error) => {
console.log('error in findLatitudeAndLongitude for', state.city);
throw error;
})
}


const changeGround = function () {
if (state.temp <= 39) {
document.querySelector("#currentTemp")
const tempGroundContainer = document.querySelector("#groundChange")
tempGroundContainer.textContent = `❄️🌲❄️☃️❄️🏂❄️🌲❄️`
}

else if (state.temp >= 40 && state.temp <= 59) {
document.querySelector("#currentTemp")
const tempGroundContainer = document.querySelector("#groundChange")
tempGroundContainer.textContent = `🌬️ 🍂 🦃 🌾 🍂 🌰 🐿️ 🌾 🍂`
}

else if (state.temp >= 60 && state.temp <= 69){
Comment on lines +57 to +70

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great function naming, this looks really clean 💯 Your conditonal comprehension is very strong

document.querySelector("#currentTemp")
const tempGroundContainer = document.querySelector("#groundChange")
tempGroundContainer.textContent = `🌱 🐾 🌱 🌷 🌱 🐝 🌱 🍃 🌱`

}
else if (state.temp >= 70 && state.temp <= 89){
document.querySelector("#currentTemp")
const tempGroundContainer = document.querySelector("#groundChange")
tempGroundContainer.textContent = `🌺 🏖️ 🌴 🌺 🧉 🐠 🌺 🦋 🍔`

}
else if (state.temp >= 90){
document.querySelector("#currentTemp")
const tempGroundContainer = document.querySelector("#groundChange")
tempGroundContainer.textContent = `🔥 😈 💦 🔥 🌭 🥵 ❤️‍🔥 🧑🏼‍🚒 🦂`
}
}

const colorChanging = function () {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

if (state.temp <= 39) {
document.querySelector("#currentTemp").className = 'purple'
console.log(document.querySelector("#currentTemp").className)
}

else if (state.temp >= 40 && state.temp <= 59) {
document.querySelector("#currentTemp").className = 'green'
console.log(document.querySelector("#currentTemp").className)

}

else if (state.temp >= 60 && state.temp <= 69){
document.querySelector("#currentTemp").className = 'blue'
console.log(document.querySelector("#currentTemp").className)

}
else if (state.temp >= 70 && state.temp <= 89){
document.querySelector("#currentTemp").className = 'orange'
console.log(document.querySelector("#currentTemp").className)

}
else if (state.temp >= 90){
document.querySelector("#currentTemp").className = 'red'
console.log(document.querySelector("#currentTemp").className)

}
}

const displayCity = function(){
const inputNow = document.querySelector("input").value
console.log(inputNow)
state.city = inputNow
const tempCityContainer = document.querySelector('#city')
tempCityContainer.textContent = `For the lovely city of ${state.city}`
}

const incrementTemp = function() {
state.temp +=1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer state.temp += 1 here for reada😄bility

const tempNumContainer = document.querySelector("#currentTemp")
tempNumContainer.textContent = `${state.temp}°`;
colorChanging();
changeGround();
};

const decrementTemp = function() {
state.temp -=1

@ameerrah9 ameerrah9 Jun 26, 2023

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer state.temp -= 1 here for readability

const tempNumContainer = document.querySelector("#currentTemp")
tempNumContainer.textContent = `${state.temp}°`;
colorChanging();
changeGround();
};

const getRealTimeTemp = function (){
findLatitudeAndLongitude();
colorChanging();
changeGround();
Comment on lines +142 to +145

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice way to reuse these functions!

}

const resetCityName = function () {
state.city = "Atlanta";
const resetNowContainer = document.querySelector("#city");
console.log(resetNowContainer);
resetNowContainer.textContent = `For the lovely city of ${state.city}`;
const userInput = document.querySelector("input");
userInput.value = '';
colorChanging();
}

const newSKySelect = function () {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer newSkySelect here

const skyOption = document.querySelector(".sky_selecting").value
const newSkyContainer = document.querySelector("#skyChange")
newSkyContainer.textContent = skyOption
}

const registerEventHandlers = () => {
const upArrow = document.querySelector("#up_arrow");
upArrow.addEventListener('click', incrementTemp);

const DownArrow = document.querySelector("#down_arrow");
DownArrow.addEventListener('click', decrementTemp);

const cityInput = document.getElementById("inputCity")
cityInput.addEventListener('input', displayCity)

const calculateTemp = document.querySelector("#getTemp");
calculateTemp.addEventListener('click', findLatitudeAndLongitude)

const resetNowButton = document.querySelector("#reset");
resetNowButton.addEventListener('click', resetCityName)

const newSkyDropDown = document
newSkyDropDown.addEventListener("change", newSKySelect)

// const colorChangeEffect = document.querySelector("currentTemp")
// colorChangeEffect.addEventListener("click", colorChangeEffect)
};

document.addEventListener("DOMContentLoaded", registerEventHandlers);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳🎉

81 changes: 81 additions & 0 deletions styles/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
html{
background-color: rgb(99, 163, 208);
color: white;
font-family: Arial, Helvetica, sans-serif;
text-align: center;
word-wrap: break-word;
}

.content_container{
width: 100%;
height: 100%;
display: grid;
grid-template-columns: 1/3 1/3 1/3;
grid-template-rows: 200 500;
row-gap: 1em;
column-gap: 1em;
}

#temperature_section{
background-color: white;
border-radius: 25px;
color: black;
grid-column-start: 1;
grid-column-end: 2;
grid-row-start: 1;
grid-row-end: 2;
}

#sky_section{
background-color: white;
border-radius: 25px;
color: black;
grid-column-start: 2;
grid-column-end: 3;
grid-row-start: 1;
grid-row-end: 2;
}

#city_section{
background-color: white;
border-radius: 25px;
color: black;
grid-column-start: 3;
grid-column-end: 4;
grid-row-start: 1;
grid-row-end: 2;
}

#weather_garden_section{
background-color: white;
border-radius: 25px;
color: black;
grid-column-start: 1;
grid-column-end: 4;
grid-row-start: 2;
grid-row-end: 3;
}

.weather_emojis {
font-size: xx-large;
}

.red {
color: red
}

.orange {
color: orange
}

.blue {
color: rgb(123, 154, 239)
}

.green {
color: green
}

.purple {
color: rgb(5, 34, 128)
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ asynckit@^0.4.0:
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==

axios@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.2.1.tgz#44cf04a3c9f0c2252ebd85975361c026cb9f864a"
integrity sha512-I88cFiGu9ryt/tfVEi4kX2SITsvDddTajXTOFmt2uK1ZVA8LytjtdeyefdQWEf5PU8w+4SSJDoYnggflB5tW4A==
axios@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.4.0.tgz#38a7bf1224cd308de271146038b551d725f0be1f"
integrity sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==
dependencies:
follow-redirects "^1.15.0"
form-data "^4.0.0"
Expand Down