-
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
Cedar: Khandice Schuhmann #64
base: main
Are you sure you want to change the base?
Changes from 12 commits
1bd88ed
ce6e434
2665ca9
a4e98e7
043ed18
22fa242
3d3205f
193a195
afd9b8d
6d2a608
0b574fe
095bb48
26b370a
f986181
9e9dfec
fc845cf
76c1e0a
f74aac1
46ab991
291583f
3a3e52f
0dc9d69
b53df56
abc4cf0
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,127 @@ | ||
const updateCity = () => { | ||
const userInput = document.querySelector('#user_input').value; | ||
document.getElementById('city_name').innerHTML = userInput; | ||
}; | ||
|
||
const createResetListener = () => { | ||
const resetButton = document.getElementById('reset'); | ||
resetButton.addEventListener('click', function(){ | ||
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. For the callback functions in each of the |
||
document.getElementById('city_name').innerHTML = 'My Favorite City 😌'; | ||
}) | ||
}; | ||
|
||
const createSkyListener = () => { | ||
document.getElementById('sky_dropdown').addEventListener('change', function() { | ||
if (document.getElementById('sky_dropdown').value === "sunny"){ | ||
document.getElementById('sky_emojis').innerHTML = '☁️ ☁️ ☁️ ☀️ ☁️ ☁️'; | ||
} | ||
if (document.getElementById('sky_dropdown').value === "cloudy"){ | ||
document.getElementById('sky_emojis').innerHTML = | ||
'☁️☁️ ☁️ ☁️☁️ ☁️ 🌤 ☁️ ☁️☁️'; | ||
} | ||
console.log(document.getElementById('sky_dropdown').value); | ||
if (document.getElementById('sky_dropdown').value === "rainy"){ | ||
document.getElementById('sky_emojis').innerHTML = '🌧🌈⛈🌧🌧💧⛈🌧🌦🌧💧🌧🌧'; | ||
} | ||
console.log(document.getElementById('sky_dropdown').value); | ||
if (document.getElementById('sky_dropdown').value === "snowy"){ | ||
document.getElementById('sky_emojis').innerHTML = '🌨❄️🌨🌨❄️❄️🌨❄️🌨❄️❄️🌨🌨'; | ||
} | ||
}); | ||
|
||
}; | ||
|
||
const createTempListeners = () => { | ||
const upArrow = document.querySelector("#raise_temp"); | ||
const downArrow = document.querySelector('#lower_temp'); | ||
const tempNum = document.getElementById('temp_display'); | ||
tempNum.innerHTML = 55; | ||
upArrow.addEventListener("click", function(){ | ||
tempNum.innerHTML = parseInt(tempNum.innerHTML) + 1; | ||
}); | ||
downArrow.addEventListener('click', function () { | ||
tempNum.innerHTML = parseInt(tempNum.innerHTML) - 1; | ||
}); | ||
}; | ||
|
||
city_name_header; | ||
change_widgets; | ||
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 looks like these lines can be removed |
||
const createGroundListener = () => { | ||
document.getElementById('temp_display').addEventListener('DOMSubtreeModified', function () { | ||
if (document.getElementById('temp_display').innerHTML <= 44) { | ||
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. Nice work dynamically implementing these styles. It looks great! Notice that there is quite a bit of repeated code here. Here are a couple ways you might consider refactoring. 1) Rather than applying the style directly to the element, you could assign a class to each element here, and then use that class to apply to styles. Assign each element that you are dynamically styling to a constant, and then you can use that constant to either directly change the style or assign a class name. |
||
document.getElementById('ground_emojis').innerHTML = '🌲🎄🦭🦭🌲⛄️🌲🐻❄️⛄️🗻🐧🌲🎄'; | ||
document.getElementById('weather_body').style.backgroundColor = | ||
'rgba(157, 236, 237, 0.701)'; | ||
document.getElementById('city_name_header').style.backgroundColor = | ||
'rgba(157, 236, 237, 0.701)'; | ||
document.getElementById('change_temp').style.backgroundColor = | ||
'rgba(157, 236, 237, 0.701)'; | ||
document.getElementById('change_sky').style.backgroundColor = | ||
'rgba(157, 236, 237, 0.701)'; | ||
document.getElementById('change_city').style.backgroundColor = | ||
'rgba(157, 236, 237, 0.701)'; | ||
}else if (document.getElementById('temp_display').innerHTML <= 59) { | ||
document.getElementById('ground_emojis').innerHTML = | ||
'🌲🌲⛄️🌲⛄️🍂🌲🍁🌲🌲⛄️🍂🌲'; | ||
document.getElementById('weather_body').style.backgroundColor = | ||
'rgba(99, 165, 235, 0.81)'; | ||
document.getElementById('city_name_header').style.backgroundColor = | ||
'rgba(99, 165, 235, 0.81)'; | ||
document.getElementById('change_temp').style.backgroundColor = | ||
'rgba(99, 165, 235, 0.81)'; | ||
document.getElementById('change_sky').style.backgroundColor = | ||
'rgba(99, 165, 235, 0.81)'; | ||
document.getElementById('change_city').style.backgroundColor = | ||
'rgba(99, 165, 235, 0.81)'; | ||
} else if (document.getElementById('temp_display').innerHTML <= 69) { | ||
document.getElementById('ground_emojis').innerHTML = | ||
'🌾🌾_🍃_🪨__🛤_🌾🌾🌾_🍃'; | ||
document.getElementById('weather_body').style.backgroundColor = | ||
'rgba(70, 184, 70, 0.701)'; | ||
document.getElementById('city_name_header').style.backgroundColor = | ||
'rgba(70, 184, 70, 0.701)'; | ||
document.getElementById('change_temp').style.backgroundColor = | ||
'rgba(70, 184, 70, 0.701)'; | ||
document.getElementById('change_sky').style.backgroundColor = | ||
'rgba(70, 184, 70, 0.701)'; | ||
document.getElementById('change_city').style.backgroundColor = | ||
'rgba(70, 184, 70, 0.701)'; | ||
} else if (document.getElementById('temp_display').innerHTML <= 79) { | ||
document.getElementById('ground_emojis').innerHTML = '🌸🌿🌼__🌷🌻🌿_☘️🌱_🌻🌷'; | ||
document.getElementById('weather_body').style.backgroundColor = | ||
'rgba(255, 234, 0, 0.701)'; | ||
document.getElementById('city_name_header').style.backgroundColor = | ||
'rgba(255, 234, 0, 0.701)'; | ||
document.getElementById('change_temp').style.backgroundColor = | ||
'rgba(255, 234, 0, 0.701)'; | ||
document.getElementById('change_sky').style.backgroundColor = | ||
'rgba(255, 234, 0, 0.701)'; | ||
document.getElementById('change_city').style.backgroundColor = | ||
'rgba(255, 234, 0, 0.701)'; | ||
}else if (document.getElementById('temp_display').innerHTML >= 80) { | ||
document.getElementById('ground_emojis').innerHTML = '🌵__🐍_🦂_🌵🌵__🐍_🏜_🦂'; | ||
document.getElementById('weather_body').style.backgroundColor = | ||
'rgba(247, 153, 12, 0.701)'; | ||
document.getElementById('city_name_header').style.backgroundColor = | ||
'rgba(247, 153, 12, 0.701)'; | ||
document.getElementById('change_temp').style.backgroundColor = | ||
'rgba(247, 153, 12, 0.701)'; | ||
document.getElementById('change_sky').style.backgroundColor = | ||
'rgba(247, 153, 12, 0.701)'; | ||
document.getElementById('change_city').style.backgroundColor = | ||
'rgba(247, 153, 12, 0.701)'; | ||
} | ||
}); | ||
}; | ||
|
||
|
||
const registerEventHandlers = () => { | ||
createSkyListener(); | ||
updateCity(); | ||
createResetListener(); | ||
createTempListeners(); | ||
createGroundListener(); | ||
}; | ||
|
||
// wait to register my event handlers until page is fully loaded. | ||
document.addEventListener("DOMContentLoaded", registerEventHandlers); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
body { | ||
background-color: rgba(141, 187, 235, 0.742); | ||
} | ||
header, #weather_body, #change_temp, #change_sky, #change_city{ | ||
background-color: rgba(99, 165, 235, 0.81); | ||
color: white; | ||
font-family: 'Abril Fatface', cursive; | ||
} | ||
|
||
#city_name_header { | ||
display: flex; | ||
justify-content: center; | ||
margin: 50px 575px; | ||
border-radius: 50px; | ||
padding: 0px 15px; | ||
font-size: smaller; | ||
} | ||
|
||
#weather_body { | ||
margin: 35px 175px; | ||
border-radius: 5px; | ||
font-size: 5em; | ||
text-align: center; | ||
} | ||
|
||
#weather_body div { | ||
padding: 50px 0px; | ||
} | ||
#change_widgets { | ||
display: flex; | ||
margin: 35px 250px; | ||
justify-content: space-between; | ||
} | ||
|
||
#change_temp, #change_sky, #change_city { | ||
border-radius: 50%; | ||
text-align: center; | ||
width: 200px; | ||
height: 175px; | ||
font-size: 25px; | ||
|
||
} | ||
|
||
#change_temp{ | ||
display: grid; | ||
grid-template-columns: 1fr 1fr; | ||
grid-template-rows: 1fr 2fr; | ||
} | ||
|
||
#change_temp h4 { | ||
grid-row-start: 1; | ||
grid-column: 1 / span 2; | ||
} | ||
/* #lower_temp { | ||
grid-row-start: 2; | ||
grid-column-start: 1; | ||
} | ||
|
||
#temp_display { | ||
grid-column-start: 2; | ||
grid-column-end: 3; | ||
grid-row: 1 / span 2; | ||
|
||
} */ | ||
|
||
#temp_buttons { | ||
margin: -20px; | ||
} | ||
|
||
#temp_buttons button { | ||
width: 20px; | ||
border: none; | ||
display: block; | ||
align-self: end; | ||
} | ||
|
||
#sky_dropdown { | ||
width: 150px; | ||
} | ||
|
||
#reset { | ||
border-radius: 5px; | ||
font-family: 'Abril Fatface', cursive; | ||
} | ||
|
||
footer{ | ||
text-align: center; | ||
} |
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.
Nice work writing semantic html