forked from AdaGold/weather-report
-
Notifications
You must be signed in to change notification settings - Fork 85
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
Rae Elwell Weather Report #69
Open
raeelwell
wants to merge
3
commits into
Ada-C16:main
Choose a base branch
from
raeelwell:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
const tempDisplay = document.getElementById("temperatureDisplay"); | ||
const skyDisplay = document.getElementById("topDisplay"); | ||
const groundDisplay = document.getElementById("bottomDisplay"); | ||
const cityInput = document.getElementById("mutableSubHeader"); | ||
const bgDisplay = document.getElementById("gardenBackground"); | ||
|
||
//document.getElementById("myDiv").style.backgroundColor = "lightblue"; | ||
|
||
tempDisplay.textContent = 70; | ||
skyDisplay.textContent = "☀️ ☀️ ☀️ ☀️ ☀️ ☀️ ☀️ ☀️ ☀️"; | ||
groundDisplay.textContent ="🌱 🌱 🌱 🌱 🌱 🌱 🌱 🌱"; | ||
cityInput.textContent = "My Hometown"; | ||
bgDisplay.style.backgroundColor = "orange"; | ||
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. It's a best practice to avoid directly setting the style of an element in JS. (This is because then we only have one place we need to update styles when we change the theme of the site.) |
||
|
||
let temperature = 70; | ||
|
||
const registerEventHandlers = () => { | ||
const upArrow = document.querySelector('#upArrow'); | ||
const downArrow = document.querySelector('#downArrow'); | ||
const selectWeather = document.querySelector('#dropdownButton'); | ||
const citySubmission = document.querySelector('#hometownForm'); | ||
|
||
upArrow.addEventListener("click", increaseTemp); | ||
downArrow.addEventListener("click", decreaseTemp); | ||
selectWeather.addEventListener("change", skyStateSelect); | ||
citySubmission.addEventListener("submit", changeCityName); | ||
} | ||
|
||
const increaseTemp = () => { | ||
temperature +=1; | ||
tempDisplay.textContent = temperature; | ||
mutableGround(temperature); | ||
} | ||
|
||
const decreaseTemp = () => { | ||
temperature -=1; | ||
tempDisplay.textContent = temperature; | ||
mutableGround(temperature); | ||
} | ||
|
||
const mutableGround = (temperature) => { | ||
groundDisplay.textContent = "🌱 🌱 🌱 🌱 🌱 🌱 🌱 🌱"; | ||
bgDisplay.style.backgroundColor = "orange"; | ||
if (temperature > 80) { | ||
groundDisplay.textContent = "🌵 🌵 🌵 🌵 🌵 🌵 🌵"; | ||
bgDisplay.style.backgroundColor = "red"; | ||
} | ||
if (temperature < 70) { | ||
groundDisplay.textContent = "💧 💧 💧 💧 💧 💧 💧 💧 💧"; | ||
bgDisplay.style.backgroundColor = "yellow"; | ||
} | ||
if (temperature < 60 ) { | ||
bgDisplay.style.backgroundColor = "green"; | ||
} | ||
if (temperature < 50) { | ||
groundDisplay.textContent = "🏔️ 🏔️ 🏔️ 🏔️ 🏔️ 🏔️ 🏔️ 🏔️"; | ||
bgDisplay.style.backgroundColor = "teal" | ||
} | ||
} | ||
|
||
const skyStateSelect = () => { | ||
let select = document.getElementById('dropdownButton'); | ||
let skyState = select.options[select.selectedIndex].value; | ||
let weatherDisplay = "Weather Display" | ||
if (skyState == "sunny") { | ||
weatherDisplay = "☀️ ☀️ ☀️ ☀️ ☀️ ☀️ ☀️ ☀️ ☀️" | ||
}; | ||
if (skyState == "cloudy") { | ||
weatherDisplay ="☁️ ☁️ ☁️ ☁️ ☁️ ☁️ ☁️ ☁️ ☁️" | ||
}; | ||
if (skyState == "snowy") { | ||
weatherDisplay = "❄️ ❄️ ❄️ ❄️ ❄️ ❄️ ❄️ ❄️ ❄️" | ||
}; | ||
if (skyState =="rainy") { | ||
weatherDisplay = "🌧 🌧 🌧 🌧 🌧 🌧 🌧" | ||
} | ||
skyDisplay.textContent = weatherDisplay; | ||
} | ||
|
||
const changeCityName = (submission) => { | ||
cityInput.textContent = document.getElementById("cityInput").value; | ||
submission.preventDefault(); | ||
} | ||
|
||
document.addEventListener("DOMContentLoaded", registerEventHandlers); | ||
|
||
//consider making sky/grass a dictionary to pull the key from |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
body { | ||
background-color: rgb(62, 62, 177); | ||
font-family:'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif | ||
} | ||
|
||
h1 { | ||
font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif; | ||
font-size: 3em; | ||
} | ||
|
||
p { | ||
font-size:1.2em; | ||
color: lightblue; | ||
} | ||
|
||
.widget * { | ||
background-color: rgb(110, 107, 107); | ||
width: 200px; | ||
display: flex; | ||
flex-direction: column; | ||
flex-wrap: wrap; | ||
} | ||
|
||
main { | ||
display: flex; | ||
justify-content: space-around; | ||
} | ||
|
||
#temperatureChanger { | ||
padding: 15px; | ||
} | ||
|
||
.arrowKeys * { | ||
display: inline; | ||
} | ||
|
||
#skyChanger { | ||
padding: 15px; | ||
} | ||
|
||
#hometownChanger { | ||
padding: 15px; | ||
} | ||
|
||
#gardenBackground { | ||
background-color: green; | ||
width: 500px; | ||
height: 300px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-around; | ||
} | ||
|
||
.display { | ||
display: flex; | ||
justify-content: space-around; | ||
font-size: xx-large; | ||
} | ||
|
||
.header * { | ||
display: inline-block; | ||
} | ||
|
||
.subHeader { | ||
display: inline-block; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It's more appropriate to use a heading tag (
<h2>
,<h3>
depending on how nested) for something like a<section>
title: