2017-02-20 18:15:36 +02:00
|
|
|
import React from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { Switch, Route } from 'react-router-dom';
|
|
|
|
import { injectGlobal } from 'styled-components';
|
|
|
|
import { updateRouter } from '@state/actions';
|
|
|
|
import Article from '@components/article';
|
|
|
|
import Base from '@ui/components/base';
|
|
|
|
import BaselineGrid from '@ui/components/baseline-grid';
|
|
|
|
import Footer from '@components/footer';
|
|
|
|
import Header from '@containers/header';
|
|
|
|
import Home from '@containers/home';
|
|
|
|
import NotFound from '@containers/not-found';
|
|
|
|
import Nav from '@components/navigation';
|
|
|
|
import OrgNavigation from '@components/navigation/org';
|
2016-12-13 16:35:39 +02:00
|
|
|
|
2016-10-20 04:14:26 +03:00
|
|
|
const App = connect()(React.createClass({
|
2016-12-14 00:09:04 +02:00
|
|
|
displayName: 'App',
|
2016-10-25 22:15:33 +03:00
|
|
|
propTypes: {
|
|
|
|
children: React.PropTypes.node,
|
|
|
|
dispatch: React.PropTypes.func,
|
|
|
|
router: React.PropTypes.object
|
|
|
|
},
|
2016-10-20 04:14:26 +03:00
|
|
|
componentWillMount: function() {
|
|
|
|
const {
|
|
|
|
router,
|
|
|
|
dispatch
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
// ugly hack needed because of a limitation of react-router api
|
|
|
|
// that doens't pass it's instance to matched routes
|
2016-10-20 22:42:39 +03:00
|
|
|
// wait for react-router-redux@5
|
2016-10-20 04:14:26 +03:00
|
|
|
dispatch(updateRouter(router));
|
2016-12-13 16:35:39 +02:00
|
|
|
|
|
|
|
injectGlobal`
|
|
|
|
${Base.global}
|
|
|
|
`;
|
2016-10-20 04:14:26 +03:00
|
|
|
},
|
|
|
|
render: function() {
|
|
|
|
const {
|
|
|
|
children
|
|
|
|
} = this.props;
|
|
|
|
|
2017-02-01 14:35:25 +02:00
|
|
|
let _children = children;
|
|
|
|
|
|
|
|
if (!Array.isArray(_children)) {
|
|
|
|
return _children;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV !== 'production' && process.env.BASELINE_GRID) {
|
|
|
|
_children = (
|
|
|
|
<BaselineGrid>
|
|
|
|
{_children}
|
|
|
|
</BaselineGrid>
|
|
|
|
);
|
2016-10-20 04:14:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2016-12-13 16:35:39 +02:00
|
|
|
<Base>
|
2017-02-01 14:35:25 +02:00
|
|
|
{_children}
|
2016-12-13 16:35:39 +02:00
|
|
|
</Base>
|
2016-10-20 04:14:26 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
2017-02-20 18:15:36 +02:00
|
|
|
export default (props) => (
|
2017-02-06 20:27:10 +02:00
|
|
|
<App {...props}>
|
|
|
|
<Header />
|
2017-02-20 18:15:36 +02:00
|
|
|
<Nav name='application-org-navigation'>
|
2017-02-06 20:27:10 +02:00
|
|
|
<OrgNavigation />
|
|
|
|
</Nav>
|
2017-02-20 18:15:36 +02:00
|
|
|
<Article name='application-content'>
|
2017-02-06 20:27:10 +02:00
|
|
|
<Switch>
|
|
|
|
<Route component={Home} path='/:org?/:section?' />
|
|
|
|
<Route component={NotFound} />
|
|
|
|
</Switch>
|
|
|
|
</Article>
|
2017-02-20 18:15:36 +02:00
|
|
|
<Footer name='application-footer' />
|
2017-02-06 20:27:10 +02:00
|
|
|
</App>
|
|
|
|
);
|