Skip to content

Commit

Permalink
UI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
caseycesari committed May 24, 2016
1 parent 432b28a commit 3c874df
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 29 deletions.
3 changes: 2 additions & 1 deletion src/css/app.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
body {
padding-top: 50px;
padding-top: 70px;
padding-bottom: 30px;
}
5 changes: 2 additions & 3 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="css/app.css">
</head>
<body>
<div id="app" class="container">
</div>
<body role="document">
<div id="app"></div>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
Expand Down
5 changes: 3 additions & 2 deletions src/js/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ export default class App extends Component {
return (
<div>
<Header />
<h1>eBird Hotspot Viewer</h1>
{content}
<div className="container" role="main">
{content}
</div>
</div>
);
}
Expand Down
20 changes: 13 additions & 7 deletions src/js/components/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ import { Link } from 'react-router';

export default function App() {
return (
<Link
to="/hotspots"
type="button"
className="btn btn-primary"
>
View nearby hotspots
</Link>
<div className="jumbotron">
<h1>eBird Hotspot Viewer</h1>
<p>View observations from the last two weeks at nearby hotspots</p>
<p>
<Link
to="/hotspots"
type="button"
className="btn btn-primary"
>
View nearby hotspots
</Link>
</p>
</div>
);
}
5 changes: 3 additions & 2 deletions src/js/components/HotspotList.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class HotspotList extends Component {
if ((this.state.location.lat && this.state.location.lng) &&
(!this.state.hotspots || this.state.hotspots.length === 0)) {
$.ajax({
url: `http://ebird.org/ws1.1/ref/hotspot/geo?dist=${10}&lat=${this.state.location.lat}&lng=${this.state.location.lng}&fmt=json`,
url: `http://ebird.org/ws1.1/ref/hotspot/geo?dist=${10}&back=${14}&lat=${this.state.location.lat}&lng=${this.state.location.lng}&fmt=json`,
dataType: 'json',
cache: false,
success: data => {
Expand All @@ -58,7 +58,7 @@ export default class HotspotList extends Component {
render() {
let content = <Loading message={'Loading nearby hotspots...'} />;

if (this.state.hotspots) {
if (this.state.hotspots && this.state.hotspots.length !== 0) {
content = this.state.hotspots.map(h =>
<Hotspot
key={h.locID}
Expand All @@ -70,6 +70,7 @@ export default class HotspotList extends Component {

return (
<div>
<h3>Nearby hotspots</h3>
<ul className="list-group">{content}</ul>
</div>
);
Expand Down
9 changes: 6 additions & 3 deletions src/js/components/Sighting.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import React, { PropTypes } from 'react';

const propTypes = {
obsDt: PropTypes.string,
comName: PropTypes.string,
howMany: PropTypes.number,
};

export default function Sighting(props) {
return (
<li className="list-group-item">
<span>{props.comName}, {props.howMany}</span>
</li>
<tr>
<td>{props.obsDt}</td>
<td>{props.comName}</td>
<td>{props.howMany}</td>
</tr>
);
}

Expand Down
42 changes: 31 additions & 11 deletions src/js/components/SightingsList.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { Component, PropTypes } from 'react';
import Sighting from './Sighting.js';
import { Actions } from '../actions/Actions';
import { Link } from 'react-router';
import $ from 'jquery';

import { Actions } from '../actions/Actions';
import { Store } from '../stores/Store';
import $ from 'jquery';
import Sighting from './Sighting.js';
import Loading from './Loading';

function getState() {
return {
Expand Down Expand Up @@ -55,22 +56,41 @@ export default class SightingsList extends Component {
Actions.setHotspotId(undefined);
}


render() {
let content = '';
let content = <Loading message={'Fetching recent observations...'} />;
let title = '';

if (this.state.sightings) {
content = this.state.sightings.map(s =>
<Sighting key={Math.random()} comName={s.comName} howMany={s.howMany} />
title = this.state.sightings[0].locName;
let sightings = this.state.sightings.map(s =>
<Sighting
key={Math.random()}
obsDt={s.obsDt}
comName={s.comName}
howMany={s.howMany}
/>
);
content = (
<table className="table table-hover table-responsive">
<tbody>
<tr>
<th>Date</th>
<th>Species</th>
<th>Count</th>
</tr>
{sightings}
</tbody>
</table>
);
} else if (this.state.sightings && this.state.sightings.length === 0) {
content = <em>No recent sightings</em>;
}

return (
<div>
<Link to="/hotspots" onClick={this.setHotspotId}>&larr; Back to hotspot list</Link>
<div>
<strong>{this.props.params.hotspotId}</strong>
</div>
{content}
<h3>{title}</h3>
{content}
</div>
);
}
Expand Down

0 comments on commit 3c874df

Please sign in to comment.