-
Notifications
You must be signed in to change notification settings - Fork 82
Amethyst Abby Goodman & Winslow Edwards #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
eefca8a
4fecda9
6d5dfef
9183b39
00ff4a1
8e23a18
4a7d996
b65a22c
853b550
f492647
0e07293
31ea1cc
0af5373
8293aad
6dfa35d
66f4354
290d054
8fe1887
1624994
0785f57
cebc963
9e31c87
108697b
0288140
a6f80e3
82cd795
2c533f4
4e3cd7c
ea0bafb
55f6e5a
838e406
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "dependencies": { | ||
| "axios": "^1.2.1" | ||
| "axios": "^1.4.0" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,187 @@ | ||
| state = { | ||
| temp: 50, | ||
| city: "Atlanta", | ||
| latitude: 0, | ||
| longitude: 0 | ||
| }; | ||
|
|
||
| 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) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 () { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer |
||
| const tempNumContainer = document.querySelector("#currentTemp") | ||
| tempNumContainer.textContent = `${state.temp}°`; | ||
| colorChanging(); | ||
| changeGround(); | ||
| }; | ||
|
|
||
| const decrementTemp = function() { | ||
| state.temp -=1 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer |
||
| const tempNumContainer = document.querySelector("#currentTemp") | ||
| tempNumContainer.textContent = `${state.temp}°`; | ||
| colorChanging(); | ||
| changeGround(); | ||
| }; | ||
|
|
||
| const getRealTimeTemp = function (){ | ||
| findLatitudeAndLongitude(); | ||
| colorChanging(); | ||
| changeGround(); | ||
|
Comment on lines
+142
to
+145
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 () { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer |
||
| 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); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🥳🎉 |
||
| 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) | ||
| } |
There was a problem hiding this comment.
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!