-
Notifications
You must be signed in to change notification settings - Fork 88
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
Jamie Horvath C-17 Digital Sharks #87
base: main
Are you sure you want to change the base?
Conversation
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.
Fantastic work Jamie! Your project met all the requirements. And I loved your algorithm to generate the hex color as the temp changes definitely made up for it.
I didn't have much feedback to add as your code is very neat. Design-wise, it wasn't obvious that users could click on the city text to switch to 'Reset Location'. A hover effect or a separate button that clearly says "reset city" would have been helpful.
Other than that great work!
Grade: 🟢
lets do centered column flex elements | ||
reset button0<(city name) | ||
3 buttons stacked next to <(70 degrees) | ||
update the background gradient per temperature | ||
|
||
x An element that displays the temperature | ||
x A clickable element to increase temperature | ||
x A clickable element to decrease temperature | ||
x An element that displays a landscape | ||
x bottom gradient from blue to red | ||
|
||
Wave 3: | ||
|
||
x An element that displays the city name | ||
x? An element that contains an <input type="text"> element, used to rename the city | ||
|
||
Wave 4: | ||
|
||
x A clickable element to get the current temperature of the displayed city name | ||
|
||
Wave 5: | ||
top gradient yellow sun, grey cloud, blue rain, white snow | ||
? A <select> dropdown element to set the sky type | ||
? An element that displays a sky | ||
|
||
Wave 6: | ||
|
||
x A clickable element to reset the city name --> |
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.
These are great notes, however, the intended use of PRs is to share code that we'd like our team to also have. I highly recommend putting these type of notes in a local branch as you're working through some code.
const getTemp = () => { | ||
axios | ||
.get('http://localhost:5000/weather', { | ||
params: { | ||
lat: state.lat, | ||
lon: state.lon, | ||
}, | ||
}) | ||
.then((response) => { | ||
state.temp = parseInt( | ||
((response.data['current'].temp - 273) * 9) / 5 + 32 | ||
); | ||
state.weather = response.data['current']['weather'][0].main; | ||
console.log('success in finding weather!', state.temp, state.weather); | ||
tempChange(state.temp, true); | ||
}) | ||
.catch((error) => { | ||
console.log('error in weather'); | ||
}); | ||
return state.temp; | ||
}; |
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.
👍
const state = { | ||
location: '', | ||
temp: 70, | ||
weather: '', | ||
lat: 0, | ||
lon: 0, | ||
}; |
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.
👍
const toHex = (dec) => (dec < 16 ? '0' + dec.toString(16) : dec.toString(16)); | ||
const normalize = (newTemp) => (newTemp % 35) / 35; |
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.
LOVE this formula to generate the temp color!!!
} else { | ||
color = ['FF', '00', '00']; | ||
} | ||
return ['#', ...color].join(''); |
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.
Clever!
}; | ||
///////////////////////////////////////////// | ||
const getLocation = () => { | ||
print; |
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.
I don't think you need htis line.
console.log('success in finding location!', state.lat, state.lon); | ||
}) | ||
.catch((error) => { | ||
console.log('error in location'); |
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.
Good job in error handling and utilizing logs to confirm the behavior of your get
request. However, unless we're making a terminal program, we should keep console.logs
out of PRs.
const locationChange = () => { | ||
const currentLocation = document.querySelector('#location'); | ||
const locationButton = document.querySelector('#locationReset'); | ||
|
||
state.location = currentLocation.value; | ||
getLocation(); | ||
locationButton.textContent = state.location; | ||
currentLocation.value = ''; | ||
}; |
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.
👍
const clearLocation = () => { | ||
const locationButton = document.querySelector('#locationReset'); | ||
locationButton.textContent = 'Reset Location'; | ||
state.location = ''; | ||
state.lat = 0; | ||
state.lon = 0; | ||
}; |
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.
👍
const registerEventHandlers = () => { | ||
const upTempButton = document.querySelector('#up_temp'); | ||
upTempButton.addEventListener('click', (event) => tempChange(1, false)); | ||
const downTempButton = document.querySelector('#down_temp'); | ||
downTempButton.addEventListener('click', (event) => tempChange(-1, false)); | ||
const setTempButton = document.querySelector('#lookup_temp'); | ||
setTempButton.addEventListener('click', (event) => getTemp()); | ||
|
||
const updateLocation = document.querySelector('#location'); | ||
updateLocation.addEventListener('change', (event) => locationChange()); | ||
const updateWeather = document.querySelector('#weatherBox'); | ||
updateWeather.addEventListener('change', (event) => weatherChange()); | ||
|
||
const locationResetButton = document.querySelector('#locationReset'); | ||
locationResetButton.addEventListener('click', (event) => clearLocation()); | ||
}; | ||
|
||
document.addEventListener('DOMContentLoaded', registerEventHandlers); | ||
tempChange(0, false); |
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.
👍
No description provided.