Skip to content

Commit aeee8b8

Browse files
Merge pull request #94 from conveyal/refactor-a-bit
Refactor a bit
2 parents 8871ede + 15a23ec commit aeee8b8

19 files changed

+232
-174
lines changed

configurations/default/settings.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cloudfront: EJKZ46R7IC1BB
22
entries:
33
- src/index.js:assets/index.js
4-
- src/containers/indianapolis/style.css:assets/index.css
4+
- src/index.css:assets/index.css
55
env: development
66
flyle: true
77
s3bucket: taui

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
},
2525
"homepage": "https://github.com/conveyal/taui",
2626
"devDependencies": {
27-
"mastarm": "^2.0.0",
28-
"semantic-release": "^4.3.5"
27+
"mastarm": "^3.0.0",
28+
"semantic-release": "^6.3.2"
2929
},
3030
"dependencies": {
31-
"@conveyal/woonerf": "^0.2.1",
31+
"@conveyal/woonerf": "^0.3.1",
3232
"browsochrones": "^0.9.1",
3333
"color": "^0.11.1",
3434
"debug": "^2.2.0",

src/actions/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {createAction} from 'redux-actions'
55
import fetch, {
66
incrementFetches as incrementWork,
77
decrementFetches as decrementWork
8-
} from '@conveyal/woonerf/build/lib/fetch'
8+
} from '@conveyal/woonerf/fetch'
99

1010
import featureToLabel from '../utils/feature-to-label'
1111
import {setKeyTo} from '../utils/hash'

src/containers/indianapolis/index.js src/components/application.js

+8-39
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,17 @@
11
import lonlng from 'lonlng'
22
import React, {Component, PropTypes} from 'react'
3-
import {connect} from 'react-redux'
43

5-
import {
6-
clearEnd,
7-
clearIsochrone,
8-
clearStart,
9-
setBaseActive,
10-
setComparisonActive,
11-
updateDestination,
12-
updateOrigin,
13-
updateSelectedTimeCutoff
14-
} from '../../actions'
15-
import featureToLabel from '../../utils/feature-to-label'
4+
import featureToLabel from '../utils/feature-to-label'
165
import Form from './form'
17-
import Fullscreen from '../../components/fullscreen'
18-
import Icon from '../../components/icon'
19-
import Log from '../../components/log'
6+
import Fullscreen from './fullscreen'
7+
import Icon from './icon'
8+
import Log from './log'
209
import Map from './map'
21-
import messages from '../../utils/messages'
22-
import RouteCard from '../../components/route-card'
23-
import initializeBrowsochrones from '../../utils/initialize-browsochrones'
10+
import messages from '../utils/messages'
11+
import RouteCard from './route-card'
12+
import initializeBrowsochrones from '../utils/initialize-browsochrones'
2413

