From 6e668cda6837d1dd5d9c1bf1879fe21b972b2517 Mon Sep 17 00:00:00 2001 From: ghalestrilo Date: Thu, 30 Jul 2020 15:40:43 -0300 Subject: [PATCH] :construction: improve routing for mobile examples screen --- client/modules/App/App.jsx | 3 +- client/modules/IDE/pages/MobileIDEView.jsx | 2 +- client/modules/Mobile/MobileDashboard.jsx | 27 ++++++++++++------ client/routes.jsx | 7 +++-- server/routes/server.routes.js | 32 +++++++++++++++------- 5 files changed, 49 insertions(+), 22 deletions(-) diff --git a/client/modules/App/App.jsx b/client/modules/App/App.jsx index af441a9d..346ea411 100644 --- a/client/modules/App/App.jsx +++ b/client/modules/App/App.jsx @@ -34,7 +34,8 @@ class App extends React.Component { render() { return (
- {this.state.isMounted && !window.devToolsExtension && getConfig('NODE_ENV') === 'development' && } + {/* FIXME: remove false */} + {false && this.state.isMounted && !window.devToolsExtension && getConfig('NODE_ENV') === 'development' && } {this.props.children}
); diff --git a/client/modules/IDE/pages/MobileIDEView.jsx b/client/modules/IDE/pages/MobileIDEView.jsx index 86cd1766..dd019fab 100644 --- a/client/modules/IDE/pages/MobileIDEView.jsx +++ b/client/modules/IDE/pages/MobileIDEView.jsx @@ -48,7 +48,7 @@ const NavItem = styled.li` const headerNavOptions = [ { icon: PreferencesIcon, title: 'Preferences', href: '/mobile/preferences', }, - { icon: PreferencesIcon, title: 'Examples', href: '/mobile/examples' }, + { icon: PreferencesIcon, title: 'Examples', href: '/p5/sketches' }, { icon: PreferencesIcon, title: 'Original Editor', href: '/', }, ]; diff --git a/client/modules/Mobile/MobileDashboard.jsx b/client/modules/Mobile/MobileDashboard.jsx index adda7b59..103f02c0 100644 --- a/client/modules/Mobile/MobileDashboard.jsx +++ b/client/modules/Mobile/MobileDashboard.jsx @@ -1,6 +1,8 @@ import React, { useState } from 'react'; import PropTypes from 'prop-types'; import styled from 'styled-components'; +import { withRouter } from 'react-router'; + import Screen from '../../components/mobile/MobileScreen'; import Header from '../../components/mobile/Header'; import IconButton from '../../components/mobile/IconButton'; @@ -42,15 +44,20 @@ const FooterTabSwitcher = styled.div` `; const Panels = { - Sketches: props => , - Collections: props => , - Assets: props => + Sketches: SketchList, + Collections: CollectionList, + Assets: AssetList }; -const MobileDashboard = ({ username }) => { +const renderPanel = (name, props) => (Component => (Component && ))(Panels[name]); + + +const MobileDashboard = ({ params }) => { const Tabs = Object.keys(Panels); const [selected, selectTab] = useState(Tabs[0]); + // const username = 'p5'; + const { username } = params; const isExamples = username === EXAMPLE_USERNAME; return ( @@ -64,7 +71,7 @@ const MobileDashboard = ({ username }) => { - {Panels[selected] && Panels[selected]({ username })} + {renderPanel(selected, { username })}