-
Notifications
You must be signed in to change notification settings - Fork 100
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
Snow Leopards - Alaere & Anika #86
base: main
Are you sure you want to change the base?
Conversation
buttons still work.
…e on page. Will fix later
…ealtime temp still not working
…oves buttons and removes unused code
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.
Nice work on weather report, Alaere and Anika! Let me know if you have any questions.
} | ||
}); | ||
|
||
const weatherEmojisandColor = () => { |
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.
Consider renaming this method to use a verb to indicate that this method does something, maybe something like setWeatherEmojisaAndColor
const state = { | ||
city: 'Portland, OR', | ||
temperature: 72, | ||
latitude: 45.5152, | ||
longitude: 122.6784, | ||
}; |
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.
👍
document.getElementById("sky").addEventListener('change', (event) => { | ||
const bgValue = event.target.options[event.target.selectedIndex].value; | ||
if( bgValue == 'sunny' ) { | ||
document.body.style.backgroundImage = "url(/ada-project-docs/assets/sunshine.png)"; | ||
} else if( bgValue == "cloudy" ){ | ||
document.body.style.backgroundImage = "url(/ada-project-docs/assets/cloudy.png)"; | ||
} else if( bgValue == "rainy" ){ | ||
document.body.style.backgroundImage = "url(/ada-project-docs/assets/rain.png)"; | ||
} else if( bgValue == "snowy" ){ | ||
document.body.style.backgroundImage = "url(/ada-project-docs/assets/snow.png)"; | ||
} | ||
}); |
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.
Could this have been wrapped inside a function and the function been registered on an event inside registerEventHandlers
like you do with your other event handler methods?
For example, this could be put in a method called like updateBackground
and then in registerEventHandlers you could have:
const background = document.getElementById("sky");
background.addEventListener('change', updateBackground);
Doing so would ensure that your format is uniform throughout the project and makes the code a bit more readable
const weatherEmojisandColor = () => { | ||
let temp = state.temperature; | ||
let color; | ||
if (temp <= 49) { |
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.
How could you refactor this method so that it's data driven instead of using several if/else if statements (maybe iterate over a data structure) ?
} | ||
let tempTag = document.getElementById("tempTag"); | ||
|
||
tempTag.textContent = String(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.
another way to create a string, without using the String constructor is to just use a template string
`${state.temp}`
}) | ||
.catch ((error) => { | ||
console.log("error no temperature found"); | ||
})}; |
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.
Nice work getting practice using async/await and promise with then and catch. You might see a large code base with a mix because different people are working on different parts, but usually when the project is small and we can help it we'll want to keep to one style.
Did you prefer one style over the other?
nowShowingTemp(); | ||
}; | ||
|
||
const nowShowingTemp = () => { |
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.
Consider renaming this method to use a verb, maybe something like updateNowShowingTemp
No description provided.