-
Notifications
You must be signed in to change notification settings - Fork 78
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
gloria/scissors #71
base: main
Are you sure you want to change the base?
gloria/scissors #71
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
🌵__🐍_🦂_🌵🌵__🐍_🏜_🦂 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<Title>Weather Report</Title> | ||
<link rel="stylesheet" href="styles/index.css"> | ||
|
||
|
||
</head> | ||
<body> | ||
<div> | ||
<div id="header"> | ||
<h1>Weather Report</h1> | ||
<span>For the lovely city of </span> | ||
<h3 id="town-name">My Hometown</h3> | ||
</div> | ||
<div id="content"> | ||
<div id="temperature-card"> | ||
<h3 id="temperature-title">Temperature</h3> | ||
<br> | ||
<div id="up-arrow" onclick="increaseTemperature()">⬆️</div> | ||
<div id="decreaseTempArrow">⬇️</div> | ||
<div> | ||
<span class="orange-temp" id="temp-value">71</span> | ||
</div> | ||
|
||
|
||
</div> | ||
<div id="sky-card"> | ||
<h3>Sky</h3> | ||
<br> | ||
<select name="sky"> | ||
<option value="sunny">Sunny</option> | ||
<option value="cloudy">Cloudy</option> | ||
<option value="rainy">Rainy</option> | ||
<option value="snowy">Snowy</option> | ||
</select> | ||
</div> | ||
<div id="city-card"> | ||
<h3>City Name</h3> | ||
<br> | ||
<input type="text" value="My Hometown"> | ||
<button="resetButton">Reset</button> | ||
</div> | ||
<div id="garden-card"> | ||
<h3>Weather Garden</h3> | ||
<br> | ||
<div> | ||
<p id="sky-landscape">☁️ ☁️ ☁️ ☀️ ☁️ ☁️ </p> | ||
<br> | ||
<br> | ||
<br> | ||
<p id="ground-landscape">🌸🌿🌼__🌷🌻🌿_☘️🌱_🌻🌷</p> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
<script src="scripts/index.js" ></script> | ||
</body> | ||
</html> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
|
||
|
||
const tempToColor = (temp) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Notice that |
||
if (temp >= 80){ | ||
return "red-temp"; | ||
} else if (temp >= 70){ | ||
return "orange-temp"; | ||
} else if (temp >= 60){ | ||
return "yellow-temp"; | ||
} else if (temp >= 50){ | ||
return "green-temp"; | ||
} else { | ||
return "teal-temp"; | ||
} | ||
// ((temp>= 70) && (temp <= 79)) | ||
}; | ||
|
||
const tempToLandscape = (temp) => { | ||
if (temp >= 80){ | ||
return "🌵__🐍_🦂_🌵🌵__🐍_🏜_🦂" | ||
} else if (temp >= 70){ | ||
return "🌸🌿🌼__🌷🌻🌿_☘️🌱_🌻🌷" | ||
} else if (temp >= 60){ | ||
return "🌾🌾_🍃_🪨__🛤_🌾🌾🌾_🍃" | ||
} else { | ||
return "🌲🌲⛄️🌲⛄️🍂🌲🍁🌲🌲⛄️🍂🌲" | ||
} | ||
}; | ||
|
||
const skyToLandscape = (sky) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like how you encapsulated this logic in a function that returns the value that you need, and then you can invoke the function and use the return value in the event handler. |
||
if (sky == "sunny"){ | ||
return "☁️ ☁️ ☁️ ☀️ ☁️ ☁" | ||
} else if (sky == "cloudy"){ | ||
return "☁️☁️ ☁️ ☁️☁️ ☁️ 🌤 ☁️ ☁️☁️" | ||
} else if (sky == "rainy"){ | ||
return "🌧🌈⛈🌧🌧💧⛈🌧🌦🌧💧🌧🌧" | ||
} else if (sky == "snowy"){ | ||
return "🌨❄️🌨🌨❄️❄️🌨❄️🌨❄️❄️🌨🌨" | ||
} | ||
} | ||
|
||
const resetClickCount = ()=>{ | ||
StaticRange.clickCount = 0; | ||
const townnameContainer = document.getElementBy("town-name"); | ||
}; | ||
|
||
const setTempClass = (tag, className) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clever! An alternative to removing all the classes we don't need, and adding the class we do need is using this attribute |
||
tag.classList.remove("red-temp"); | ||
tag.classList.remove("orange-temp"); | ||
tag.classList.remove("yellow-temp"); | ||
tag.classList.remove("green-temp"); | ||
tag.classList.remove("teal-temp"); | ||
//remove all the classes | ||
tag.classList.add(className); | ||
}; | ||
|
||
const setGroundLandscape = (temp) => { | ||
let p = document.getElementById("ground-landscape"); | ||
let groundValue = tempToLandscape(temp); | ||
p.innerText = groundValue; | ||
}; | ||
|
||
|
||
const increaseTemperature = function(){ | ||
let span=document.getElementById("temp-value"); | ||
let value = parseInt(span.innerText); | ||
value +=1; //convert from string to int | ||
span.innerText = value; | ||
let className=tempToColor(value); | ||
setTempClass(span,className); | ||
setGroundLandscape(value); | ||
}; | ||
|
||
|
||
|
||
|
||
const decreaseTemp = () => { | ||
const span = document.querySelector("#temp-value"); | ||
let value = parseInt(span.textContent); | ||
value -=1; | ||
span.textContent = value; | ||
let className=tempToColor(value); | ||
setTempClass(span,className); | ||
setGroundLandscape(value); | ||
}; | ||
|
||
const changeSky = () => { | ||
|
||
let p = document.getElementById("sky-landscape"); | ||
let select = document.querySelector("#sky-card > select"); //select is tag | ||
let weather = select.value; | ||
let landscape = skyToLandscape(weather); | ||
p.textContent = landscape; | ||
|
||
// use sky to landscape function select.value | ||
// let className=tempToColor(value); | ||
// skyToLandscape = select.value | ||
} | ||
const decreaseTempArrow = document.querySelector("#decreaseTempArrow"); //# is id | ||
decreaseTempArrow.addEventListener('click',decreaseTemp); | ||
let select = document.querySelector("#sky-card > select"); //select is tag | ||
select.addEventListener('change',changeSky); | ||
Comment on lines
+99
to
+102
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider moving all the Event Listener logic into a function called |
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
#select by class | ||
.orange-temp { | ||
color: orange; | ||
} | ||
|
||
.red-temp { | ||
color: red; | ||
} | ||
|
||
.yellow-temp { | ||
color: yellow; | ||
} | ||
|
||
.green-temp { | ||
color: green; | ||
} | ||
|
||
.teal-temp { | ||
color: teal; | ||
} | ||
|
||
#city-card input { | ||
background-color: red | ||
} | ||
|
||
#city-card > h3 { | ||
margin: 20px; | ||
} | ||
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These arrows are buttons! It is best practice to use semantic HTML and make these button elements.
In addition, rather than putting the
onclick
event right into the html, we encourage you to use javascript to do this and add the event listener the same way you did for decreaseTemperature