-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added react-router-dom, spun out Home, LocationInput, Forecast compon…
…ents
- Loading branch information
Showing
7 changed files
with
206 additions
and
71 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React, { Component } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
class Forecast extends React.Component { | ||
render() { | ||
return ( | ||
<div className="container"> | ||
Forecast Component | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export default Forecast; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React, { Component } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import PropTypes from 'prop-types'; | ||
import api from './utils/api'; | ||
|
||
class Home extends Component { | ||
render() { | ||
return ( | ||
<div className="container"> | ||
<h1 className="text-center">Enter a City and State</h1> | ||
<LocationInput | ||
style={{flexDirection: "column"}} | ||
onSubmit={this.handleSubmit} | ||
/> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export default Home; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React, { Component } from 'react'; | ||
import api from './utils/api'; | ||
|
||
class LocationInput extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
location: '', | ||
}; | ||
|
||
this.handleChange = this.handleChange.bind(this); | ||
this.handleSubmit = this.handleSubmit.bind(this); | ||
} | ||
handleChange(event) { | ||
var value = event.target.value; | ||
|
||
this.setState(_ => { | ||
return { | ||
location: value, | ||
} | ||
}); | ||
} | ||
handleSubmit(event) { | ||
event.preventDefault(); | ||
|
||
this.props.onSubmit( | ||
this.state.location, | ||
); | ||
} | ||
render() { | ||
return ( | ||
<div className="loc-container"> | ||
<form className="getweather" onSubmit={this.handleSubmit} style={this.props.style}> | ||
<input | ||
id="location" | ||
placeholder="San Francisco, CA" | ||
type="text" | ||
className="locinput" | ||
autoComplete="off" | ||
value={this.state.location} | ||
onChange={this.handleChange} | ||
/> | ||
<button | ||
className="btn" | ||
type="submit" | ||
disabled={!this.state.location}> | ||
Get Weather | ||
</button> | ||
</form> | ||
|
||
</div> | ||
) | ||
} | ||
} | ||
|
||
// LocationInput.propTypes = { | ||
// location: PropTypes.string.isRequired, | ||
// } | ||
|
||
export default LocationInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters