@@ -2,15 +2,13 @@ import 'babel-polyfill';
22import React , { Component , PropTypes } from 'react' ;
33import { connect } from 'react-redux' ;
44import autobind from 'autobind-decorator' ;
5- import MapGL from 'react-map-gl' ;
65
7- import MarkdownPage from '../components/markdown-page' ;
8- import GenericInput from './input' ;
9- import * as Demos from './demos' ;
6+ import Map from './map' ;
7+ import InfoPanel from './info-panel' ;
8+ import MarkdownPage from './markdown-page' ;
9+ import Demos from './demos' ;
1010import * as appActions from '../actions/app-actions' ;
1111import ViewportAnimation from '../utils/map-utils' ;
12- import { MAPBOX_STYLES } from '../constants/defaults' ;
13- import MAPBOX_ACCESS_TOKEN from '../constants/mapbox-token' ;
1412
1513class Page extends Component {
1614 constructor ( props ) {
@@ -65,12 +63,6 @@ class Page extends Component {
6563 return content ;
6664 }
6765
68- @autobind
69- _onUpdateMap ( viewport ) {
70- this . setState ( { mapFocus : true } ) ;
71- this . props . updateMap ( viewport ) ;
72- }
73-
7466 @autobind
7567 _resizeMap ( ) {
7668 const w = window . innerWidth ;
@@ -81,56 +73,19 @@ class Page extends Component {
8173 } ) ;
8274 }
8375
76+ @autobind
77+ _setMapFocus ( state ) {
78+ this . setState ( { mapFocus : state } ) ;
79+ }
80+
8481 _setActiveTab ( tabName ) {
8582 const { location : { pathname} } = this . props ;
8683 this . context . router . replace ( `${ pathname } ?tab=${ tabName } ` ) ;
8784 }
8885
89- _renderMap ( ) {
90- const { viewport, vis : { params, owner, data} , updateMeta} = this . props ;
91- const { tabs : { demo} } = this . state ;
92- const DemoComponent = Demos [ demo ] ;
93- const dataLoaded = owner === demo ? data : null ;
94-
95- return (
96- < MapGL
97- mapboxApiAccessToken = { MAPBOX_ACCESS_TOKEN }
98- perspectiveEnabled = { true }
99- { ...viewport }
100- onChangeViewport = { this . _onUpdateMap } >
101-
102- < DemoComponent ref = "demo" viewport = { viewport } params = { params }
103- onStateChange = { updateMeta }
104- data = { dataLoaded } />
105-
106- </ MapGL >
107- )
108- }
109-
110- _renderOptions ( ) {
111- const { vis : { params, owner, meta} } = this . props ;
112- const { tabs : { demo} , mapFocus} = this . state ;
113- const DemoComponent = Demos [ demo ] ;
114- const metaLoaded = owner === demo ? meta : { } ;
115-
116- return (
117- < div className = { `options-panel top-right ${ mapFocus ? '' : 'focus' } ` }
118- onClick = { ( ) => this . setState ( { mapFocus : false } ) } >
119- { DemoComponent . renderInfo ( metaLoaded ) }
120- { Object . keys ( params ) . length > 0 && < hr /> }
121- {
122- Object . keys ( params ) . map ( ( name , i ) => (
123- < GenericInput key = { i } name = { name } { ...params [ name ] }
124- onChange = { this . props . updateParam } />
125- ) )
126- }
127- </ div >
128- ) ;
129- }
130-
13186 _renderTabContent ( tabName , tab ) {
13287 const { contents, location} = this . props ;
133- const { tabs} = this . state ;
88+ const { tabs, mapFocus } = this . state ;
13489 const activeTab = location . query . tab || Object . keys ( tabs ) [ 0 ] ;
13590
13691 return Object . keys ( tabs ) . map ( tabName => {
@@ -140,8 +95,10 @@ class Page extends Component {
14095 if ( tabName === 'demo' ) {
14196 child = (
14297 < div >
143- { this . _renderMap ( ) }
144- { this . _renderOptions ( ) }
98+ < Map demo = { tab }
99+ onInteract = { this . _setMapFocus . bind ( this , true ) } />
100+ < InfoPanel demo = { tab } hasFocus = { ! mapFocus }
101+ onInteract = { this . _setMapFocus . bind ( this , false ) } />
145102 </ div >
146103 )
147104 } else if ( typeof tab === 'string' ) {
0 commit comments