Skip to content

Commit 19ffdd4

Browse files
committed
🚧 create editorAccessibility.forceDesktop state prop
1 parent 6e1724a commit 19ffdd4

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

client/components/Dropdown.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ Dropdown.propTypes = {
8080
items: PropTypes.arrayOf(PropTypes.shape({
8181
action: PropTypes.func,
8282
icon: PropTypes.func,
83-
href: PropTypes.string
83+
href: PropTypes.string,
84+
title: PropTypes.string
8485
})),
8586
};
8687

client/modules/IDE/pages/MobileIDEView.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ const NavItem = styled.li`
6363
position: relative;
6464
`;
6565

66-
const getNavOptions = (username = undefined) =>
66+
const getNavOptions = (username = undefined, toggleForceDesktop = () => {}) =>
6767
(username
6868
? [
6969
{ icon: PreferencesIcon, title: 'Preferences', href: '/preferences', },
7070
{ icon: PreferencesIcon, title: 'My Stuff', href: `/${username}/sketches` },
7171
{ icon: PreferencesIcon, title: 'Examples', href: '/p5/sketches' },
72-
{ icon: PreferencesIcon, title: 'Original Editor', href: '/', },
72+
{ icon: PreferencesIcon, title: 'Original Editor', action: toggleForceDesktop, },
7373
]
7474
: [
7575
{ icon: PreferencesIcon, title: 'Preferences', href: '/preferences', },
@@ -84,7 +84,8 @@ const MobileIDEView = (props) => {
8484
selectedFile, updateFileContent, files, user, params,
8585
closeEditorOptions, showEditorOptions,
8686
startRefreshSketch, stopSketch, expandSidebar, collapseSidebar, clearConsole, console,
87-
showRuntimeErrorWarning, hideRuntimeErrorWarning, startSketch, getProject, clearPersistedState, setUnsavedChanges
87+
showRuntimeErrorWarning, hideRuntimeErrorWarning, startSketch, getProject, clearPersistedState, setUnsavedChanges,
88+
toggleForceDesktop
8889
} = props;
8990

9091
const [tmController, setTmController] = useState(null); // eslint-disable-line
@@ -110,7 +111,7 @@ const MobileIDEView = (props) => {
110111

111112
// Screen Modals
112113
const [toggleNavDropdown, NavDropDown] = useAsModal(<Dropdown
113-
items={getNavOptions(username)}
114+
items={getNavOptions(username, toggleForceDesktop)}
114115
align="right"
115116
/>);
116117

@@ -287,6 +288,7 @@ MobileIDEView.propTypes = {
287288
showRuntimeErrorWarning: PropTypes.func.isRequired,
288289

289290
hideRuntimeErrorWarning: PropTypes.func.isRequired,
291+
toggleForceDesktop: PropTypes.func.isRequired,
290292

291293
user: PropTypes.shape({
292294
authenticated: PropTypes.bool.isRequired,

client/modules/IDE/reducers/editorAccessibility.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import * as ActionTypes from '../../../constants';
22

33
const initialState = {
4-
lintMessages: []
4+
lintMessages: [],
5+
forceDesktop: false
56
};
67
let messageId = 0;
78

@@ -16,6 +17,8 @@ const editorAccessibility = (state = initialState, action) => {
1617
});
1718
case ActionTypes.CLEAR_LINT_MESSAGE:
1819
return Object.assign({}, state, { lintMessages: [] });
20+
case ActionTypes.TOGGLE_FORCE_DESKTOP:
21+
return { ...state, forceDesktop: !state.forceDesktop };
1922
default:
2023
return state;
2124
}

client/routes.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ const checkAuth = (store) => {
2727
store.dispatch(getUser());
2828
};
2929

30-
const mobileFirst = (MobileComponent, Fallback) => props => (
30+
const mobileFirst = (MobileComponent, Fallback, store) => props => (
3131
<MediaQuery minDeviceWidth={770}>
32-
{matches => (matches
32+
{matches => ((matches && (!store || store.getState().editorAccessibility.forceDesktop))
3333
? <Fallback {...props} />
3434
: <MobileComponent {...props} />)}
3535
</MediaQuery>);

0 commit comments

Comments
 (0)