-
Notifications
You must be signed in to change notification settings - Fork 314
/
Copy pathmain.jsx
115 lines (96 loc) · 2.85 KB
/
main.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import React, {PropTypes, Component} from 'react/addons';
import shouldPureComponentUpdate from 'react-pure-render/function';
import * as routeNames from 'actions/user_routes.js';
import {examples} from 'consts/example_defs.js';
import {Connector} from 'redux/react';
import MainMapPage from './examples/x_main/main_map_page.jsx';
import SimpleMapPage from './examples/x_simple/simple_map_page.jsx';
import OptionsMapPage from './examples/x_options/options_map_page.jsx';
import SimpleHoverMapPage from './examples/x_simple_hover/simple_hover_map_page.jsx';
import DistanceHoverMapPage from './examples/x_distance_hover/distance_hover_map_page.jsx';
import EventsMapPage from './examples/x_events/events_map_page.jsx';
import Page from './page.jsx';
export default class Main extends Component {
static propTypes = {
routeName: PropTypes.string.isRequired,
routePath: PropTypes.string.isRequired,
routeFullPath: PropTypes.string.isRequired,
routeParams: PropTypes.any.isRequired
}
shouldComponentUpdate = shouldPureComponentUpdate;
constructor(props) {
super(props);
}
_selectExample(exampleName, props) {
switch (exampleName) {
case examples.main:
return (
<MainMapPage />
);
case examples.balderdash:
return (
<MainMapPage layout="R" />
);
case examples.simple:
return (
<SimpleMapPage />
);
case examples.options:
return (
<OptionsMapPage />
);
case examples.simple_hover:
return (
<SimpleHoverMapPage />
);
case examples.distance_hover:
return (
<DistanceHoverMapPage />
);
case examples.events:
return (
<EventsMapPage />
);
default:
return (
<div>
<h3>404 example not found</h3>
<div>{this._renderPathProps(props)}</div>
</div>
);
}
}
_renderMain(props) {
switch (props.routePath) {
case routeNames.K_DEFAULT_ROUTE:
return (
<div>K_DEFAULT_ROUTE</div>
);
case routeNames.K_MAP_ROUTE:
return this._selectExample(props.routeParams.example, props);
default:
return (
<div>
<h3>404 page not found</h3>
<div>{this._renderPathProps(props)}</div>
</div>
);
}
}
_renderPathProps(props) {
return (
<div>{/*routeName: {props.routeName}, routePath: {props.routePath}, routeFullPath: {props.routeFullPath}, routeParams: {props.routeParams.toString()} */}</div>
);
}
render() {
const main = this._renderMain(this.props);
return (
<Connector select={state => ({ example: state.example })}>
{({example}) =>
<Page example={example}>
{main}
</Page>}
</Connector>
);
}
}