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

Ruby Kimberly & Sage #51

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
97f9762
Upgraded yarn
Coolcud Jun 6, 2023
9612a8e
Added axios script tag
Coolcud Jun 6, 2023
23ef80d
Removed extra axios script tag and added index.css script tag
Coolcud Jun 6, 2023
f214ae1
Added coworking agreement
Coolcud Jun 7, 2023
fd929d4
Removed index.css script tag from body
Coolcud Jun 7, 2023
a9c004a
Adjusted date
Coolcud Jun 7, 2023
cd632d9
Added bare bones HTML
Coolcud Jun 7, 2023
5dfb81a
Added css styling to the index.html file. Styling was added to the fo…
kimcodes3 Jun 7, 2023
926bab3
Added buttons for temperature control
Coolcud Jun 8, 2023
e513f7e
Added axios import and default city info
Coolcud Jun 8, 2023
d12cd67
Added CSS for tempValue and removed extra empty lines
Coolcud Jun 8, 2023
2186232
Added cloud images for background
Coolcud Jun 8, 2023
1856f1c
Added div for current temperature button
Coolcud Jun 8, 2023
afac519
Added up and down temperature buttons functionality
Coolcud Jun 8, 2023
2c85658
Added temperature section css
Coolcud Jun 8, 2023
45c57ff
Merge pull request #1 from Coolcud/temp-section
Coolcud Jun 8, 2023
dc448e8
added a ladnscape object to incorporate in our formatTempAndGarden fu…
kimcodes3 Jun 8, 2023
3bc37e4
created the reset button and a text box for our city name, which is a…
kimcodes3 Jun 8, 2023
759c5fb
Added div for input box and reset button
Coolcud Jun 8, 2023
f442ecc
Added styling for input text box
Coolcud Jun 8, 2023
523235a
Modified current control button to be centered
Coolcud Jun 8, 2023
82afeec
Removed empty line
Coolcud Jun 9, 2023
cbb7b8e
Added getWeather and getCoordinates functionality with axios to get c…
Coolcud Jun 9, 2023
701f50e
Added styling for weather garden
Coolcud Jun 9, 2023
ef0b939
Added sky type dropdown menu for different sky options
Coolcud Jun 9, 2023
f215d58
Added functionality for formatSky() to reflect user choice from dropd…
Coolcud Jun 9, 2023
3724992
Added consistent styling to dropdown menu and small font changes
Coolcud Jun 9, 2023
6093fb2
Merge pull request #2 from Coolcud/sky-section
Coolcud Jun 9, 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
38 changes: 31 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Weather Report

# Coworking Agreement

## Accessibility Needs
- Quieter environment
- Zoom and Live Share
- Keeping each other accountable

## Collaboration vs. individual work expectations
- Divide and conquer
- Give overviews of what was worked on

## Learning Style
- Visual; diagrams preferred
- Learn by looking at examples

## Preferred Feedback Style
- Just don't be Rude.

## One Team Communication Skill to Improve
- Timeboxing and explaining during the process

## Signatures
Kimberly Lantigua & Sage Choi (6/7/2023)

## Skills Assessed

- Following directions and reading comprehension
Expand All @@ -24,23 +48,23 @@ Great weather apps do these two things:
1. Pull weather data from a data source
1. Display the weather in readable, compelling way

