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

Tigers - Mica and Misha #83

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

Tigers - Mica and Misha #83

wants to merge 25 commits into from

Conversation

mc-dev99
Copy link

No description provided.

Copy link

@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 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">

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 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');

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 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');
});
};

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 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 = '🌲🌲⛄️🌲⛄️🍂🌲🍁🌲🌲⛄️🍂🌲';
}
};

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;
     }
   }
 };

@@ -0,0 +1,98 @@
body {
display: grid;

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