Skip to content

Sandra Caballero -Spruce#76

Open
Sanderspat wants to merge 1 commit intoAda-C16:mainfrom
Sanderspat:main
Open

Sandra Caballero -Spruce#76
Sanderspat wants to merge 1 commit intoAda-C16:mainfrom
Sanderspat:main

Conversation

@Sanderspat
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@anselrognlie anselrognlie left a comment

Choose a reason for hiding this comment

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

Overall, nice job on your site. Your layout looks really clean (I especially like the gradient background). Your ground and color changing works great! Sky handling would be very similar to how the ground is selected, but we would use a 'select' tag and the 'change' event. The city name would be a little different (using the input event instead), but it would also be similar in that we would read the value from the text input, and then update an element in the DOM with that value.

Comment thread index.html
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./style.css"/>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Prefer to put the stylesheets in the styles folder.

Comment thread index.html
<div id="floor-container">🌸🌿🌼__🌷🌻🌿_☘️🌱_🌻🌷</div>
<button type="button" id="up-button">Up</button>
<button type="button" id="down-button">Down</button>
<span type="number" id="temperature" value="75" class="orange">70</span>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The type and value attributes here only apply to an input tag. span doesn't know what to do with them.

Comment thread style.css

body {
height: 100vh;
display: flex;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice flex layout!

Comment thread style.css
color:antiquewhite;
}

.location, .temperature {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice way to apply a set of style rules to more than one class!

Comment thread style.css
justify-content: space-around;
align-items: center;
}
.orange{
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Class names like these are fine, but in general, try to use class names that convey a sense of the element's role rather than being directly related to its appearance. Here, it's not too big of an issue, since they really don't have much of any other role.

Comment thread src/index.js
@@ -0,0 +1,40 @@
document.getElementById("up-button").onclick = function(){
var tempInt = parseInt(document.getElementById("temperature").innerHTML);
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 introducing a state variable outside the functions to hold the temperature, and only writing it to the display element, rather than using the text in the display element as the storage and needing to parse it back.

Comment thread src/index.js
@@ -0,0 +1,40 @@
document.getElementById("up-button").onclick = function(){
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Prefer using addEventListener to register event handlers on an element rather than assigning to the on* event attributes.

document.getElementById("up-button").addEventListener("click", function(){
  ...
});

Comment thread src/index.js
Comment on lines +9 to +12
var tempInt = parseInt(document.getElementById("temperature").innerHTML);
tempInt--;
document.getElementById("temperature").innerHTML = tempInt;
tempColor(tempInt);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Notice how similar the body of this function is to the event handler registers for increasing the temperature. Consider making a helper function to hold the parts in common. Just keep the parts that differ in these functions, and make use of the new helper for the things they do that are the same.

Comment thread src/index.js
} else {
color = 'teal';
floor = '🌲🌲⛄️🌲⛄️🍂🌲🍁🌲🌲⛄️🍂🌲';
}
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 the above logic and how similar all the branches are. We look for whether the temperature is within a range, and pick a color and landscape accordingly. What if we had a list of records that we could iterate through to find the values. We could set up something like

  const tempRecords = [
    { lowerBound: 80, color: "red", landscape: "🌵__🐍_🦂_🌵🌵__🐍_🏜_🦂"},
    { lowerBound: 70, color: "other color", landscape: "other landscape"},
    ...
  ];

For the else case, we might set the lowerBound to a very low value, or to null and write a special case to check it. But for everything else, we could simply iterate through the list and find the first record that has a lower bound lower than our temperature, then use it as the source of picking the color and landscape!

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