-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathLayout.js
53 lines (44 loc) · 964 Bytes
/
Layout.js
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
import h from 'react-hyperscript'
import { compose } from 'recompose'
import { connect as connectFela } from 'react-fela'
import { Route, Switch } from 'react-router-dom'
import { pipe, map, values, isNil } from 'ramda'
import styles from '../styles/Layout'
import Navigation from './Navigation'
export default compose(
connectFela(styles)
)(Layout)
function Layout (props) {
const { styles, routes, navigationRoutes } = props
return (
h('div', {
className: styles.container
}, [
h(Navigation, { navigationRoutes }),
h('div', {
className: styles.wrapper
}, [
h(Switch, {}, [
mapRoutePages(routes)
])
])
])
)
}
const mapRoutePages = map(route => {
const {
path,
exact,
Component
} = route
if (isNil(Component)) return null
const key = path || '404'
return (
h(Route, {
path,
key,
exact,
component: Component
})
)
})