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

Maz + Kaliane Van #71

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8e084e3
created template, classes and ids
mlweir98 Jun 8, 2023
fc21181
created increase temp button)
mlweir98 Jun 8, 2023
2cc2a70
changed ids for increase temp button container
mlweir98 Jun 8, 2023
c126ed8
added functionality to increase temp button
mlweir98 Jun 8, 2023
eb6634a
added functionality to decrease temp button
mlweir98 Jun 8, 2023
46b06b4
added color classes for temp changes
mlweir98 Jun 8, 2023
28f5c42
changed class names to snake case
mlweir98 Jun 8, 2023
4d2f23f
added class to tempincrease button
mlweir98 Jun 8, 2023
7d09b5f
updated class name for temp display
mlweir98 Jun 8, 2023
1b1e016
added color changes for temperature based on temperature change
mlweir98 Jun 8, 2023
9a75f09
added classes for different temperatures
mlweir98 Jun 8, 2023
cd6060d
Implemented emoji landscape for wave 2.
kalianev Jun 9, 2023
393c5ea
updated names of ids for entire html document to be in snakeCase
mlweir98 Jun 9, 2023
9965e46
added input functionality
mlweir98 Jun 9, 2023
6e5dcef
solved merge conflicts
mlweir98 Jun 9, 2023
f9e0e76
changed name of checkTemp function to more accurately reflect functio…
mlweir98 Jun 9, 2023
2ab4b47
Added emoji sky dropdown menu for wave 6.
kalianev Jun 12, 2023
0d20642
began implementing wave 4, cannot get api call to work
mlweir98 Jun 12, 2023
2b4d893
resolved merge conflicts
mlweir98 Jun 12, 2023
790fbb9
added functionality for reset button, api calls
mlweir98 Jun 12, 2023
2114375
updated id name for temp button
mlweir98 Jun 12, 2023
7a97d6e
updated id name for temp button to realTimeTemp
mlweir98 Jun 12, 2023
07f23e8
Added defualt emoji sky and emoji landscape to HTML.
kalianev Jun 12, 2023
d4f14f8
updated class names:
mlweir98 Jun 12, 2023
d3a2453
updated class names
mlweir98 Jun 12, 2023
b6eca8b
merged conflicts
mlweir98 Jun 12, 2023
9a88730
Wave 6 Complete. Need to reimpliment temp up and down functionality a…
kalianev Jun 13, 2023
89e7037
hehe
mlweir98 Jun 13, 2023
e23f743
hehe
mlweir98 Jun 13, 2023
cf625f4
resolved merge conflicts
mlweir98 Jun 13, 2023
e6559d9
Fixed the temp up and down feature.
kalianev Jun 13, 2023
e63958d
changed id names
mlweir98 Jun 13, 2023
283a4ce
committing
mlweir98 Jun 13, 2023
664401d
reverted to correct commit
mlweir98 Jun 13, 2023
93b4ab4
reverted to past commit
mlweir98 Jun 13, 2023
c6d9b54
commit
mlweir98 Jun 13, 2023
8c9aa2d
THIS VERSION WORKS
mlweir98 Jun 13, 2023
35b0f6d
Trouble shooting implementing single click real temp button
kalianev Jun 13, 2023
ea3cee3
implemented
mlweir98 Jun 13, 2023
3914ff7
Merge branch 'main' of https://github.com/MotifNoticer/weather-report
mlweir98 Jun 13, 2023
51fa9d9
implemented css grid
mlweir98 Jun 14, 2023
342d656
created await async format
mlweir98 Jun 14, 2023
126d17a
added css grid
mlweir98 Jun 14, 2023
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
54 changes: 54 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,60 @@
<link rel="stylesheet" href="styles/index.css" />
</head>
<body>
<section class="container" id="mainAppContainer">
<section class="child header" id="weatherReport">
<h2 id="weatherHeader">Weather Report</h2>
<div class="cityDisplay">
<h3>For the lovely city of...</h3>
<h3 id="weatherCity"></h3>
</div>
</section>
<section class="child" id="temp">
<h2 id="tempHeader">Temperature</h2>
<section id="tempChangesSection">
<div id="tempNumberLabel">
<h2 id="tempNumberContainer" class="greenTemp"></h2>
</div>
<div>
<button id="increaseTempButton">Temp Up</button>
</div>
<div>
<button id="decreaseTempButton">Temp Down</button>
</div>
</section>
</section>
<section class="child" id="sky">
<div>
<h2 id="skyHeaderContainer">Sky</h2>
</div>
<div>
<select id="skyDropdown">
<option value="sunny">Sunny</option>
<option value="cloudy">Cloudy</option>
<option value="rainy">Rainy</option>
<option value="snowy">Snowy</option>
</select>
</div>
</section>
<section class="child" id="cityInfoDisplay">
<div id="cityHeaderContainer">
<h2 id="cityNameContainer">City Name</h2>
</div>
<div id="cityChangesDiv">
<input id="cityInput" type="text">
<button id="realTempButton" type="reset">Real Temp</button>
</div>
</section>
<section class="child div2" id="weatherGardenSection">
<div>
<h2 id="weatherGardenHeaderContainer">Weather Garden</h2>
</div>
<div id="landscapeDisplayContainer">
<div id="skyEmojiContainer">☁️ ☁️ ☁️ ☀️ ☁️ ☁️</div>
<div id="landEmojiContainer">🌲🌲⛄️🌲⛄️🍂🌲🍁🌲🌲⛄️🍂🌲</div>
</div>
</section>
</section>
<script src="./src/index.js"></script>
<script src="./node_modules/axios/dist/axios.min.js"></script>
</body>
Expand Down
43 changes: 43 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"dependencies": {
"axios": "^1.2.1"
}
"axios": "^0.21.1"
},
"name": "weather-report",
"description": "## Skills Assessed",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
140 changes: 140 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
// `"use strict";`

