C24-Jesica & Xi #8
Conversation
… value instead of object for function
…eInput's value(avoid touch the object directly)
There was a problem hiding this comment.
Pull request overview
This pull request implements a weather report application with real-time temperature fetching and interactive UI components. The implementation appears to be a student project (C24-Jesica & Xi) that creates a weather-themed application with temperature controls, sky conditions, and city selection.
Key Changes:
- Implementation of weather report application with temperature display and controls
- Integration with weather API using Axios for real-time data
- Interactive UI with city name selection, sky conditions, and visual weather garden
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Added axios and dotenv dependencies with version issues |
| package-lock.json | Generated lockfile for new dependencies with incorrect versions |
| index.html | Added complete HTML structure for weather application UI |
| styles/index.css | Added comprehensive CSS styling for weather components |
| src/index.js | Implemented JavaScript functionality with minor naming issue |
| coworking_agreement.md | Completed team agreement with spelling errors and future dates |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ## Accessibility Needs | ||
| *What does each team member need access to in order to succeed and show up the best they can?* | ||
|
|
||
| Jesica: Clear commuincation and transperancy of where each team memeber is at via Slack or meeting up outside of classroom hours. Attend Office hours for extra help when stuck in a wave. |
There was a problem hiding this comment.
Spelling error: "transperancy" should be "transparency".
| Jesica: Clear commuincation and transperancy of where each team memeber is at via Slack or meeting up outside of classroom hours. Attend Office hours for extra help when stuck in a wave. | |
| Jesica: Clear commuincation and transparency of where each team memeber is at via Slack or meeting up outside of classroom hours. Attend Office hours for extra help when stuck in a wave. |
| ## Accessibility Needs | ||
| *What does each team member need access to in order to succeed and show up the best they can?* | ||
|
|
||
| Jesica: Clear commuincation and transperancy of where each team memeber is at via Slack or meeting up outside of classroom hours. Attend Office hours for extra help when stuck in a wave. |
There was a problem hiding this comment.
Spelling error: "memeber" should be "member".
| Jesica: Clear commuincation and transperancy of where each team memeber is at via Slack or meeting up outside of classroom hours. Attend Office hours for extra help when stuck in a wave. | |
| Jesica: Clear commuincation and transperancy of where each team member is at via Slack or meeting up outside of classroom hours. Attend Office hours for extra help when stuck in a wave. |
| ## Collaboration vs. Individual Work Expectations | ||
| *Clarify your collaboration expectations - does your group want to write code together all of the time? Or divide work to do independently, then come together to share accomplishments? What tools and technologies can help your collaboration?* | ||
|
|
||
| Coding together for the first 2 waves so we can both be on the same page. Once we have a throught plan we can split the work up wether thats splitting 1 wave or all the waves together. |
There was a problem hiding this comment.
Spelling error: "throught" should be "thought".
| ## Collaboration vs. Individual Work Expectations | ||
| *Clarify your collaboration expectations - does your group want to write code together all of the time? Or divide work to do independently, then come together to share accomplishments? What tools and technologies can help your collaboration?* | ||
|
|
||
| Coding together for the first 2 waves so we can both be on the same page. Once we have a throught plan we can split the work up wether thats splitting 1 wave or all the waves together. |
There was a problem hiding this comment.
Spelling error: "wether thats" should be "whether that's".
| ## Accessibility Needs | ||
| *What does each team member need access to in order to succeed and show up the best they can?* | ||
|
|
||
| Jesica: Clear commuincation and transperancy of where each team memeber is at via Slack or meeting up outside of classroom hours. Attend Office hours for extra help when stuck in a wave. |
There was a problem hiding this comment.
Spelling error: "commuincation" should be "communication".
|
|
||
| ## One Team Communication Skill to Improve | ||
| *What is a teamwork-related skill you want to work on?* | ||
| Jesica: I would like to work on explaining code better to make sure my partner understand where I cam coming from or how did i get to the solution. |
There was a problem hiding this comment.
Spelling error: "cam" should be "am".
| skyElement.textContent = getSkyDisplay(option); | ||
| }; | ||
|
|
||
| const skySelectDropDwon = () => { |
There was a problem hiding this comment.
Function name typo: "skySelectDropDwon" should be "skySelectDropDown" (missing "o" and incorrect capitalization).
| } | ||
|
|
||
| updateSkyDisplay(skySelectElement.value); | ||
| } |
There was a problem hiding this comment.
Avoid automated semicolon insertion (97% of all statements in the enclosing script have an explicit semicolon).
| @@ -0,0 +1,242 @@ | |||
| 'use strict'; | |||
There was a problem hiding this comment.
👍 Nice job remembering to add 'use strict'
| @@ -0,0 +1,242 @@ | |||
| 'use strict'; | |||
|
|
|||
| const BASE_URL = 'https://ada-weather-report-proxy-server.onrender.com'; | |||
There was a problem hiding this comment.
👌 Good work using a constant value to refer to the proxy-server URL.
| let tempElement = null; | ||
| let landscapeElement = null; | ||
| let skyElement = null; | ||
| let headerCityElement = null; | ||
| let cityNameInputElement = null; | ||
| let cityNameResetElement = null; | ||
| let increaseTempControlElement = null; | ||
| let decreaseTempControlElement = null; | ||
| let currentTempButtonElement = null; | ||
| let skySelectElement = null; | ||
| let gardenContent = null; |
There was a problem hiding this comment.
Would prefer that these variables that reference elements are stored in the state object instead of having a bunch of global variables that are declared using let that could be accidentally changed (which could introduce bugs).
You can see an example of how we did this in pick-me-up-pup here.
| const getElementBySelector = (selector) => { | ||
| const element = document.querySelector(selector); | ||
| if (element) { | ||
| return element; | ||
| } else { | ||
| return null; | ||
| } | ||
| }; |
There was a problem hiding this comment.
This helper function is unnecessary because it duplicates behavior that querySelector already has. Prefer to directly use querySelector without this helper.
Per the MDN docs "The Document method querySelector() returns the first Element within the document that matches the specified CSS selector, or group of CSS selectors. If no matches are found, null is returned."
| const addCounter = () => { | ||
| state.counter += 1; | ||
| displayCurrentTemp(); | ||
| }; | ||
|
|
||
| const subtractCounter = () => { | ||
| state.counter -= 1; | ||
| displayCurrentTemp(); | ||
| }; |
There was a problem hiding this comment.
The difference between these addCounter and subtractCounter are + and -. Can you think of a way to write this logic with just one function that increase or decrease the temperature without repeating logic.
| return '🌲🌲⛄️🌲⛄️🍂🌲🍁🌲🌲⛄️🍂🌲'; | ||
| }; | ||
|
|
||
| const changeCurrentTempColor = (temp) => { |
There was a problem hiding this comment.
This name could be a little more descriptive. When I read changeCurrentTempColor I make the assumption that this function changes the color of the temperature display (like 91 would be red). This function does 2 things though because it also updates the landscape.
A name like changeCurrentTempColorAndLandscape would be more descriptive.
| setTemperatureAndDisplay(temp); | ||
| } catch (err) { | ||
| console.error('Failed to fetch temperature:', err); | ||
| setTemperatureAndDisplay(DEFAULT_TEMPERATURE); |
There was a problem hiding this comment.
Nice job coming up with a default fallback plan for scenario where the call to get the current temp fails.
| if (option == 'Sunny') { | ||
| skyElement.textContent = '☁️ ☁️ ☁️ ☀️ ☁️ ☁️'; | ||
| gardenContent.style.backgroundColor = 'rgb(221, 255, 255)'; | ||
| } else if (option == 'Cloudy') { | ||
| skyElement.textContent = '☁️☁️ ☁️ ☁️☁️ ☁️ 🌤 ☁️ ☁️☁️'; | ||
| gardenContent.style.backgroundColor = 'lightgrey'; | ||
| } else if (option == 'Rainy') { | ||
| skyElement.textContent = '🌧🌈⛈🌧🌧💧⛈🌧🌦🌧💧🌧🌧'; | ||
| gardenContent.style.backgroundColor = 'lightblue'; | ||
| } else if (option == 'Snowy') { | ||
| skyElement.textContent = '🌨❄️🌨🌨❄️❄️🌨❄️🌨❄️❄️🌨🌨'; | ||
| gardenContent.style.backgroundColor = 'lightsteelblue'; | ||
| } |
There was a problem hiding this comment.
What if the adjectives that describe the weather like "Sunny", "Rainy", etc were keys in an object and the color and sky content were values?
If you had an object that held this data then you could refactor this implementation so you wouldn't need to chain many if-statements (which is brittle and difficult to maintain).
You could use option to get the corresponding sky and garden values:
let option = skySelectElement.value;
const sky_data = {
"Rainy": ['☁️ ☁️ ☁️ ☀️ ☁️ ☁️', 'rgb(221, 255, 255)'],
// rest of your data
};
skyElement.textContent = sky_data[option][0];
gardenContent.style.backgroundColor = sky_data[option][1];| displayCurrentTemp(); | ||
| }; | ||
|
|
||
| document.addEventListener('DOMContentLoaded', registerEventHandlers); |
There was a problem hiding this comment.
Nice job organizing your code! I like that you have a function that 'loads' all the elements, like you do in initializeElements and I like that you have a function that registers all the event handlers.
The function registerEventHandlers does more than just registering event handlers though because it also performs some initial logic that needs to happen when the page loads (initializeElements and displayCurrentTemp).
I'd prefer this initial set up logic to be in a separate helper function, maybe something like setUpUI. And also introduce a function like onLoaded that would call setUpUI and registerEventHandlers. You can see an example of how we do this here in pick-me-up-pup.
const setUpUI = () => {
// steps to carry out when the page has loaded
initializeElements();
displayCurrentTemp();
};
const onLoaded = () => {
setUpUI();
registerEventHandlers()
};
document.addEventListener('DOMContentLoaded', onLoaded);| if (cityNameInputElement) { | ||
| const initialCityName = getCityInputValue(); | ||
| // Set initial city name header | ||
| updateCityNameHeader(initialCityName); | ||
| cityNameInputElement.addEventListener('input', () => { | ||
| const cityName = getCityInputValue(); | ||
| updateCityNameHeader(cityName); | ||
| }); | ||
| } |
There was a problem hiding this comment.
I'd prefer this logic to be in a function so that you can pass a named function to addEventListener on line 229 (instead of passing an anonymous function like you currently do).
Having named functions that you can pass to addEventListener makes your code easier to understand and maintain.
No description provided.