Skip to content

Commit ddc95fa

Browse files
committed
🚧 switch index page manually
1 parent 8308eda commit ddc95fa

File tree

3 files changed

+60
-4
lines changed

3 files changed

+60
-4
lines changed

client/routes.jsx

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { Route, IndexRoute } from 'react-router';
22
import React from 'react';
3+
import PropTypes from 'prop-types';
4+
import MediaQuery from 'react-responsive';
5+
36
import App from './modules/App/App';
47
import IDEView from './modules/IDE/pages/IDEView';
58
import MobileIDEView from './modules/IDE/pages/MobileIDEView';
@@ -24,6 +27,21 @@ const checkAuth = (store) => {
2427
store.dispatch(getUser());
2528
};
2629

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+
2745
// TODO: This short-circuit seems unnecessary - using the mobile <Switch /> navigator (future) should prevent this from being called
2846
const onRouteChange = (store) => {
2947
const path = window.location.pathname;
@@ -34,7 +52,16 @@ const onRouteChange = (store) => {
3452

3553
const routes = store => (
3654
<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+
3865
<Route path="/login" component={userIsNotAuthenticated(LoginView)} />
3966
<Route path="/signup" component={userIsNotAuthenticated(SignupView)} />
4067
<Route path="/reset-password" component={userIsNotAuthenticated(ResetPasswordView)} />
@@ -58,10 +85,10 @@ const routes = store => (
5885
<Route path="/:username/collections/:collection_id" component={CollectionView} />
5986
<Route path="/about" component={IDEView} />
6087

88+
<Route path="/mobile" component={MobileIDEView} />
6189

6290
<Route path="/mobile/preview" component={MobileSketchView} />
6391
<Route path="/mobile/preferences" component={MobilePreferences} />
64-
<Route path="/mobile" component={MobileIDEView} />
6592

6693
<Route path="/mobile/:username/sketches/:project_id" component={MobileIDEView} />
6794
<Route path="/mobile/:username/assets" component={userIsAuthenticated(userIsAuthorized(MobileDashboardView))} />

package-lock.json

Lines changed: 30 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@
201201
"react-hot-loader": "^4.12.19",
202202
"react-i18next": "^11.5.0",
203203
"react-redux": "^7.2.0",
204+
"react-responsive": "^8.1.0",
204205
"react-router": "^3.2.5",
205206
"react-split-pane": "^0.1.89",
206207
"react-tabs": "^2.3.1",

0 commit comments

Comments
 (0)