Skip to content

Kunzite - Airis W. & Doris L.#48

Open
dorl9039 wants to merge 27 commits intoAda-C19:mainfrom
dorl9039:main
Open

Kunzite - Airis W. & Doris L.#48
dorl9039 wants to merge 27 commits intoAda-C19:mainfrom
dorl9039:main

Conversation

@dorl9039
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.

Heck yeah, Airis and Doris! Good job using a build with your deployment!

Some things to consider:

  • When assigning variables, don't forget your semicolon, even if the value is a function! Same when you call a function, too! It needs a semicolon at the end.

<div id="landscape"></div>
</div>
</section>
<!-- <script src="./node_modules/axios/dist/axios.min.js"></script> -->

Choose a reason for hiding this comment

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

Looks like you used a build in order to import axios and other dependencies instead of relying on a JavaScript file! Great job!

Since we aren't using this anymore, let's get rid of it

Suggested change
<!-- <script src="./node_modules/axios/dist/axios.min.js"></script> -->

@@ -0,0 +1,170 @@
"use strict";
import 'regenerator-runtime/runtime';

Choose a reason for hiding this comment

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

Hm, where do we use this? Was this imported accidentally?

gardenContent: null,
};

const loadControls = () => {

Choose a reason for hiding this comment

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

Interesting approach! Very creative way to retrieve your state values all at once!

}
}
}
loadControls()

Choose a reason for hiding this comment

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

This works! I suggest calling it inside our registerEventHandler function, so we know that everything has been loaded before we grab values from the DOM.

Suggested change
loadControls()
loadControls();

Comment on lines +29 to +66
const changeTempColor = (temp) => {
let color;
let backgroundColor;
if (temp >= 80) {
color = 'red';
backgroundColor = "#a75051";
} else if (temp >= 70 && temp <= 79) {
color = 'orange';
backgroundColor = "#d3834d";
} else if (temp >= 60 && temp <= 69) {
color = 'yellow';
backgroundColor = "#c8a669";
} else if (temp >= 50 && temp <= 59) {
color = 'green';
backgroundColor = "#528478";
} else if (temp < 50) {
color = 'teal';
backgroundColor = "#4288c2";
}
state.tempValue.setAttribute('class', color);
document.body.style.background = backgroundColor;
cityNameReset.style.backgroundColor = backgroundColor;
currentTempButton.style.backgroundColor = backgroundColor;
}

const changeLandscape = (temp) => {
let landscapeImage;
if (temp >= 80) {
landscapeImage = '🌵__🐍_🦂_🌵🌵__🐍_🏜_🦂';
} else if (temp >= 70 && temp <= 79) {
landscapeImage = '🌸🌿🌼__🌷🌻🌿_☘️🌱_🌻🌷';
} else if (temp >= 60 && temp <=69) {
landscapeImage = '🌾🌾_🍃_🪨__🛤_🌾🌾🌾_🍃';
} else {
landscapeImage = '🌲🌲⛄️🌲⛄️🍂🌲🍁🌲🌲⛄️🍂🌲'
}
state.landscape.textContent = landscapeImage;
}

Choose a reason for hiding this comment

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

Another way to format these two methods (maybe combine them into one) would be to have an object that has temp values as keys, and then you could have values be a list. The list could hold background color and background image, like:

const tempDisplayObject = {
    80: ['red',  "🌵__🐍_🦂_🌵🌵__🐍_🏜_🦂"], 
    70: ['orange', "🌸🌿🌼__🌷🌻🌿_☘️🌱_🌻🌷"]
} 

When you have an object, you don't need to do if/else if/else if/ else which can introduce bugs and also adds complexity to the method. If you have an object, than you can iterate over the object and check the keys with state.temp and then get the correct values to set the color and landscape emojis.

Comment on lines +127 to +134
const updateTempByCity = () => {
getLocationWeather(state.cityNameInput.value)
.then(temp => {
state.tempValue.textContent = temp;
changeTempColor(temp);
changeLandscape(temp);
});
}

Choose a reason for hiding this comment

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

Great job separating out these promises into individual functions and chaining them!

Comment on lines +136 to +155
const changeSky = () => {
let skyGraphic;
let gardenContentColor = 'garden__content ';

if (state.skySelect.value === 'sunny') {
skyGraphic = "☁️ ☁️ ☁️ ☀️ ☁️ ☁️";
gardenContentColor += 'sunny'
} else if (state.skySelect.value === 'cloudy') {
skyGraphic = "☁️☁️ ☁️ ☁️☁️ ☁️ 🌤 ☁️ ☁️☁️";
gardenContentColor += 'cloudy';
} else if (state.skySelect.value === 'rainy') {
skyGraphic = "🌧🌈⛈🌧🌧💧⛈🌧🌦🌧💧🌧🌧";
gardenContentColor += 'rainy';
} else {
skyGraphic = "🌨❄️🌨🌨❄️❄️🌨❄️🌨❄️❄️🌨🌨";
gardenContentColor += 'snowy';
}
state.sky.textContent = skyGraphic
state.gardenContent.setAttribute('class', gardenContentColor)
}

Choose a reason for hiding this comment

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

Same as above! Let's turn this into an object, so we can cut down on all these if/else statements

state[element] = document.getElementById(String(element));
}
}
}

Choose a reason for hiding this comment

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

Suggested change
}
};

document.body.style.background = backgroundColor;
cityNameReset.style.backgroundColor = backgroundColor;
currentTempButton.style.backgroundColor = backgroundColor;
}

Choose a reason for hiding this comment

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

Suggested change
}
};

since this is an assignment on line 29, we give it a semicolon at the end of the expression

landscapeImage = '🌲🌲⛄️🌲⛄️🍂🌲🍁🌲🌲⛄️🍂🌲'
}
state.landscape.textContent = landscapeImage;
}

Choose a reason for hiding this comment

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

Suggested change
}
};

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.

4 participants