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
4
import App from './modules/App/App' ;
7
5
import IDEView from './modules/IDE/pages/IDEView' ;
@@ -22,31 +20,12 @@ import MobileDashboardView from './modules/Mobile/MobileDashboardView';
22
20
import { getUser } from './modules/User/actions' ;
23
21
import { stopSketch } from './modules/IDE/actions/ide' ;
24
22
import { userIsAuthenticated , userIsNotAuthenticated , userIsAuthorized } from './utils/auth' ;
25
- import ResponsiveForm from './modules/User/components/ResponsiveForm ' ;
23
+ import { createMobileFirst , responsiveForm } from './utils/responsive ' ;
26
24
27
25
const checkAuth = ( store ) => {
28
26
store . dispatch ( getUser ( ) ) ;
29
27
} ;
30
28
31
- const mobileEnabled = ( ) => ( window . process . env . MOBILE_ENABLED === true ) ;
32
-
33
- /** createMobileFirst: Receives the store, and creates a function that chooses between two components,
34
- * aimed at mobile and desktop resolutions, respectively.
35
- * The created function returns a Component (props => jsx)
36
- */
37
- const createMobileFirst = store => ( MobileComponent , Fallback ) => props => (
38
- < MediaQuery minDeviceWidth = { 770 } >
39
- { matches => ( ( matches || ( store && store . getState ( ) . editorAccessibility . forceDesktop ) || ( ! mobileEnabled ( ) ) )
40
- ? < Fallback { ...props } />
41
- : < MobileComponent { ...props } /> ) }
42
- </ MediaQuery > ) ;
43
-
44
- const responsiveForm = DesktopComponent => props => (
45
- < ResponsiveForm >
46
- < DesktopComponent { ...props } />
47
- </ ResponsiveForm >
48
- ) ;
49
-
50
29
// TODO: This short-circuit seems unnecessary - using the mobile <Switch /> navigator (future) should prevent this from being called
51
30
const onRouteChange = ( store ) => {
52
31
const path = window . location . pathname ;
0 commit comments