Skip to content

Commit 7dc10ab

Browse files
committed
✨make environment variable-based switch for /mobile route
1 parent 327406e commit 7dc10ab

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

client/modules/IDE/pages/IDEViewMobile.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import styled from 'styled-components';
4+
import { Link } from 'react-router';
5+
6+
import Editor from '../components/Editor';
47
import { prop, remSize } from '../../../theme';
58

69
const background = prop('Button.default.background');
@@ -34,10 +37,13 @@ Screen.propTypes = {
3437
export default () => (
3538
<Screen>
3639
<Header><h1>Mobile View</h1></Header>
40+
41+
3742
<h3>
3843
<br />This page is under construction.
39-
<br /><a href="/?ignoremobile" >Click here</a> to return to the regular editor
44+
<br /><a href="/">Click here</a> to return to the regular editor
4045
</h3>
46+
4147
<Footer><h1>Bottom Bar</h1></Footer>
4248
</Screen>
4349
);

client/routes.jsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Route, IndexRoute } from 'react-router';
22
import React from 'react';
33
import App from './modules/App/App';
4-
import IDEViewScreen from './modules/IDE/pages/IDEView';
5-
import IDEViewMobileScreen from './modules/IDE/pages/IDEViewMobile';
4+
import IDEView from './modules/IDE/pages/IDEView';
5+
import IDEViewMobile from './modules/IDE/pages/IDEViewMobile';
66
import FullView from './modules/IDE/pages/FullView';
77
import LoginView from './modules/User/pages/LoginView';
88
import SignupView from './modules/User/pages/SignupView';
@@ -25,11 +25,12 @@ const onRouteChange = (store) => {
2525
store.dispatch(stopSketch());
2626
};
2727

28-
const ignoreMobile = () => window.location.search.substring(1).includes('ignoremobile');
29-
30-
const isMobile = () => window.innerWidth <= 760;
31-
const IDEView = isMobile() && !ignoreMobile() ? IDEViewMobileScreen : IDEViewScreen;
28+
// TODO: Investigate using react-router for this switch
29+
// const ignoreMobile = () => window.location.search.substring(1).includes('ignoremobile');
30+
// const isMobile = () => window.innerWidth <= 760;
31+
// const IDEView = isMobile() && !ignoreMobile() ? IDEViewMobileScreen : IDEViewScreen;
3232

33+
// How to use URL as a prop?
3334
const routes = store => (
3435
<Route path="/" component={App} onChange={() => { onRouteChange(store); }}>
3536
<IndexRoute component={IDEView} onEnter={checkAuth(store)} />
@@ -55,6 +56,7 @@ const routes = store => (
5556
<Route path="/:username/collections/create" component={DashboardView} />
5657
<Route path="/:username/collections/:collection_id" component={CollectionView} />
5758
<Route path="/about" component={IDEView} />
59+
<Route path="/mobile" component={IDEViewMobile} />
5860

5961
</Route>
6062
);

client/theme.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,8 @@ export default {
111111
foreground: grays.light,
112112
background: grays.dark,
113113
border: grays.middleDark,
114-
115114
},
116115
},
117-
118-
119116
},
120117
[Theme.contrast]: {
121118
colors,

server/routes/server.routes.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,11 @@ router.get('/about', (req, res) => {
114114
res.send(renderIndex());
115115
});
116116

117-
router.get('/feedback', (req, res) => {
118-
res.send(renderIndex());
119-
});
117+
if (process.env.MOBILE_ENABLED) {
118+
router.get('/mobile', (req, res) => {
119+
res.send(renderIndex());
120+
});
121+
}
120122

121123
router.get('/:username/collections/create', (req, res) => {
122124
userExists(req.params.username, (exists) => {

server/views/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export function renderIndex() {
3232
window.process.env.UI_ACCESS_TOKEN_ENABLED = ${process.env.UI_ACCESS_TOKEN_ENABLED === 'false' ? false : true};
3333
window.process.env.UI_COLLECTIONS_ENABLED = ${process.env.UI_COLLECTIONS_ENABLED === 'false' ? false : true};
3434
window.process.env.UPLOAD_LIMIT = ${process.env.UPLOAD_LIMIT ? `${process.env.UPLOAD_LIMIT}` : undefined};
35+
window.process.env.MOBILE_ENABLED = ${process.env.MOBILE_ENABLED ? `${process.env.MOBILE_ENABLED}` : undefined};
3536
</script>
3637
</head>
3738
<body>

0 commit comments

Comments
 (0)