1
1
import { Route , IndexRoute } from 'react-router' ;
2
2
import React from 'react' ;
3
+ import PropTypes from 'prop-types' ;
4
+ import MediaQuery from 'react-responsive' ;
5
+
3
6
import App from './modules/App/App' ;
4
7
import IDEView from './modules/IDE/pages/IDEView' ;
5
8
import MobileIDEView from './modules/IDE/pages/MobileIDEView' ;
@@ -24,6 +27,21 @@ const checkAuth = (store) => {
24
27
store . dispatch ( getUser ( ) ) ;
25
28
} ;
26
29
30
+ // const MobileFirstRoute = props => (
31
+ // <Route path={props.path} {...props}>
32
+ // <MediaQuery minDeviceWidth={1224}>
33
+ // {matches => (matches
34
+ // ? props.component(props)
35
+ // : props.fallback(props)) }
36
+ // </MediaQuery>
37
+ // </Route>);
38
+
39
+ // MobileFirstRoute.propTypes = {
40
+ // path: PropTypes.string.isRequired,
41
+ // component: PropTypes.any.isRequired, // eslint-disable-line
42
+ // fallback: PropTypes.any.isRequired // eslint-disable-line
43
+ // };
44
+
27
45
// TODO: This short-circuit seems unnecessary - using the mobile <Switch /> navigator (future) should prevent this from being called
28
46
const onRouteChange = ( store ) => {
29
47
const path = window . location . pathname ;
@@ -34,7 +52,16 @@ const onRouteChange = (store) => {
34
52
35
53
const routes = store => (
36
54
< Route path = "/" component = { App } onChange = { ( ) => { onRouteChange ( store ) ; } } >
37
- < IndexRoute component = { IDEView } onEnter = { checkAuth ( store ) } />
55
+ < IndexRoute
56
+ onEnter = { checkAuth ( store ) }
57
+ component = { props => (
58
+ < MediaQuery minDeviceWidth = { 1224 } >
59
+ { matches => ( matches
60
+ ? < IDEView { ...props } />
61
+ : < MobileIDEView { ...props } /> ) }
62
+ </ MediaQuery > ) }
63
+ />
64
+
38
65
< Route path = "/login" component = { userIsNotAuthenticated ( LoginView ) } />
39
66
< Route path = "/signup" component = { userIsNotAuthenticated ( SignupView ) } />
40
67
< Route path = "/reset-password" component = { userIsNotAuthenticated ( ResetPasswordView ) } />
@@ -58,10 +85,10 @@ const routes = store => (
58
85
< Route path = "/:username/collections/:collection_id" component = { CollectionView } />
59
86
< Route path = "/about" component = { IDEView } />
60
87
88
+ < Route path = "/mobile" component = { MobileIDEView } />
61
89
62
90
< Route path = "/mobile/preview" component = { MobileSketchView } />
63
91
< Route path = "/mobile/preferences" component = { MobilePreferences } />
64
- < Route path = "/mobile" component = { MobileIDEView } />
65
92
66
93
< Route path = "/mobile/:username/sketches/:project_id" component = { MobileIDEView } />
67
94
< Route path = "/mobile/:username/assets" component = { userIsAuthenticated ( userIsAuthorized ( MobileDashboardView ) ) } />
0 commit comments