![DuckDuckGo's weather modal, which features city name, temperature reading, and the weather. Some icons show sunny weather, some icons show rainy weather, and some show cloudy weather.](ada-project-docs/assets/example-duckduckgo.png)
![DuckDuckGo's weather modal, which features city name, temperature reading, and the weather. Some icons show sunny weather, some icons show rainy weather, and some show cloudy weather.](ada-project-docs/assets/example-duckduckgo.png)
_Fig. DuckDuckGo's weather modal, which features city name, temperature reading, and weather icons._

Our goal is to create a fun, small weather app that focuses on displaying the weather.

Our weather app will set the weather using user interaction and get the weather from a 3rd party API, OpenWeather.

![Example weather app: The temperature reads 62, in yellow text. The selected dropdown for "Sky" is "Cloudy." There is a depiction of cloudy weather. The city name is "Hoboken." The header reads "Hoboken."](ada-project-docs/assets/cloudy-62.png)
![Example weather app: The temperature reads 62, in yellow text. The selected dropdown for "Sky" is "Cloudy." There is a depiction of cloudy weather. The city name is "Hoboken." The header reads "Hoboken."](ada-project-docs/assets/cloudy-62.png)
_Fig. Example weather app displaying the weather for Hoboken._

![Example weather app: The temperature reads 85, in red text. The selected dropdown for "Sky" is "Sunny." There is a depiction of sunny weather. The city name is "Santo Domingo" The header reads "Santo Domingo."](ada-project-docs/assets/santo-domingo-85.png)
![Example weather app: The temperature reads 85, in red text. The selected dropdown for "Sky" is "Sunny." There is a depiction of sunny weather. The city name is "Santo Domingo" The header reads "Santo Domingo."](ada-project-docs/assets/santo-domingo-85.png)
_Fig. Example weather app displaying the weather for Santo Domingo._

![Example weather app: The temperature reads 38, in teal text. The selected dropdown for "Sky" is "Snowy." There is a depiction of snowy weather. The city name is "Bozeman." The header reads "Bozeman."](ada-project-docs/assets/snow-38.png)
![Example weather app: The temperature reads 38, in teal text. The selected dropdown for "Sky" is "Snowy." There is a depiction of snowy weather. The city name is "Bozeman." The header reads "Bozeman."](ada-project-docs/assets/snow-38.png)
_Fig. Example weather app displaying the weather for Bozeman._

![Example weather app: The temperature reads 49, in teal text. The selected dropdown for "Sky" is "Rainy." There is a depiction of rainy weather. The city name is "Seattle." The header reads "Seattle."](ada-project-docs/assets/rainy-49.png)
![Example weather app: The temperature reads 49, in teal text. The selected dropdown for "Sky" is "Rainy." There is a depiction of rainy weather. The city name is "Seattle." The header reads "Seattle."](ada-project-docs/assets/rainy-49.png)
_Fig. Example weather app displaying the weather for Seattle._

## How to Complete and Submit
Expand Down Expand Up @@ -75,9 +99,9 @@ This should be done during the Wave 1 initial setup of your `index.html` page.

## Content Requirements

For this project, there are no requirements around color schemes, font choices, or layouts.
For this project, there are no requirements around color schemes, font choices, or layouts.

Note that applying styles with CSS is one of many learning goals of this project -- it is not the central learning goal. You may enjoy being creative with styles, but we encourage you to not concern yourself with getting the styles perfect. Remember, you can always choose to continue working on styling after you've completed all functional requirements.
Note that applying styles with CSS is one of many learning goals of this project -- it is not the central learning goal. You may enjoy being creative with styles, but we encourage you to not concern yourself with getting the styles perfect. Remember, you can always choose to continue working on styling after you've completed all functional requirements.

However, _at a minimum_, your project must contain these elements:

Expand Down
Binary file added images/clouds1.jpg
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 images/clouds2.jpg
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 images/clouds3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 45 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,51 @@
<link rel="stylesheet" href="styles/index.css" />
</head>
<body>
<script src="./src/index.js"></script>
<header class="header__header">
<h1>Weather Report</h1>
<span>Follow your curio-city:

Choose a reason for hiding this comment

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

😂 Excellent!

<span id="headerCityName" class="header__city-name">
Seattle
</span>
</span>
</header>
<section class="temperature__section">
<h2>Temperature (℉)</h2>
<div class="temperature__content">
<div class="temperature__controls">
<button id="increaseTempBtn">+</button>
<span id="tempValue" class="yellow">72</span>
<button id="decreaseTempBtn">-</button>
</div>
<div class="current__control">
<button id="currentTempBtn">Current Temp</button>
</div>
</div>
</section>
<section class="sky__section">
<h2>Sky</h2>
<select id="skySelect">
<option>Sunny</option>
<option>Cloudy</option>
<option>Rainy</option>
<option>Snowy</option>
</select>
</section>
<section class="city-name__section">
<h2>City Name</h2>
<div id="textAndBtn">
<input id="cityNameInput" type="text" value="Seattle">
<button id="cityNameReset" class="city-name__reset-btn">Reset</button>
</div>
</section>
<section class="garden__section">
<h2>Weather Garden</h2>
<div id="gardenContent" class="garden__content sunny">
<div id="sky"></div>
<div id="landscape"></div>
</div>
</section>
<script src="./node_modules/axios/dist/axios.min.js"></script>
<script src="./src/index.js"></script>
</body>
</html>
185 changes: 185 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@

const state = {
city: 'Seattle',
lat: 47.6038321,
long: -122.3300624,
temp: 70,
};

const convertKToF = (temp) => {

Choose a reason for hiding this comment

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

Excellent!

return (temp - 273.15) * (9 / 5) + 32;
};

const getWeather = () => {

Choose a reason for hiding this comment

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

Excellent!

axios
.get('http://127.0.0.1:5000/weather', {
params: {
lat: state.lat,
lon: state.long,
},
})
.then((response) => {
const weather = response.data;
state.temp = Math.round(convertKToF(weather.main.temp));
formatTempAndGarden();
})
.catch((error) => {
console.log('Could not retrieve the weather:')

Choose a reason for hiding this comment

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

Minor nitpick, but it seems you meant to include printing the error, but didn't!

});
};

const getCoordinates = async () => {

Choose a reason for hiding this comment

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

Generally, if you add async to the function definition, that means you are using await instead of .then(). Since you're using .then(), you do not need the async here.

axios
.get('http://127.0.0.1:5000/location', {
params: {
q: state.city,
},
})
.then((response) => {
state.lat = response.data[0].lat;
state.long = response.data[0].lon;
getWeather();
})
.catch((error) => {
console.log('Could not find latitute and longitude:', error.response);

Choose a reason for hiding this comment

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

I believe errors don't have a response, you would just print the error directly.

});
};

const updateCityName = () => {

Choose a reason for hiding this comment

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

Excellent!

const inputName = document.getElementById("cityNameInput").value;
const headerCityName = document.getElementById("headerCityName");
state.city = inputName;
headerCityName.textContent = state.city;
};

const resetCityName = () => {

Choose a reason for hiding this comment

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

Excellent!

const cityNameInput = document.getElementById("cityNameInput");
cityNameInput.value = 'Seattle';
updateCityName();
};

const formatSky = () => {

Choose a reason for hiding this comment

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

Excellent!

const skies = {
sunny: "☁️ ☁️ ☁️ ☀️ ☁️ ☁️",
cloudy: "☁️☁️ ☁️ ☁️☁️ ☁️ 🌤 ☁️ ☁️☁️",
rainy: "🌧🌈⛈🌧🌧💧⛈🌧🌦🌧💧🌧🌧",
snowy: "🌨❄️🌨🌨❄️❄️🌨❄️🌨❄️❄️🌨🌨"
};
const inputSky = document.getElementById('skySelect').value;
const skyBox = document.getElementById('sky');
let sky = '';
let skyColor = '';

if (inputSky === 'Sunny') {
sky = skies.sunny;
skyColor = 'sunny';
} else if (inputSky === 'Cloudy') {
sky = skies.cloudy;
skyColor = 'cloudy';
} else if (inputSky === 'Rainy') {
sky = skies.rainy;
skyColor = 'rainy';
} else if (inputSky === 'Snowy') {
sky = skies.snowy;
skyColor = 'snowy';
}

skyBox.textContent = sky;
const gardenContent = document.getElementById('gardenContent');
gardenContent.classList = `garden__content ${skyColor}`;
}

const formatTempAndGarden = () => {

Choose a reason for hiding this comment

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

Excellent!

const landscapes = {
hot: "🌵__🐍_🦂_🌵🌵__🐍_🏜_🦂",
warm: "🌸🌿🌼__🌷🌻🌿_☘️🌱_🌻🌷",
cool: "🌾🌾_🍃_🪨__🛤_🌾🌾🌾_🍃",
cold: "🌲🌲⛄️🌲⛄️🍂🌲🍁🌲🌲⛄️🍂🌲"
};
let temp = state.temp;
let color = 'green';
let landscape = landscapes.warm;

if (temp >= 100) {
color = 'red';
landscape = landscapes.hot;
} else if (temp >= 95) {
color = 'orangered';
landscape = landscapes.hot;
} else if (temp >= 86) {
color = 'orange';
landscape = landscapes.hot;
} else if (temp >= 77) {
color = 'green';
landscape = landscapes.warm;
} else if (temp >= 68) {
color = 'darkgreen';
landscape = landscapes.warm;
} else if (temp >= 59) {
color = 'teal';
landscape = landscapes.cool;
} else if (temp >= 50) {
color = 'cornflowerblue';
landscape = landscapes.cool;
} else if (temp >= 41) {
color = 'steelblue';
landscape = landscapes.cold;
} else if (temp >= 32) {
color = 'royalblue';
landscape = landscapes.cold;
} else if (temp >= 23) {
color = 'darkblue';
landscape = landscapes.cold;
} else if (temp >= 14) {
color = 'darkslateblue';
landscape = landscapes.cold;
} else if (temp >= 5) {
color = '#424040';
landscape = landscapes.cold;
} else {
color = 'black';
landscape = landscapes.cold;
}

const temperature = document.getElementById('tempValue');
const newLandscape = document.getElementById('landscape');
temperature.style.color = color;
temperature.textContent = String(state.temp);
newLandscape.textContent = landscape;
};

const increaseTemp = () => {

Choose a reason for hiding this comment

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

Excellent!

state.temp++;
formatTempAndGarden();
};

const decreaseTemp = () => {

Choose a reason for hiding this comment

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

Excellent!

state.temp--;
formatTempAndGarden();
};

const registerEventHandlers = () => {

Choose a reason for hiding this comment

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

Excellent!

formatTempAndGarden();
const currentTempBtn = document.getElementById('currentTempBtn');
currentTempBtn.addEventListener('click', getCoordinates);

const increaseTempBtn = document.getElementById('increaseTempBtn');
increaseTempBtn.addEventListener('click', increaseTemp);

const decreaseTempBtn = document.getElementById('decreaseTempBtn');
decreaseTempBtn.addEventListener('click', decreaseTemp);

updateCityName();

Choose a reason for hiding this comment

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

This function call is not necessary when the page first loads since it's the one that needs to be called when users are typing something in to the search bar.

const cityNameInput = document.getElementById('cityNameInput');
cityNameInput.addEventListener('input', updateCityName);

const cityNameResetBtn = document.getElementById('cityNameReset');
cityNameResetBtn.addEventListener('click', resetCityName);
cityNameResetBtn.addEventListener('click', getCoordinates);

formatSky();
const skySelect = document.getElementById('skySelect');
skySelect.addEventListener('change', formatSky);
};

document.addEventListener('DOMContentLoaded', registerEventHandlers);
Loading