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

Cedar - Rebeca Muniz #76

Open
wants to merge 4 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
55 changes: 55 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href= "styles/index.css"/>
</head>
<body class="parent-side-container">

Choose a reason for hiding this comment

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

Nice work writing clear, semantic HTML!

<header>
<h1> Weather Report </h1>
<h2> 🌈 For the lovely city of <span class="city"> Gayville </span> 🌈 </h2>
</header>

<section class = "temperature-side-container" action="#">
<h3> Temperature </h3>
<p id = "temperature-value"> 76 </p>

Choose a reason for hiding this comment

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

Minor note: it is a convention not to include spaces between a properties and it's value.

Suggested change
<p id = "temperature-value"> 76 </p>
<p id="temperature-value"> 76 </p>

Choose a reason for hiding this comment

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

Consider initializing with class name 'orange' so when the page first loads the 76 is orange

<button id="increaseTemp">⬆️ </button>
<button id="decreaseTemp"> ⬇️ </button>
</section>

<form class= "sky-side-container" action= "#">
<h3> Sky </h3>
<select id="sky-type" name="sky">
<option value="Rainy">Rainy</option>
<option value="Sunny">Sunny</option>
<option value="Snowy">Snowy</option>
<option value="Cloudy">Cloudy</option>
</select>
</form>

<form class= "city-side-container" action= "#" >
<h3> City Name </h3>
<input type="text" class="cityInput" name="city" placeholder="What's your hometown?" />
<button id="resetButton" type="button"> Reset </button>
</form>

<section>
<h3> Weather Garden </h3>
<div class="weather-container">
<p class="sky-weather"> 🌧🌈⛈💧🌧💧⛈🌧🌧🌧💧🌈</p>
<p class="garden-weather"> 🌸🌿🌼__🌷🌻🌿_☘️🌱_🌻🌷 </p>
</div>


</section>

<footer> </footer>
<script src="scripts/index.js"></script>
</body>

</html>


97 changes: 97 additions & 0 deletions scripts/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
//Temperature values elements that will change when clicked
const tempContainer = document.getElementById('temperature-value');
const increaseButton = document.getElementById('increaseTemp');
const decreaseButton = document.getElementById('decreaseTemp');
const gardenWeather = document.querySelector('.garden-weather');
const skyWeather = document.querySelector('.sky-weather');
const skyType = document.getElementById('sky-type');
const resetButton = document.getElementById('resetButton');
const cityName = document.querySelector('.city');
let cityInput = document.querySelector('.cityInput')

const landscapeImage= {
summer: "🌵__🐍_🦂_🌵🌵__🐍_🏜_🦂",
spring: "🌸🌿🌼__🌷🌻🌿_☘️🌱_🌻🌷",
fall: "🌾🌾_🍃_🪨__🛤_🌾🌾🌾_🍃",
winter: "🌲🌲⛄️🌲⛄️🍂🌲🍁🌲🌲⛄️🍂🌲",
}
const skyImage = {
sunny: "☀️☁️ ☀️☁️ ☀️☁️ ☀️ ☁️ ☀️ ☁️☀️",
cloudy: "☁️☁️ ☁️ ☁️☁️ ☁️ 🌤 ☁️ ☁️☁️",
rainy: "🌧🌈⛈🌧🌧💧⛈🌧🌦🌧💧🌧",
snowy: "🌨❄️🌨🌨❄️❄️🌨❄️🌨❄️❄️🌨",
}

const state = {

Choose a reason for hiding this comment

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

Nice use of state object

tempCount: 76,
currentLandscapeImage: landscapeImage.spring
};
//increases and decrease tempereature with one click
const addTemperature = () => {
state.tempCount += 1;
tempContainer.textContent = `${state.tempCount}`;
changeTempTextColor();
}
const decreaseTemperature = () => {
state.tempCount -= 1;
tempContainer.textContent = `${state.tempCount}`;
changeTempTextColor();
}

const changeTempTextColor = () => {
if(state.tempCount >= 80) {

Choose a reason for hiding this comment

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

A chained conditional if\else if\else if would make this code a bit more efficient. Also, minor note, if orangize it as temp <= 49 / else if temp <= 59 ... we do not need the compound conditional.

tempContainer.className = 'red';
gardenWeather.innerHTML = landscapeImage.summer;
}
if(state.tempCount <= 79 && state.tempCount > 70) {
tempContainer.className = 'orange';
gardenWeather.innerHTML = landscapeImage.spring;
}
if(state.tempCount <= 69 && state.tempCount > 60) {
tempContainer.className = 'yellow';
gardenWeather.innerHTML = landscapeImage.fall
}
if(state.tempCount <= 59 && state.tempCount > 50) tempContainer.className = 'green';
if(state.tempCount <= 49) {
tempContainer.className = 'teal';
gardenWeather.innerHTML = landscapeImage.winter
}

}
// Change sky type
const changeSkyType = (event) => {
if(event.target.value === "Sunny") {
skyWeather.innerHTML = skyImage.sunny;
}
if(event.target.value === "Cloudy"){
skyWeather.innerHTML = skyImage.cloudy;
}
if(event.target.value === "Rainy"){
skyWeather.innerHTML = skyImage.rainy;
}
if(event.target.value === "Snowy"){
skyWeather.innerHTML = skyImage.snowy;
}

}

// changes the city name
const changeCityName = (event) => {
cityName.innerHTML = event.target.value
}
// resets the cityname input
const resetCityName = (event) =>{
console.log(cityInput.defaultValue)
cityInput = cityInput.defaultValue
}

const registerEventHandlers = (event) => {

Choose a reason for hiding this comment

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

Great work organizing this event listeners in the registerEventHandlers function. You might consider refactoring grabbing the corresponding elements that are declared as variables at the top of the script here instead.

increaseButton.addEventListener("click", addTemperature);
decreaseButton.addEventListener("click", decreaseTemperature);
skyType.addEventListener("change", changeSkyType);
cityInput.addEventListener("input", changeCityName);
resetButton.addEventListener("click", resetCityName);

};

document.addEventListener("DOMContentLoaded", registerEventHandlers);
39 changes: 39 additions & 0 deletions styles/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* Background blue: #324DF7

Sunny sky background: #D6FFFF,
Cloudy sky background: #C9C9C9
Rainy sky background: #9FCFE0
Snowy sky background: #A1B6D6
Very cold number color: #256D6C
Cold number color: #1F7001
Cool number color: #F4D10A
Warm number color: #F0940A
Hot number color: #EA0009 */


body{
padding: 2rem 2rem;
max-width: 100vw;
}

.red{
color: red;
}
.orange {
color: orange;
}
.yellow {
color: yellow;
}
.green {
color: green;
}
.teal {
color: teal;
}
.weather-container {
background-color: pink;
padding: 2rem;
max-width: 90%;
border-radius: .5rem ;
}