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

Pine-Roslyn M. #74

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed assets/.keep
Empty file.
Binary file added assets/leavenworth/Fall.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/leavenworth/spring.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/leavenworth/summer.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/leavenworth/toohot.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/leavenworth/winter.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Weather Report</title>
<link href="styles/index.css" rel="stylesheet" type="text/css" />
</head>
<body id="all">
<main>
<h1>Weather Report</h1>
<h3>For the lovely town of ✨<span id="city">Leavenworth</span>✨</h3>
<section class="main-container">
<section class="controls">
<div class="subcontrols">Temperature
<div><span id="down">🧊</span><span class="tempcol" id="temp"> 70 </span><span id="up">🔥</span></div></div>

Choose a reason for hiding this comment

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

To add spacing between the span tags, look at padding-left and padding-right.

<div class="subcontrols">Sky:
<select id="sky" name="sky">
<option value="none">None</option>
<option value="cloudy">Cloudy</option>
<option value="snowy">Snowy</option>
<option value="sunny">Sunny</option>
<option value="rainy">Rainy</option>
</select>
</div>
<div class="subcontrols">
<form id="filltown">
<label>Where are you???</label><br>
<input type="text" id="filltownval" name="filltownval"><br>
<input type="submit" value="Reset">
</form>
</div>
</section>
<section class="garden-container">Whats going on in Leavyyy??
<section class="garden" id="gardenchange">
<div id="gardenactivity">☀️☀️☀️☀️☀️☀️☀️☀️☀️☀️☀️☀️</div>
<div id="landscape">🌲🌲🌲🌲🌲🌲🌲🌲🌲🌲🌲🌲</div>
</section>
<div id="landscapetext"> </div>
</section>
</section>
</main>
<script src="scripts/index.js">
</script>
</body>
</html>
79 changes: 79 additions & 0 deletions scripts/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
const up = document.getElementById("up")

Choose a reason for hiding this comment

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

This setup works, but if the script tag was moved from the bottom of the web page to the top, they would stop working, because they would attempt to run before the html loads. I would recommend grabbing these elements in the functions that need them, rather than doing it all at the same time here.

const down = document.getElementById("down")
const temp = document.getElementById("temp")
const landscape = document.getElementById("landscape")
const landscapetext = document.getElementById("landscapetext")
const city = document.getElementById("city")
const form = document.getElementById('filltown');
const sky = document.getElementById("sky")
const state = {tempCount: 70};
const skyscene = document.getElementById('gardenactivity')
const garden = document.getElementsByClassName('garden')

const changeTempColor = () => {

Choose a reason for hiding this comment

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

Great helper function!

if (state.tempCount<=32){
temp.setAttribute('class', 'winter');
landscape.textContent="⛄️⛄️🗻⛷🏂⛄️⛄️🗻⛷🏂⛄️⛄️";
landscapetext.textContent="Its a bit chilly! Time to ski?!?";
document.getElementById('gardenchange').style.background="center / cover no-repeat url(../assets/leavenworth/winter.jpeg)"
} else if (state.tempCount>32 && state.tempCount<=60){
temp.setAttribute('class', 'fall');
landscape.textContent="🍁🚵🏾‍♂️⛰🍁🚵🏽‍♀️🍁🚵🏾‍♂️⛰🍁🚵🏽‍♀️🍁🚵🏾‍♂️";
landscapetext.textContent="Shoulder season whats up! Time for some more mountain biking???";
document.getElementById('gardenchange').style.background="center / cover no-repeat url(../assets/leavenworth/fall.jpeg)"
} else if (state.tempCount>60 && state.tempCount<=80){
temp.setAttribute('class', 'spring')
landscape.textContent="🌲🧗🏾‍♀️🏔🌲🌲🧗🏾‍♀️🏔🌲🌲🧗🏾‍♀️🏔🌲";
landscapetext.textContent="PRIME CLIMBING TEMPS!!!";
document.getElementById('gardenchange').style.background="center / cover no-repeat url(../assets/leavenworth/spring.jpeg)"
} else if (state.tempCount>80 && state.tempCount<=100){
temp.setAttribute('class', 'summer')
landscape.textContent="🌻🏄🏾‍♀️🏝🛶🌻🏄🏾‍♀️🌻🏝🛶🌻🏄🏾‍♀️🌻";
landscapetext.textContent="Its getting hotttttt, maybe time for a plunge???";
document.getElementById('gardenchange').style.background="center / cover no-repeat url(../assets/leavenworth/summer.jpeg)"
} else {
temp.setAttribute('class', 'tooextreme')
landscape.textContent="🍻📚🛋📺🍻📚🛋📺🍻📚🛋📺";
landscapetext.textContent="WAY TOO HOT TO LEAVE THE HOUSE! Time for beer or a book (or both?)!";
document.getElementById('gardenchange').style.background="center / cover no-repeat url(../assets/leavenworth/toohot.jpeg)"
}
}

const changeCity = (event) => {
const inputCity = document.getElementById("filltownval").value;
city.textContent = inputCity;
event.preventDefault();
}

const changeSky = (event) =>{
if (sky.value == "cloudy"){
skyscene.textContent="☁️☁️☁️☁️☁️☁️☁️☁️☁️☁️☁️☁️"
}else if (sky.value == "sunny"){
skyscene.textContent="☀️☀️☀️☀️☀️☀️☀️☀️☀️☀️☀️☀️";
}else if (sky.value == "rainy"){
skyscene.textContent="🌦🌦🌦🌦🌦🌦🌦🌦🌦🌦🌦🌦"
}else if (sky.value == "snowy"){
skyscene.textContent="❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️"
}else{
skyscene.textContent="🛸🛸🛸🛸🛸🛸🛸🛸🛸🛸🛸🛸"
}
event.preventDefault();
}

sky.addEventListener('change', changeSky)

form.addEventListener('input', changeCity)

up.addEventListener('click', ()=>{
state.tempCount += 1;
temp.textContent = `${state.tempCount}`;
changeTempColor();
})

down.addEventListener('click', () => {
Comment on lines +63 to +73

Choose a reason for hiding this comment

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

I recommend wrapping all of the addEventListener calls in a registerEventHandler type function, and then set that up to run when "DOMContentLoaded" event triggers.

state.tempCount -= 1;
temp.textContent = `${state.tempCount}`;
changeTempColor();
})


80 changes: 80 additions & 0 deletions styles/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
body {
color: #D4B5B0;
font-family: American Typewriter, serif;
background: #383E56;
justify-content: center;
text-align: center;
}

.main-container {
display: grid;
grid-template-columns: 40% 60%;
width: 100vw;
height: 100vh;
}

.controls{
display: grid;
grid-template-rows: 30% 30% 30%;
}

.subcontrols {
display: flex;
justify-content: space-evenly;
flex-direction: column;
margin: 15%;
border: #EEDAD1;
border-width: 20%;
border-style: solid;
background: #F69E7B;
padding: 10px;
border-radius: 10px;
color: #383E56;
font-weight: bold;
text-align: center;
}

select{
text-align-last:center;
}
.garden-container {
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
}
.garden {
display: flex;
flex-direction: column;
margin-left: 20%;
margin-right: 20%;
border: #EEDAD1;
border-width: 20%;
padding: 10px;
border-radius: 10px;
border-style: solid;
background: #EEDAD1;
justify-content: space-between;
gap: 200px;
}

.winter {
color:white;
}
.fall {
color:green
}
.spring{
color:yellow
}
.summer {
color:red
}
.tooextreme {
color:black
}

.temp {
color: yellow;
}