25-
class Indianapolis extends Component {
14+
export default class Application extends Component {
2615
static propTypes = {
2716
actionLog: PropTypes.arrayOf(PropTypes.object),
2817
browsochrones: PropTypes.object.isRequired,
@@ -245,23 +234,3 @@ class Indianapolis extends Component {
245234
)
246235
}
247236
}
248-
249-
function mapStateToProps (state, ownProps) {
250-
return state
251-
}
252-
253-
function mapDispatchToProps (dispatch, ownProps) {
254-
return {
255-
clearEnd: () => dispatch(clearEnd()),
256-
clearIsochrone: () => dispatch(clearIsochrone()),
257-
clearStart: () => dispatch(clearStart()),
258-
initializeBrowsochrones: (actions) => dispatch(actions),
259-
moveOrigin: (options) => dispatch(updateOrigin(options)),
260-
moveDestination: (options) => dispatch(updateDestination(options)),
261-
onTimeCutoffChange: (options) => dispatch(updateSelectedTimeCutoff(options)),
262-
setBaseActive: () => dispatch(setBaseActive()),
263-
setComparisonActive: () => dispatch(setComparisonActive())
264-
}
265-
}
266-
267-
export default connect(mapStateToProps, mapDispatchToProps)(Indianapolis)

src/components/deep-equal.js

-14
This file was deleted.

src/containers/indianapolis/form.js src/components/form.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
import Pure from '@conveyal/woonerf/components/pure'
12
import React from 'react'
23
import Geocoder from 'react-select-geocoder'
34

4-
import DeepEqual from '../../components/deep-equal'
5-
import featureToLabel from '../../utils/feature-to-label'
6-
import {search} from '../../utils/mapbox-geocoder'
7-
import messages from '../../utils/messages'
5+
import featureToLabel from '../utils/feature-to-label'
6+
import {search} from '../utils/mapbox-geocoder'
7+
import messages from '../utils/messages'
88

9-
export default class Form extends DeepEqual {
9+
export default class Form extends Pure {
1010
render () {
1111
const {
1212
geocoder,

src/components/fullscreen/index.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import Pure from '@conveyal/woonerf/components/pure'
12
import React from 'react'
23

3-
import {pure} from '../deep-equal'
4-
5-
const Fullscreen = (props) => <div className='Fullscreen'>{props.children}</div>
6-
7-
export default pure(Fullscreen)
4+
export default class Fullscreen extends Pure {
5+
render () {
6+
return <div className='Fullscreen'>{this.props.children}</div>
7+
}
8+
}

src/components/icon.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
import Pure from '@conveyal/woonerf/components/pure'
12
import React from 'react'
23

3-
import {pure} from './deep-equal'
4+
export default class Icon extends Pure {
5+
render () {
6+
const {
7+
className = '',
8+
type,
9+
...props
10+
} = this.props
411

5-
const Icon = ({
6-
className = '',
7-
type,
8-
...props
9-
}) =>
10-
<i
11-
className={`fa fa-${type} fa-fw ${className}`}
12-
{...props}
13-
/>
14-
15-
export default pure(Icon)
12+
return <i
13+
className={`fa fa-${type} fa-fw ${className}`}
14+
{...props}
15+
/>
16+
}
17+
}

src/components/log-item/index.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1+
import Pure from '@conveyal/woonerf/components/pure'
12
import React, {PropTypes} from 'react'
23
import moment from 'moment'
34

4-
import DeepEqual from '../deep-equal'
5-
65
const format = 'HH:mm:ss'
76

8-
export default class LogItem extends DeepEqual {
7+
export default class LogItem extends Pure {
98
static propTypes = {
109
createdAt: PropTypes.object,
1110
level: PropTypes.string,

src/components/log/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import Pure from '@conveyal/woonerf/components/pure'
12
import React, {PropTypes} from 'react'
23

3-
import DeepEqual from '../deep-equal'
44
import LogItem from '../log-item'
55

6-
export default class Log extends DeepEqual {
6+
export default class Log extends Pure {
77
static propTypes = {
88
items: PropTypes.arrayOf(PropTypes.object).isRequired
99
};

src/containers/indianapolis/map.js src/components/map.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
import Pure from '@conveyal/woonerf/components/pure'
12
import {Browser} from 'leaflet'
23
import React, {PropTypes} from 'react'
34
import {GeoJson, Map as LeafletMap, Marker, Popup, TileLayer, ZoomControl} from 'react-leaflet'
45

5-
import DeepEqual from '../../components/deep-equal'
6-
import Icon from '../../components/icon'
7-
import leafletIcon from '../../utils/leaflet-icons'
8-
import messages from '../../utils/messages'
9-
import TransitiveLayer from '../../components/transitive-map-layer'
10-
import transitiveStyle from './transitive-style'
6+
import Icon from './icon'
7+
import leafletIcon from '../utils/leaflet-icons'
8+
import messages from '../utils/messages'
9+
import TransitiveLayer from './transitive-map-layer'
10+
import transitiveStyle from '../transitive-style'
1111

1212
const startIcon = leafletIcon({
1313
icon: 'play',
@@ -19,7 +19,7 @@ const endIcon = leafletIcon({
1919
markerColor: 'orange'
2020
})
2121

22-
export default class Map extends DeepEqual {
22+
export default class Map extends Pure {
2323
static propTypes = {
2424
centerCoordinates: PropTypes.arrayOf(PropTypes.number),
2525
clearStartAndEnd: PropTypes.func.isRequired,

src/components/route-card.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
import Pure from '@conveyal/woonerf/components/pure'
12
import Color from 'color'
23
import React from 'react'
34
import toCapitalCase from 'lodash.capitalize'
45
import toSpaceCase from 'lodash.lowercase'
56
import unique from 'lodash.uniq'
67

7-
import DeepEqual from './deep-equal'
88
import Icon from './icon'
99
import messages from '../utils/messages'
1010

11-
export default class RouteCard extends DeepEqual {
11+
export default class RouteCard extends Pure {
1212
render () {
1313
const {
1414
active,

src/components/timecutoff-select.js

-32
This file was deleted.

src/containers/application.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {connect} from 'react-redux'
2+
3+
import {
4+
clearEnd,
5+
clearIsochrone,
6+
clearStart,
7+
setBaseActive,
8+
setComparisonActive,
9+
updateDestination,
10+
updateOrigin,
11+
updateSelectedTimeCutoff
12+
} from '../actions'
13+
import Application from '../components/application'
14+
15+
function mapStateToProps (state, ownProps) {
16+
return state
17+
}
18+
19+
function mapDispatchToProps (dispatch, ownProps) {
20+
return {
21+
clearEnd: () => dispatch(clearEnd()),
22+
clearIsochrone: () => dispatch(clearIsochrone()),
23+
clearStart: () => dispatch(clearStart()),
24+
initializeBrowsochrones: (actions) => dispatch(actions),
25+
moveOrigin: (options) => dispatch(updateOrigin(options)),
26+
moveDestination: (options) => dispatch(updateDestination(options)),
27+
onTimeCutoffChange: (options) => dispatch(updateSelectedTimeCutoff(options)),
28+
setBaseActive: () => dispatch(setBaseActive()),
29+
setComparisonActive: () => dispatch(setComparisonActive())
30+
}
31+
}
32+
33+
export default connect(mapStateToProps, mapDispatchToProps)(Application)
File renamed without changes.

src/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import mount from '@conveyal/woonerf/build/lib/mount'
1+
import mount from '@conveyal/woonerf/mount'
22

3-
import Indianapolis from './containers/indianapolis'
3+
import Application from './containers/application'
44
import reducers from './reducers'
55

66
mount({
7-
app: Indianapolis,
7+
app: Application,
88
reducers
99
})

src/reducers/ui.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {DECREMENT_FETCH, INCREMENT_FETCH} from '@conveyal/woonerf/build/lib/fetch'
1+
import {DECREMENT_FETCH, INCREMENT_FETCH} from '@conveyal/woonerf/fetch'
22
import {handleActions} from 'redux-actions'
33

44
export default handleActions({
File renamed without changes.

0 commit comments

Comments
 (0)