forked from fullstackreact/google-maps-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainer.js
More file actions
83 lines (72 loc) · 2.14 KB
/
Container.js
File metadata and controls
83 lines (72 loc) · 2.14 KB
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
import React from 'react'
import PropTypes from 'prop-types'
import ReactDOM from 'react-dom'
import {Link} from 'react-router'
import GitHubForkRibbon from 'react-github-fork-ribbon'
let GoogleApiWrapper;
if (__IS_DEV__) {
GoogleApiWrapper = require('../src/index').GoogleApiWrapper
} else {
GoogleApiWrapper = require('../dist').GoogleApiWrapper
}
import styles from './styles.module.css'
export const Container = React.createClass({
propTypes: {
children: PropTypes.element.isRequired
},
contextTypes: {
router: PropTypes.object
},
renderChildren: function() {
const {children} = this.props;
if (!children) return;
const sharedProps = {
google: this.props.google,
loaded: this.props.loaded
}
return React.Children.map(children, c => {
return React.cloneElement(c, sharedProps, {
});
})
},
render: function() {
const {routeMap, routeDef} = this.props;
const {router} = this.context;
const c = this.renderChildren();
return (
<div className={styles.container}>
<GitHubForkRibbon href="//github.com/fullstackreact/google-maps-react"
target="_blank"
position="right">
Fork me on GitHub
</GitHubForkRibbon>
<div className={styles.wrapper}>
<div className={styles.list}>
<ul>
{Object.keys(routeMap).map(key => {
return (
<Link to={key}
activeClassName={styles.active}
key={key}>
<li>{routeMap[key].name}</li>
</Link>
)
})}
</ul>
</div>
<div className={styles.content}>
<div className={styles.header}>
<h1>{routeDef && routeDef.name} Example</h1>
<h2><a href="https://github.com/fullstackreact/google-maps-react/blob/master/README.md">Readme</a></h2>
</div>
{c}
</div>
</div>
</div>
)
}
})
export default GoogleApiWrapper({
apiKey: __GAPI_KEY__,
libraries: ['places','visualization']
})(Container)