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

Panther - Ryan Thomas #95

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

Panther - Ryan Thomas #95

wants to merge 7 commits into from

Conversation

ryanrt9
Copy link

@ryanrt9 ryanrt9 commented Dec 20, 2022

No description provided.

Comment on lines +12 to +36
<h1>Today's Weather</h1>
<span>Today in the city of
<span id="headerCityName" class="header__city-name">
"insert city"
</span>
</span>
</span>
</header>
<section class="temperature__section">
<h2>Actual Temperature</h2>
<div class="temperature__content">
</div>
<span id="actualValue" class="orange">65°</span>
</div>
</section>
<section class="sky__section">
<h2>Desired Sky</h2>
<select id="skySelect">
<option value="sunny">Sunny</option>
<option value="cloudy">Cloudy</option>
<option value="rainy">Rainy</option>
<option value="snowy">Snowy</option>
</select>
</section>
<section class="garden__section">

Choose a reason for hiding this comment

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

Markup looks great!

Comment on lines +37 to +42
<h1> Sky & Garden </h1>
<div id="gardenContent" class="garden__content sunny">
<span id="desiredSky">☀️🌞☀️🌞☀️🌞☀️🌞☀️🌞☀️🌞☀️🌞</span>
<span id="landscape">🌼🌸🌸🌸🌼🌸🌸🌸🌼🌸🌸🌸🌼🌸🌸🌸🌼</span>
</div>
</h2>

Choose a reason for hiding this comment

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

Rather than hard-coding a value for UI elements (which just happens to match the initial value backing the control), I like to leave the initial markup blank, and update the UI on first load from the initial backing values in the JS code. So like here, leave off the emojis, then when the document loads, update the UI in the JS to show the initial sky and landscape value. This would protect us from changing the default starting JS value, but having it be out of sync with what the UI is showing.

I would tend to do this for any of the configurable elements (temperature, ground, sky, city).

<span id="increaseTempControl">⬆️</span>
<span id="decreaseTempControl">⬇️</span>
</div>
<span id="tempValue">70°</span>

Choose a reason for hiding this comment

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

Rather than hard-coding a value for UI elements (which just happens to match the initial value backing the control), I like to leave the initial markup blank, and update the UI on first load from the initial backing values in the JS code. So like here, leave off the 70, then when the document loads, update the UI in the JS to show the initial temperature value. This would protect us from changing the default starting JS value, but having it be out of sync with what the UI is showing.

I would tend to do this for any of the configurable elements (temperature, ground, sky, city).


const state = {
temp : 70,
sky : document.getElementById('skySelect'),

Choose a reason for hiding this comment

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

Instead of having a hard coded default sky state, how might you refactor this so the logic is more data driven? The sky should really be displayed based on the call to the api

const state = {
temp : 70,
sky : document.getElementById('skySelect'),
location : '',

Choose a reason for hiding this comment

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

The few values in your default state could be the lat, long, temp and city name

// TEMP CHANGES
const increaseTemp = () => {
state.temp ++;
tempValue.innerHTML = state.temp + "°" ;

Choose a reason for hiding this comment

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

Instead of using the + symbol here you could use concatenation ${state.temp}°

Comment on lines +132 to +137
.then((response) => {
state.lon = response.data[0].lon
state.lat = response.data[0].lat
})
.then(()=> {
getWeather();

Choose a reason for hiding this comment

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

You can combine these two .thens into one like so:

    .then((response) => {
      state.lat = response.data[0].lat;
      state.long = response.data[0].lon;
      getWeather();
    })

Comment on lines +157 to +158
tempValue.innerHTML = state.temp + "°" ;
actualTempValue.innerHTML = state.temp + "°" ;

Choose a reason for hiding this comment

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

We should separate our concerns here by having another function handle updating our UI

Comment on lines +101 to +121
const landscapeChange = () =>{
if (state.temp >= 80){
desiredLandscape.textContent = "🌵__🐍_🦂_🌵🌵__🐍_🏜_🦂"
bgColor.style.backgroundColor = '#E24E1B'
}
else if (state.temp >= 70 ){
desiredLandscape.textContent = "🌸🌿🌼__🌷🌻🌿_🌱_🌻🌷"
bgColor.style.backgroundColor = '#E5B25D'
}
else if (state.temp >= 60 ){
desiredLandscape.textContent = "🌾🌾_🍃_🪨__🛤_🌾🌾🌾_🍃"
bgColor.style.backgroundColor = '#D0CFEC'
}
else if (state.temp >= 50 ){
desiredLandscape.textContent = "🌲🌲⛄️🌲⛄️🍂🌲🍁🌲🌲⛄️🍂🌲"
bgColor.style.backgroundColor = "#875C74"
}
else if (state.temp <= 40 ){
bgColor.style.backgroundColor = "#1B4079"
}
}
Copy link

@ameerrah9 ameerrah9 Jan 11, 2023

Choose a reason for hiding this comment

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

There’s an issue with wave 02 (temperature), the requirements specify that the temperature ranges should change the text color or the background of the temperature & the landscape depending on what temperature it is. Currently your code is updating the background color of the entire page.

Comment on lines +52 to +55
const changeCityName = () => {
headerCityName.innerHTML = cityNameInput.value

}

Choose a reason for hiding this comment

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

There's an issue with wave 03 (naming the city), the requirements specify that there should be an element that displays a city name & a text input element that allows the user to change the city name. The city name must also be updated every time there's a change to the text input element. Currently your code is not displaying the city name when you reset the city.

Comment on lines +63 to +67
const resetLocation = () => {
state.location = '';
cityNameInput.value = state.location;
changeCityName();
}

Choose a reason for hiding this comment

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

When you reset the city it should be updated to a selected city instead of an empty string like so:

  cityNameInput.value = 'Seattle';

Copy link

@ameerrah9 ameerrah9 left a comment

Choose a reason for hiding this comment

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

Great work on this project Ryan! The code you wrote for wave 2 & 3 is really close, I've put in a suggested solution, but I didn't have time to test it so it may need some adjustments. The code in this project is really clean and easy to read. This project is yellow 🟡

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