Skip to content

Commit

Permalink
Refactor: Create .env file and align table to top of container
Browse files Browse the repository at this point in the history
Create `.env` file and align table to top of container
- Create `.env` file for environment variables pointing to Nasa URL's
- Align the meteorite table to the top of its contains. This prevents unwanted empty space being added before and after the table when it is filtered.

Resolves: N/a
See also: N/a
  • Loading branch information
jdmedlock committed Nov 29, 2018
1 parent 4446aa7 commit 3be329a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Meteorite Explorer Environment Variables

# Meteorite dataset from Nasa Open Data Portal
REACT_APP_METEORITE_LANDING_HOMEPAGE="https://data.nasa.gov/Space-Science/Meteorite-Landings/gh4g-9sfh"
REACT_APP_METEORITE_STRIKE_DATASET="https://data.nasa.gov/resource/y77d-th95.json"

3 changes: 2 additions & 1 deletion src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
justify-content: flex-start;
font-size: calc(10px + 2vmin);
color: white;
margin: 0px auto;
}

.App-footer {
Expand Down
8 changes: 4 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class App extends Component {
}

async componentDidMount() {
const response = await fetch("https://data.nasa.gov/resource/y77d-th95.json");
const response = await fetch(process.env.REACT_APP_METEORITE_STRIKE_DATASET);
const json = await response.json();
this.setState({ meteoriteStrikes: json });
this.setState({ isDataLoaded: true});
Expand All @@ -45,16 +45,16 @@ class App extends Component {
<section className="App-results">
<div>
{this.state.isDataLoaded ?
( <MeteoriteTable meteoriteStrikes={ this.state.meteoriteStrikes }
searchTerms={ this.state.searchTerms } /> )
( <MeteoriteTable meteoriteStrikes={ this.state.meteoriteStrikes }
searchTerms={ this.state.searchTerms } /> )
: (' ')
}
</div>
</section>

<footer className="App-footer">
<BottomBar title="Data courtesy Nasa Open Data Portal"
href="https://data.nasa.gov/Space-Science/Meteorite-Landings/gh4g-9sfh" />
href={ process.env.REACT_APP_METEORITE_LANDING_HOMEPAGE } />
</footer>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/MeteoriteTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const MeteoriteTable = (props) => {
<TableBody>
{meteoriteStrikes
.filter(strike => {
return searchTerms === '' ||
return searchTerms === '' ||
(strike.name).toLowerCase().includes(searchTerms.toLowerCase())
})
.map(strike => {
Expand Down

0 comments on commit 3be329a

Please sign in to comment.