From 9ff3102392e14bd51d70bbca04668465a3545af4 Mon Sep 17 00:00:00 2001 From: davlsb Date: Wed, 6 Oct 2021 12:53:07 -0400 Subject: [PATCH 1/2] Project 1 done --- zip-search/src/App.css | 43 ++++++++++++++++++++++- zip-search/src/App.js | 77 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 113 insertions(+), 7 deletions(-) diff --git a/zip-search/src/App.css b/zip-search/src/App.css index e90e8d7..3aad493 100644 --- a/zip-search/src/App.css +++ b/zip-search/src/App.css @@ -1,6 +1,47 @@ .App-header { - background-color: #222; + background-color: #6457A6; padding: 20px; color: white; text-align: center; } + +.App-Search{ + text-align: center; + padding-top: 1em; +} + +.Round-Search{ + border-radius: 15px; + background-color:#9dacff79; + border-color: transparent; + outline: none; +} + +.info-header{ + font-weight: bold; + width:100%; + padding-top: 0.5em; + text-align: center; +} + +.App-Info-Container{ + list-style-position: inside; + display: flex; + justify-content: center; + padding:1em; +} + +.Spacious{ + padding-top: 10px; +} +.content{ + padding:0.5em; + text-align: left; + padding-right: 3em; +} + +.cities{ + text-align: left; + border-radius: 10px; + box-shadow: 0 0px 2px 0 rgba(0, 0, 0, 0.274); +} diff --git a/zip-search/src/App.js b/zip-search/src/App.js index 91e9361..6b8f765 100644 --- a/zip-search/src/App.js +++ b/zip-search/src/App.js @@ -3,25 +3,90 @@ import './App.css'; function City(props) { - return (
This is the City component
); + return ( +
+
+
+
{props.locationText}
+
+
    +
  • State: {props.stateName}
  • +
  • Location: {props.location}
  • +
  • Population (estimated): {props.population}
  • +
  • Total Wages: {props.wages}
  • +
+
+
+
); } function ZipSearchField(props) { - return (
This is the ZipSearchField component
); + + return ( +
+ Zip Code: + +
); + } class App extends Component { + + constructor(props) { + super(props) + + this.state = { + zipCode: "", + cities: [], + }; + + } + saveCities = (cities) => { + this.setState({cities}) + } + + zipSearchCheck = (event) => { + + this.setState( {zipCode: event.target.value} ) + + if(event.target.value.length > 4) { + fetch("http://ctp-zip-api.herokuapp.com/zip/" + event.target.value) + .then((response) => response.json()) + .then(this.saveCities) + } + } + + render() { return ( +

Zip Code Search

- -
- - +
+ +
Current Zip is {this.state.zipCode}
+
+ + +
+ +
+ { this.state.cities.map((city) => + ) } +
); From 0cb9fe5cea4634c646e9e3076aff34e177754649 Mon Sep 17 00:00:00 2001 From: davlsb Date: Fri, 8 Oct 2021 13:47:32 -0400 Subject: [PATCH 2/2] Fixed empty zip --- zip-search/src/App.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/zip-search/src/App.js b/zip-search/src/App.js index 6b8f765..ee91cc2 100644 --- a/zip-search/src/App.js +++ b/zip-search/src/App.js @@ -26,11 +26,7 @@ function ZipSearchField(props) {
Zip Code: + />
); } @@ -55,11 +51,15 @@ class App extends Component { this.setState( {zipCode: event.target.value} ) - if(event.target.value.length > 4) { + if(event.target.value.length == 5) { fetch("http://ctp-zip-api.herokuapp.com/zip/" + event.target.value) .then((response) => response.json()) .then(this.saveCities) } + else { + this.saveCities([]); + } + }