-
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
Amethyst - Gloria and Raina #66
base: main
Are you sure you want to change the base?
Changes from all commits
33ffe3a
4043dac
1359b1a
87a61a0
7921238
124cc17
6de5ec0
4c5eeca
8b04d22
a04642e
5aaa8bf
ec8d08a
7b60c83
1c6f40a
7814760
f34fc41
fb5a071
03f17cd
4934bd4
d6868f0
2f21544
6cefb9d
8ded3d5
3e590b8
9a2a727
1bd17d2
3047636
4d79963
d7cebf6
aa1ea02
8401ca5
8653453
aebffd5
27a4387
a057ef9
7490f4b
f66585f
b53e068
0bb5525
530d5ac
b634734
ce2af1f
8d9c483
3263701
28ee519
044fa80
c18b6b9
aa913da
ae7c2ad
62d6362
ccd8931
3167c3d
8a2539a
443518b
bc885fa
51dc73a
c846fb6
115f163
b950d05
4ae3870
3a72de2
72b6ae9
feb56fe
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.vscode | ||
.DS_Store | ||
node_modules | ||
.cache | ||
.cache |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,77 @@ | ||
<!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"> | ||
<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>Weather Report</title> | ||
<link rel="preconnect" href="https://fonts.gstatic.com"> | ||
<link href="https://fonts.googleapis.com/css2?family=Rubik&display=swap" rel="stylesheet"> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" /> | ||
<link | ||
href="https://fonts.googleapis.com/css2?family=Rubik&display=swap" | ||
rel="stylesheet" | ||
/> | ||
<link rel="stylesheet" href="styles/index.css" /> | ||
</head> | ||
<body> | ||
<link | ||
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" | ||
rel="stylesheet" | ||
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" | ||
crossorigin="anonymous" | ||
/> | ||
<link href="https://fonts.googleapis.com/css?family=Montserrat:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i&display=swap" rel="stylesheet"> | ||
</head> | ||
|
||
<body> | ||
</section> | ||
<h1> Raina and Gloria's Weather Report </h1> | ||
<section> | ||
<section class="feature-container" id="temp-container"> | ||
<h2>Temperature</h2> | ||
<p id="increase-temp">⬆️</p> | ||
<p id="display-temp">0</p> | ||
<p id="decrease-temp">⬇️</p> | ||
</section> | ||
<section class="feature-container" id="sky-container"> | ||
<h2>Sky</h2> | ||
<label> | ||
<select id="sky-dropdown"> | ||
Select Sky | ||
<option value="sunny">Sunny</option> | ||
<option value="cloudy">Cloudy</option> | ||
<option value="rainy">Rainy</option> | ||
<option value="snowy">Snowy</option> | ||
</select> | ||
</label> | ||
</section> | ||
<section class="feature-container" id="city-name-container"> | ||
<h2>City</h2> | ||
<h2 id="city-name">Realtime Text City</h2> | ||
<input type="text" id="city-input" id="form1" class="form-control" placeholder="Enter City Name"/> | ||
<button id="reset-button" type="button" class="btn btn-primary"> | ||
<i class="fas fa-search"></i> | ||
<h4>Reset</h4> | ||
</button> | ||
<button id="search-button" type="button" class="btn btn-primary"> | ||
<i class="fas fa-search"></i> | ||
<h4>Search</h4> | ||
</button> | ||
</div> | ||
</section> | ||
<section class="feature-container" id="weather-garden"> | ||
<h2>Weather Garden</h2> | ||
<p id="sky">Sky emojis</p> | ||
<br> | ||
<p id="air"> </p> | ||
<br> | ||
<p id="landscape">Landscape emojis</p> | ||
</section> | ||
|
||
<script src="./node_modules/axios/dist/axios.min.js"></script> | ||
<script src="./src/index.js"></script> | ||
<script src="./node_modules/axios/dist/axios.min.js"></script> | ||
</body> | ||
</html> | ||
<script | ||
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" | ||
integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" | ||
crossorigin="anonymous" | ||
></script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
- [x ] Temperature count | ||
- [x ] Text Color Change | ||
- [ ] Red: >= 80 | ||
- [ ] Orange: >= 70 && <= 79 | ||
- [ ] Yellow: >= 60 && <= 69 | ||
- [ ] Green: >= 50 && <= 59 | ||
- [ ] Teal: <= 49 | ||
- [x] Lanscape Change (Sky and Ground) | ||
- [ ] >= 80 | ||
- [ ] >= 70 && <= 79 | ||
- [ ] >= 60 && <= 69 | ||
- [ ] <= 59 | ||
- [X ] Up Arrow | ||
- [X ] Click increase count | ||
- [X] Down Arrow | ||
- [ X] Click decrease count | ||
|
||
- [ ] Sky Changes container | ||
- [X] drop down | ||
---> changes temp too | ||
- [X] Sunny | ||
- [X] Cloudy | ||
- [X] Rainy | ||
- [X] Sunny | ||
- [ ] City Name | ||
- [x ] Default City | ||
- [ ] Search Input linked to header | ||
- [x] Reset City Name ---- Atlanta or blank? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
const state = { | ||
lat: 33.7488, | ||
lon: 84.3877, | ||
city: "Seattle" | ||
}; | ||
|
||
document.addEventListener("DOMContentLoaded", 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. Putting all your functionality in the event listener for when the DOM is loaded is functionally okay, however you will most likely find the things in there that should be assigned to variables or calculated on initial loads. You will also usually have your event handlers being added in this function as well. For example, document.addEventListener("DOMContentLoaded", function () {
const increaseTemp = document.querySelector("#increase-temp");
const decreaseTemp = document.querySelector("#decrease-temp");
const displayTemp = document.querySelector("#display-temp");
const resetButton = document.querySelector("#reset-button");
const searchButton = document.querySelector("#search-button");
const cityName = document.getElementById("city-name");
const cityInput = document.getElementById("city-input");
const selectSky = document.querySelector("#sky-dropdown");
const result = document.querySelector("#sky");
const landscape = document.querySelector("#landscape");
increaseTemp.addEventListener("click", increaseTemperature);
decreaseTemp.addEventListener("click", decreaseTemperature);
...
} 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. You will also usually find this at the bottom of your file as well, that way you can put all your function definition on top of it. |
||
// ------------- wave 2: increase and decrease temp ------------------ | ||
const increaseTemp = document.querySelector("#increase-temp"); | ||
const decreaseTemp = document.querySelector("#decrease-temp"); | ||
const displayTemp = document.querySelector("#display-temp"); | ||
const resetButton = document.querySelector("#reset-button"); | ||
const searchButton = document.querySelector("#search-button"); | ||
const cityName = document.getElementById("city-name"); | ||
const cityInput = document.getElementById("city-input"); | ||
const selectSky = document.querySelector("#sky-dropdown"); | ||
const result = document.querySelector("#sky"); | ||
const landscape = document.querySelector("#landscape"); | ||
|
||
|
||
// ----- changes temp(converted to fahr) -> landscape -> text color ------ | ||
let temperature = 65; | ||
let lands = "🌾🌾 🍃 🪨 🛤 🌾🌾🌾 🍃"; | ||
Comment on lines
+22
to
+23
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. These could be things that you could be put in your |
||
|
||
const convert = () => { | ||
temperature = ((temperature - 273.15) * 9/5 + 32) | ||
} | ||
const updateTemp = (temperature) => { | ||
displayTemp.textContent = temperature; | ||
updateTempColor(temperature); | ||
updateLandscape(temperature); | ||
landscape.textContent = lands; | ||
} | ||
const updateTempColor = (temperature) => { | ||
if (temperature >= 80) { | ||
displayTemp.style.color = "red"; | ||
} else if (temperature >= 70 && temperature <= 79) { | ||
displayTemp.style.color = "orange"; | ||
} else if (temperature >= 60 && temperature <= 69) { | ||
displayTemp.style.color = "yellow"; | ||
} else if (temperature >= 50 && temperature <= 59) { | ||
displayTemp.style.color = "green"; | ||
} else { | ||
displayTemp.style.color = "teal"; | ||
} | ||
} | ||
const updateLandscape = (temperature) => { | ||
if (temperature >= 80) { | ||
lands = "🌵 🐍 🦂 🌵🌵 🐍 🏜 🦂"; | ||
} else if (temperature >= 70 && temperature <= 79) { | ||
lands = "🌸🌿🌼 🌷🌻🌿 ☘️🌱 🌻🌷"; | ||
} else if (temperature >= 60 && temperature <= 69) { | ||
lands = "🌾🌾 🍃 🪨 🛤 🌾🌾🌾 🍃"; | ||
} else if (temperature <= 59) { | ||
lands = "🌲🌲⛄️🌲⛄️🍂🌲🍁🌲🌲⛄️🍂🌲"; | ||
} | ||
} | ||
const increaseTemperature = () => { | ||
temperature++; | ||
updateTemp(temperature); | ||
} | ||
const decreaseTemperature = () => { | ||
temperature--; | ||
updateTemp(temperature); | ||
} | ||
|
||
increaseTemp.addEventListener("click", increaseTemperature); | ||
decreaseTemp.addEventListener("click", decreaseTemperature); | ||
updateTemp(temperature); | ||
|
||
// ------------- wave 3 naming the city ------------------ | ||
// Realtime Text City info will come from input value of cityInput | ||
const updateCityName = () => { | ||
cityName.textContent = cityInput.value; | ||
} | ||
|
||
// event listener to listen for input | ||
cityInput.addEventListener("input", updateCityName); | ||
|
||
// ------------- wave 5 selecting sky ------------------ | ||
result.textContent = "🌦 🌈 ☁️☁️☁️ ❄️ 🌨 ☁️" | ||
selectSky.addEventListener("change", (event) => { | ||
let newSky = event.target.value | ||
if (newSky == 'sunny') { | ||
result.textContent = "☁️ ☁️ ☁️ ☀️ ☁️ ☁️" | ||
} else if (newSky == 'cloudy'){ | ||
result.textContent = "☁️☁️ ☁️ ☁️☁️ ☁️ 🌤 ☁️ ☁️☁️" | ||
} else if (newSky == 'rainy'){ | ||
result.textContent = "🌧🌈⛈🌧🌧💧⛈🌧🌦🌧💧🌧🌧" | ||
} else if (newSky == 'snowy'){ | ||
result.textContent = "🌨❄️🌨🌨❄️❄️🌨❄️🌨❄️❄️🌨🌨" | ||
} else { | ||
result.textContent = "🧨 🧨 🧨 🧨 🧨 🧨" | ||
} | ||
}) | ||
|
||
// -------- wave 6 reset button event listener --------- | ||
cityName.textContent = state.city | ||
resetButton.addEventListener("click", function () { | ||
cityInput.value = state.city; | ||
cityName.textContent = state.city; | ||
updateTemp("65") | ||
} ) | ||
|
||
// -------- wave 4 calls API --------- | ||
const findLatitudeAndLongitude = async () => { | ||
// let latitude, longitude; | ||
await axios.get('http://127.0.0.1:5000/location', | ||
Comment on lines
+106
to
+108
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. I see that you used the const findLatitudeAndLongitude = async () => {
const resp = await axios.get('http://127.0.0.1:5000/location',{
params: {
q:cityInput.value,
format: 'json'
}})
try {
state.lat= response.data[0].lat;
state.lon= response.data[0].lon;
return {
cityLat: state.lat,
cityLon: state.lon
}
} catch {
console.log('error in findLatitudeAndLongitude!')
}
} |
||
{ | ||
params: { | ||
q:cityInput.value, | ||
format: 'json' | ||
} | ||
}) | ||
.then( (response) => { | ||
state.lat= response.data[0].lat; | ||
state.lon= response.data[0].lon; | ||
}) | ||
.catch( (error) => { | ||
console.log('error in findLatitudeAndLongitude!'); | ||
}); | ||
return { | ||
cityLat: state.lat, | ||
cityLon: state.lon | ||
} | ||
} | ||
|
||
const findTemp = async (latitude, longitude) => { | ||
await axios.get('http://127.0.0.1:5000/weather', | ||
{ | ||
params: { | ||
format: 'json', | ||
lat: latitude, | ||
lon: longitude | ||
} | ||
}) | ||
.then( (response) => { | ||
temperature = response.data.main.temp; | ||
return temperature; | ||
}) | ||
.catch( (error) => { | ||
console.log('error in findLocation!'); | ||
}); | ||
} | ||
|
||
const findWeather = async () => { | ||
const cityCoordinates = await findLatitudeAndLongitude(); | ||
await findTemp(cityCoordinates.cityLat, cityCoordinates.cityLon); | ||
} | ||
|
||
// ------------------- search button --------------------- | ||
searchButton.addEventListener("click", async (event) => { | ||
await findWeather(); | ||
convert() | ||
temperature = Math.round(temperature) | ||
updateTemp(temperature) | ||
|
||
}); | ||
|
||
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. 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! ⭐️ |
||
}); |
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.
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!