const state = {

Choose a reason for hiding this comment

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

Love how you all chose to use this psuedostate! I think that it is great practice for what you will see in React though it will be utilized differently!

increaseTempButton: null,
decreaseTempButton: null,
tempNumberContainer: null,
tempNumberClass: '',
tempNumber: '',
skyEmojiContainer: null,
skyEmoji: '',
landEmojiContainer: '',
landEmoji: '',
cityNameContainer: null,
cityName: '',
cityInput: '',
realTempButton: null,
SkyDropdown: null,
lat: null,
lon: null,
};

const loadControls = () => {
state.increaseTempButton = document.getElementById('increaseTempButton');
state.decreaseTempButton = document.getElementById('decreaseTempButton');
state.tempNumber = parseInt(document.getElementById('tempNumberContainer').innerText);
state.tempNumberContainer = document.getElementById('tempNumberContainer');
state.tempNumberClass = document.getElementById('tempNumberContainer').className;
state.skyEmojiContainer = document.getElementById('skyEmojiContainer');
state.skyEmoji = document.getElementById('skyEmojiContainer').innerText;
state.landEmojiContainer = document.getElementById('landEmojiContainer');
state.landEmoji = document.getElementById('landEmojiContainer').innerText;
state.cityNameContainer = document.getElementById('cityNameContainer');
state.cityName = document.getElementById('cityNameContainer').innerText;
state.cityInput = document.getElementById('cityInput');
state.realTempButton = document.getElementById('realTempButton');
state.skyDropdown = document.getElementById('skyDropdown');
state.weatherCity = document.getElementById('weatherCity');
};
Comment on lines +22 to +38

Choose a reason for hiding this comment

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

Oh wow! I love this! This shows me you centering readability! Naming conventions like this make your code a lot more intuitive!


const getTempColor = (tempNumber) => {
let className = 'redTemp';
if (tempNumber >= 80) {
className = 'redTemp';
} else if (tempNumber >= 70) {
className = 'orangeTemp';
} else if (tempNumber >= 60) {
className = 'yellowTemp';
} else if (tempNumber >= 50) {
className = 'greenTemp';
} else if (tempNumber <= 49) {
className = 'tealTemp';
}
return className
}

const getLandscape = (temperature) => {
if (temperature >= 80) {
return "🌵__🐍_🦂_🌵🌵__🐍_🏜_🦂";
} else if (temperature >= 70) {
return "🌸🌿🌼__🌷🌻🌿_☘️🌱_🌻🌷";
} else if (temperature >= 60) {
return "🌾🌾_🍃_🪨__🛤_🌾🌾🌾_🍃";
} else {
return "🌲🌲⛄️🌲⛄️🍂🌲🍁🌲🌲⛄️🍂🌲";
}
};

