Skip to content

sea turtles ada c17 #82

Open
jaekerrclayton wants to merge 4 commits into
ada-c17:mainfrom
jaekerrclayton:main
Open

sea turtles ada c17 #82
jaekerrclayton wants to merge 4 commits into
ada-c17:mainfrom
jaekerrclayton:main

Conversation

@jaekerrclayton

Copy link
Copy Markdown

No description provided.

@anselrognlie anselrognlie left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice job!

Storing app state in variables is a useful code strategy (get your sky in there too!). Structuring our code so that there are separate functions for updating those variables, and then publishing the values helps us manage user interactions and data processing. Think about how to restructure the axios calls to be a bit more generally reusable (how can we avoid making the second call directly from the first?). And keep an eye out for areas where we can use data structures to reduce code duplication.

Comment thread index.html


</main>
<script src="/src/index.js"></script>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Depending on your deployment target, absolute paths (starting with /) might not work properly. For project-style github pages sites, we need to use only relative paths (not starting with /) since they are deployed to a subdirectory, which throughs off what absolute paths map to.

Comment thread index.html



<section id="choose_sky" class="box">

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A section without a heading generates a validation warning. If we're really just grouping some elements for styling and not grouping them under a heading of some kind, prefer a plain div.

Comment thread styles/index.css Outdated
color:darksalmon;
padding: 2rem;
border-radius: 50px;
background-image: url(/styles/glitter.png);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In styles, still try to use relative paths to resources. They are interpreted relative to the css file location, not the HTML importing it.

Comment thread styles/index.css
@@ -0,0 +1,164 @@
body{

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Try using the VSCode Format Document option to keep the CSS file tidy. The indentation is a bit inconsistent.

Comment thread src/index.js
@@ -0,0 +1,199 @@
"use strict";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remember to make git commits as you work. The README asked us to make at least 5 commits (1 per wave is a good start).

Comment thread src/index.js
console.log(response.data.current.weather[0]['main']);

const weather = response.data.hourly[0]['temp'];
state.temperature = Math.round(1.8*(weather-273.15)+32);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider moving this conversion code into a helper function.

Comment thread src/index.js
const findLatAndLong = () => {
console.log(state.city);
axios
.get('http://localhost:5000/location', {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider storing the unchanging part of the URL (the base URL) in a variable elsewhere, then use string interpolation to build the full path here. This would make it easier to change where all of the endpoints in the app are going by changing a single variable.

Comment thread src/index.js

let sky = '';
let skyColor = '';
if (inputSky === 'cloudy') {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Like for the temp check, each of these clauses is very repetitive. We look for a matching value to locate information about what values to set in the UI. Consider using object (key) lookups to make this more data-driven. If the values are stored elsewhere (maybe loaded from an api) then the code here would essentially reduce down to a key lookup in an object!

Comment thread src/index.js
Comment on lines +138 to +139
const inputSky = document.getElementById('changeSky').value;
const skyContainer = document.getElementById('sky');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider storing selected value in a state variable, and splitting the updating the state into a separate function from applying the state to the UI.

Comment thread src/index.js
const cityNameInput = document.getElementById('cityName');
cityNameInput.value = 'New Orleans';

updateCityName();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 Nice function reuse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants