Skip to content
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

C22- Sphinx - Weixi He, Nikki Vaughan / Phoenix - Ajar Duishembieva #3

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

vnikki13
Copy link

@vnikki13 vnikki13 commented Dec 4, 2024

No description provided.

Copy link

@kelsey-steven-ada kelsey-steven-ada left a comment

Choose a reason for hiding this comment

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

Nice work folks, let me know if you have any question on the feedback! =]

temp.innerText = (value - 1);
}

const changeSky = () => {

Choose a reason for hiding this comment

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

The Weather Garden's sky will only appear once a user selects an option other than "Sunny" for the first time, even though it looks like a default of "Sunny" is selected. Where could we call this function so the sky is displayed along with the garden when it is updated?

Comment on lines +17 to +18
<span>For the lovely city of
<span id="headerCityName" class="header__city-name"></span></span>

Choose a reason for hiding this comment

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

I suggest using something like a h2 or a p element around the inner span here.

span is much like div where it does not inherently have semantic meaning, so we want to reserve it for places where we need an inline element to wrap something for styling-purposes only. More info: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span

<section class="temperature__section" id="temperatureSection">
<h2>Temperature</h2>
<div class="temperature__content">
<div class="temperature__controls">

Choose a reason for hiding this comment

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

There are some divs across the HTML like this one that I might suggest replacing with section or article elements because it looks they are meaningfully sectioning content. That way we only leave divs where they are wrapping content for styling purposes.

I suggest taking a look at each div across the file and asking: if it is doing more work than styling, is there any semantic element that could be a better fit?

const changeColor = (temperature) =>{
const element = document.getElementById("temperatureSection");
if(temperature >= 80){
element.classList.forEach((className) => COLORS.includes(className) ? element.classList.remove(className) : className )

Choose a reason for hiding this comment

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

Since this line is repeated without change in each if/else block, we can remove it from these blocks and perform the operation just once before the if/else chain starts.

Comment on lines +134 to +135
const defaultCity = "Seattle";
cityTitle.textContent = defaultCity;

Choose a reason for hiding this comment

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

Since we already set a default city, what could it look like to set a default temperature so that a user would have a weather and sky to look at and easily navigate between when the page loads up?

Comment on lines +35 to +36
changeColor(value)
temp.innerText = (value + 1);

Choose a reason for hiding this comment

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

increaseTemp and decreaseTemp might not be operating exactly as you expect since the color change function gets called before we actually change the temperature value.

When you manually increase the temperature starting at 68, I have to go to 71 before I see the next set of garden emojis appear. The same happens when I decrease from 71, it doesn't change back to the previous garden until the temperature reads 68.

Comment on lines +33 to +44
const increaseTemp = () =>{
value = parseInt(temp.textContent) || 0;
changeColor(value)
temp.innerText = (value + 1);

}

const decreaseTemp = () => {
value = parseInt(temp.textContent) || 0;
changeColor(value)
temp.innerText = (value - 1);
}

Choose a reason for hiding this comment

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

Since increaseTemp and decreaseTemp are very similar, another approach we could take is to combine them into 1 function:

const setTemp = (changeInTemp) => {
  value = parseInt(temp.textContent) || 0;
  changeColor(value)
  temp.innerText += changeInTemp;
};

Then where we register the handlers, we could call our new function with a parameter by doing so inside an anonymous function:

  increment.addEventListener('click', () => { setTemp(1) });
  decrement.addEventListener('click', () => { setTemp(-1) });

axios
.get('http://127.0.0.1:5000/location', {params: {q: cityName}})
.then((response) => {
console.log(

Choose a reason for hiding this comment

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

We should remove console.log statements from our Javascript before submission just like with print statements in our Python code.

Comment on lines +20 to +29
else if(temperature >= 50 && temperature <=59){
element.classList.forEach((className) => COLORS.includes(className) ? element.classList.remove(className) : className )
element.classList.add('green');
landscape.textContent = '🌲🌲⛄️🌲⛄️🍂🌲🍁🌲🌲⛄️🍂🌲';
}
else {
element.classList.forEach((className) => COLORS.includes(className) ? element.classList.remove(className) : className )
element.classList.add('teal');
landscape.textContent = '🌲🌲⛄️🌲⛄️🍂🌲🍁🌲🌲⛄️🍂🌲';
}

Choose a reason for hiding this comment

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

When we have large if-statements like this where each if-block performs the same operations with slightly different values, it can be worth making a helper function that handles the updates to reduce places we're repeating code and could accumulate small typos. With the helper function, each of the ifs here would call that function passing the desired parameters rather than setting attributes themselves.

display: flex;
flex-direction: row;
justify-content: space-around;
/* justify-content: center; */

Choose a reason for hiding this comment

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

Commented out code should be removed before opening PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants