Skip to content

Tigers - Mica and Misha#83

Open
mc-dev99 wants to merge 25 commits intoAda-C18:mainfrom
mc-dev99:main
Open

Tigers - Mica and Misha#83
mc-dev99 wants to merge 25 commits intoAda-C18:mainfrom
mc-dev99:main

Conversation

@mc-dev99
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@spitsfire spitsfire left a comment

Choose a reason for hiding this comment

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

Great job, Mica and Misha! So glad you tried out some more CSS grid styling! One thing I noticed is your class names, so I gave a little feedback there. Overall, you organized your event handlers well!

Comment thread index.html
Comment on lines +11 to +15
<header class="titleBlock">
<h1 id="siteTitle">The Weather Station</h1>
</header>
<span class="banner" id="skyBanner"></span>
<section class="cityNameBlock">
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider refactoring your class names so that they are lowercase and hyphenated between words

<h1 id="site-title">The Weather Station</h1>

Comment thread src/index.js
Comment on lines +62 to +69
const cityName = document.querySelector('#cityName');
const inputContainer = document.querySelector('#inputCityName');
state.city = inputContainer.value;
cityName.textContent = state.city;
};

const resetCityName = (event) => {
const cityName = document.querySelector('#cityName');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks like we are repeating code on lines 62 and 69! Maybe we can create global variables that will hold elements like this that will be used more than once

Comment thread src/index.js
Comment on lines +78 to +102
axios
.get(`http://localhost:5000/location?q=${state.city}`)
.then((response) => {
state.latitude = response.data[0].lat;
state.longitude = response.data[0].lon;
console.log(response.data);
axios
.get(
`http://localhost:5000/weather?lat=${state.latitude}&lon=${state.longitude}`
)
.then((response) => {
const temperatureKelvin = response.data.main.temp;
state.Temperature = ((temperatureKelvin - 273.15) * 9) / 5 + 32;
tempContainer.textContent = `${Math.round(state.Temperature)}`;
tempRange();
console.log(response.data);
})
.catch((error) => {
console.log('OpenWeather GET request error');
});
})
.catch((error) => {
console.log('LocationIQ GET request error');
});
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

good indentation! makes the promises easier to read 👍

Comment thread src/index.js
Comment on lines +28 to +44
if (state.Temperature >= 80) {
tempContainer.style.color = 'red';
landscapeContainer.textContent = '🌵__🐍_🦂_🌵🌵__🐍_🏜_🦂';
} else if (state.Temperature <= 79 && state.Temperature >= 70) {
tempContainer.style.color = 'orange';
landscapeContainer.textContent = '🌸🌿🌼__🌷🌻🌿_☘️🌱_🌻🌷';
} else if (state.Temperature <= 69 && state.Temperature >= 60) {
tempContainer.style.color = 'yellow';
landscapeContainer.textContent = '🌾🌾_🍃_🪨__🛤_🌾🌾🌾_🍃';
} else if (state.Temperature <= 59 && state.Temperature >= 50) {
tempContainer.style.color = 'green';
landscapeContainer.textContent = '🌲🌲⛄️🌲⛄️🍂🌲🍁🌲🌲⛄️🍂🌲';
} else if (state.Temperature <= 49) {
tempContainer.style.color = 'teal';
landscapeContainer.textContent = '🌲🌲⛄️🌲⛄️🍂🌲🍁🌲🌲⛄️🍂🌲';
}
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How might you refactor this so the logic is more data driven? Here you have several if/else if statements. What if you had an object with the keys as the temperature and the values as the landscape and temperature corresponding display? Then you could iterate over the object to set state!

It could look something like this:

 const tempColors = [
   [49, 'blue'],
   [59, 'green'],
   [69, 'gold'],
   [79, 'orange'],
   [null, 'red'],
 ];
 
 const getColorForTemp = (temp) => {
   for (const [boundaryTemp, color] of tempColors) {
     if (boundaryTemp === null || temp <= boundaryTemp) {
       return color;
     }
   }
 };

Comment thread styles/index.css
@@ -0,0 +1,98 @@
body {
display: grid;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ooo nice job using css grid! 👍

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.

3 participants