-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #173 from flacoman91/per-capita
Per capita
- Loading branch information
Showing
21 changed files
with
844 additions
and
147 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
@import (less) "base.less"; | ||
|
||
.date-intervals { | ||
width: 100%; | ||
float: left; | ||
p { | ||
display: block; | ||
} | ||
.date-selector { | ||
background-color: @pacific-40; | ||
&.selected { | ||
background-color: @pacific-80; | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -13,4 +13,10 @@ | |
h2 { | ||
padding: @gutter-normal; | ||
} | ||
} | ||
|
||
.refine { | ||
section { | ||
margin: 10px; | ||
} | ||
} | ||
} |
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,33 @@ | ||
import './PerCapita.less' | ||
import { GEO_NORM_NONE, GEO_NORM_PER1000 } from './constants' | ||
import { connect } from 'react-redux' | ||
import { dataNormalizationChanged } from './actions/map'; | ||
import React from 'react' | ||
|
||
|
||
export class PerCapita extends React.Component { | ||
render() { | ||
return ( | ||
<section className="per-capita"> | ||
<p>Map Shading</p> | ||
<select value={this.props.dataNormalization} | ||
onChange={this.props.onDataNormalization}> | ||
<option value={GEO_NORM_NONE}>Complaints</option> | ||
<option value={GEO_NORM_PER1000}>Per capita</option> | ||
</select> | ||
</section> | ||
) | ||
} | ||
} | ||
|
||
export const mapStateToProps = state => ( { | ||
dataNormalization: state.map.dataNormalization | ||
} ); | ||
|
||
export const mapDispatchToProps = dispatch => ( { | ||
onDataNormalization: ev => { | ||
dispatch( dataNormalizationChanged( ev.target.value ) ) | ||
} | ||
} ); | ||
|
||
export default connect( mapStateToProps, mapDispatchToProps )( PerCapita ) |
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,13 @@ | ||
@import (less) "base.less"; | ||
|
||
.per-capita { | ||
p { | ||
display: block; | ||
} | ||
.date-selector { | ||
background-color: @pacific-40; | ||
&.selected { | ||
background-color: @pacific-80; | ||
} | ||
} | ||
} |
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
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,60 @@ | ||
import configureMockStore from 'redux-mock-store' | ||
import { | ||
mapDispatchToProps, mapStateToProps, PerCapita | ||
} from '../PerCapita' | ||
import { Provider } from 'react-redux' | ||
import React from 'react' | ||
import renderer from 'react-test-renderer' | ||
import { shallow } from 'enzyme' | ||
import thunk from 'redux-thunk' | ||
|
||
function setupSnapshot() { | ||
const middlewares = [ thunk ] | ||
const mockStore = configureMockStore( middlewares ) | ||
const store = mockStore( { | ||
map: {} | ||
} ) | ||
|
||
return renderer.create( | ||
<Provider store={ store }> | ||
<PerCapita /> | ||
</Provider> | ||
) | ||
} | ||
|
||
describe( 'component: PerCapita', () => { | ||
describe( 'initial state', () => { | ||
it( 'renders without crashing', () => { | ||
const target = setupSnapshot() | ||
let tree = target.toJSON() | ||
expect( tree ).toMatchSnapshot() | ||
} ) | ||
} ) | ||
|
||
describe('mapDispatchToProps', () => { | ||
it('hooks into onDataNormalization', () => { | ||
const dispatch = jest.fn(); | ||
const ev = { | ||
target: { | ||
value: 123 | ||
} | ||
} | ||
mapDispatchToProps(dispatch).onDataNormalization( ev ); | ||
expect(dispatch.mock.calls.length).toEqual(1); | ||
}) | ||
}) | ||
|
||
describe( 'mapStateToProps', () => { | ||
it( 'maps state and props', () => { | ||
const state = { | ||
map: { | ||
dataNormalization: 'foo' | ||
} | ||
} | ||
let actual = mapStateToProps( state ) | ||
expect( actual ).toEqual( { dataNormalization: 'foo' } ) | ||
} ) | ||
} ) | ||
|
||
|
||
} ) |
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
Oops, something went wrong.