const getSky = (skyType) => {
switch(skyType) {
case 'sunny':
return "☁️ ☁️ ☁️ ☀️ ☁️ ☁️";
case 'cloudy':
return "☁️☁️ ☁️ ☁️☁️ ☁️ 🌤 ☁️ ☁️☁️";
case 'rainy':
return "🌧🌈⛈🌧🌧💧⛈🌧🌦🌧💧🌧🌧";
case 'snowy':
return "🌨❄️🌨🌨❄️❄️🌨❄️🌨❄️❄️🌨🌨";
default:
return '';
}
};

const getRealTemp = async (locationName) => {
const locationResp = await axios.get('http://localhost:5000/location',{ params: {q: locationName } })

const coords = [locationResp.data[0]['lat'], locationResp.data[0]['lon']]

const weatherResponse = await getWeather(coords[0],coords[1])

return weatherResponse

}
Comment on lines +83 to +92

Choose a reason for hiding this comment

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

Okay async/await! You used this perfectly!


const getWeather = async (lat,lon) => {
const response = await axios
.get('http://localhost:5000/weather',{
params: {
lat: lat,
lon: lon,
units: 'imperial',
},
})

state.tempNumber = response.data['main']['temp']
};

const registerEventHandlers = () => {

Choose a reason for hiding this comment

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

⭐️⭐️⭐️

state.increaseTempButton.addEventListener('click', () => {
state.tempNumberContainer.innerText = ++state.tempNumber;
state.tempNumberContainer.className = getTempColor(state.tempNumberContainer.innerText);
state.landEmojiContainer.innerText = getLandscape(state.tempNumber);
});
state.decreaseTempButton.addEventListener('click', () => {
state.tempNumberContainer.innerText = --state.tempNumber;
state.tempNumberContainer.className = getTempColor(state.tempNumber);
state.landEmojiContainer.innerText = getLandscape(state.tempNumber);
});

state.cityInput.addEventListener('input', () => {
state.cityNameContainer.innerText = state.cityInput.value;
state.weatherCity.innerText = state.cityInput.value;
});

state.realTempButton.addEventListener('click', async () => {
await getRealTemp(state.cityNameContainer.innerText)
state.tempNumberContainer.innerText = state.tempNumber;
state.tempNumberContainer.className = getTempColor(state.tempNumber);
state.landEmojiContainer.innerText = getLandscape(state.tempNumber);
});
state.skyDropdown.addEventListener('change', () => {
state.skyEmojiContainer.innerText = getSky(state.skyDropdown.value);
});
};

const onLoaded = () => {
loadControls();
registerEventHandlers();
};

onLoaded();

Choose a reason for hiding this comment

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

I would suggest putting your onLoaded method inside an event handler for when the document is loaded, that way you can have an extra layer of protection when it comes to things loading in order. Basically, it would help ensure the loadControls and. registerEventHandlers functions would run after the DOM elements are loaded. It would look something like this:

document.addEventListener("DOMContentLoaded", function () {
    loadControls()
    registerEventHandlers()
}

Choose a reason for hiding this comment

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

Awesome job everyone! You really ate this one up! Please feel free to reach out to me if you have any questions about the comments I left or if you want to discuss anything in greater detail! ⭐️

50 changes: 50 additions & 0 deletions styles/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
.redTemp {
color: red;
}

.orangeTemp {
color: orange;
}

.yellowTemp {
color: yellow;
}

.greenTemp {
color: green;
}

.tealTemp {
color: teal;
}

#landscapeEmojiDiv {
font-size: 24px;
line-height: 1.5;
margin-top: 20px;
white-space: pre-wrap;
}

.cityDisplay {
background-color: red;
/* padding; */
display: flex;
flex-direction: row;
gap: 1rem;
}

.container {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-template-rows: repeat(4, 1fr);
grid-column-gap: 50px;
grid-row-gap: 50px;
}

.header { grid-area: 1 / 1 / 2 / 2; }

.child {
background-color: aliceblue;
}

.div2 { grid-area: 2 / 2 / 5 / 3; }
Loading