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

Amethyst - Gloria and Raina #66

Open
wants to merge 63 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
33ffe3a
linked axios script
Rainacam12 Jun 8, 2023
4043dac
reset button added
Rainacam12 Jun 8, 2023
1359b1a
actions for search/reset button
Rainacam12 Jun 8, 2023
87a61a0
changed css to dark background white text and features are in a row
laughtivity Jun 9, 2023
7921238
added project_notes.txt (added to .gitignore) for shared checklist
laughtivity Jun 11, 2023
124cc17
txt in gitignore
laughtivity Jun 11, 2023
6de5ec0
undid gitignore because....
laughtivity Jun 11, 2023
4c5eeca
added display for temperature
laughtivity Jun 11, 2023
8b04d22
styling dropdown button. Still need to work on dropdown event
laughtivity Jun 11, 2023
a04642e
fixed js and css bug. Deleted/commented out previous notes so functio…
laughtivity Jun 11, 2023
5aaa8bf
added website referenced for dropdown JS
laughtivity Jun 11, 2023
ec8d08a
updated classes for temp change
laughtivity Jun 11, 2023
7b60c83
completed increase temperature functionality whenever up arrow is cli…
laughtivity Jun 11, 2023
1c6f40a
edit spacing
laughtivity Jun 11, 2023
7814760
increase temp button works as well as color-changing feature
Rainacam12 Jun 11, 2023
f34fc41
increment changes
laughtivity Jun 11, 2023
fb5a071
temperature increase/decrease fully working
Rainacam12 Jun 11, 2023
03f17cd
adding landscape changes
laughtivity Jun 11, 2023
4934bd4
Merge branch 'main' of https://github.com/laughtivity/weather-report
laughtivity Jun 11, 2023
d6868f0
adjusted dropdown style to be larger
laughtivity Jun 11, 2023
2f21544
adjustments to dropdown menu items border
laughtivity Jun 11, 2023
6cefb9d
added spacing(air) in between sky and landscape
laughtivity Jun 11, 2023
8ded3d5
reset button to something more button like
laughtivity Jun 12, 2023
3e590b8
city input real-time reflection feature added
Rainacam12 Jun 12, 2023
9a2a727
Merge branch 'main' of https://github.com/laughtivity/weather-report
Rainacam12 Jun 12, 2023
1bd17d2
??? changes
laughtivity Jun 12, 2023
3047636
resolved merge conflict
laughtivity Jun 12, 2023
4d79963
got the temp and landscape working -- issue was a missing }) on line 9
laughtivity Jun 12, 2023
d7cebf6
changed click-dropdown on line 78 in js file to remove bug. Drop down…
laughtivity Jun 12, 2023
aa1ea02
redone the dropdown menu and can now select to change the sky
laughtivity Jun 12, 2023
8401ca5
reset button semi working
Rainacam12 Jun 12, 2023
8653453
added search button. WIP
Rainacam12 Jun 12, 2023
aebffd5
default city name in city container set to Seattle
laughtivity Jun 12, 2023
27a4387
Reset the h2 city name when reset button is used
laughtivity Jun 12, 2023
a057ef9
added a default weather garden sky
laughtivity Jun 12, 2023
7490f4b
changed background for funz
laughtivity Jun 12, 2023
f66585f
2nd background funz
laughtivity Jun 12, 2023
b53e068
changed flex for feature containers
laughtivity Jun 13, 2023
0bb5525
changed function declaration to arrow method for consistency
laughtivity Jun 13, 2023
530d5ac
draft of calling api long/lad to location -> weather
laughtivity Jun 13, 2023
b634734
search and keypress works
Rainacam12 Jun 13, 2023
ce2af1f
search button registers and call function
laughtivity Jun 13, 2023
8d9c483
added async and await to api call
laughtivity Jun 13, 2023
3263701
calls findWeather when search button click
laughtivity Jun 13, 2023
28ee519
deleted unused function
Rainacam12 Jun 13, 2023
044fa80
Revert "calls findWeather when search button click"
laughtivity Jun 13, 2023
c18b6b9
fixed bug in findWeather()
laughtivity Jun 13, 2023
aa913da
reverted to using await/async (no state yet)
laughtivity Jun 13, 2023
ae7c2ad
functions connects for findWeather()
laughtivity Jun 13, 2023
62d6362
coordinates updating accordingly
Rainacam12 Jun 13, 2023
ccd8931
Merge branch 'main' of https://github.com/laughtivity/weather-report
Rainacam12 Jun 13, 2023
3167c3d
fixed it
Rainacam12 Jun 13, 2023
8a2539a
changed placeholder for city input to non-city name
laughtivity Jun 14, 2023
443518b
search button now converts temp from kelvin to fahr, reset to default…
laughtivity Jun 14, 2023
bc885fa
got rid of the else in updateLandscape() since it did not read floats…
laughtivity Jun 14, 2023
51dc73a
converted float to int for simplicity
laughtivity Jun 14, 2023
c846fb6
changes to css background to center content and background
laughtivity Jun 14, 2023
115f163
background repeat
laughtivity Jun 14, 2023
b950d05
removed unused identifiers in html
laughtivity Jun 14, 2023
4ae3870
landscape responsive to changes in temp
laughtivity Jun 14, 2023
3a72de2
changed title but need to fix wrap
laughtivity Jun 14, 2023
72b6ae9
Merge pull request #1 from laughtivity/gwbranch
laughtivity Jun 14, 2023
feb56fe
fixed some bugs from branch merge
laughtivity 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.vscode
.DS_Store
node_modules
.cache
.cache
Empty file removed assets/.keep
Empty file.
81 changes: 71 additions & 10 deletions index.html
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>
28 changes: 28 additions & 0 deletions project_notes.txt
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?
160 changes: 160 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
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!

lat: 33.7488,
lon: 84.3877,
city: "Seattle"
};

document.addEventListener("DOMContentLoaded", function () {
Copy link

@mikellewade mikellewade Jul 17, 2023

Choose a reason for hiding this comment

The 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);
    ...
}

Choose a reason for hiding this comment

The 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

Choose a reason for hiding this comment

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

These could be things that you could be put in your state variable, you want to use your state to hold information specific to a webpage at a specific time.


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

Choose a reason for hiding this comment

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

I see that you used the async/await keywords in a few of your functions. I love that you are making use of them! Here's a tip that will allow you to bring your use more in line with the keywords intention. async/await is intended to be be used in-place of promises. So when using them your code should a little more like this:

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)

});

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! ⭐️

});
Loading