make forceDesktop work

This commit is contained in:
ghalestrilo 2020-08-21 18:07:41 -03:00
parent 36670f72fd
commit f4d654a08f

View file

@ -1,20 +1,24 @@
import React from 'react'; import React from 'react';
import { useSelector } from 'react-redux';
import MediaQuery from 'react-responsive'; import MediaQuery from 'react-responsive';
import ResponsiveForm from '../modules/User/components/ResponsiveForm'; import ResponsiveForm from '../modules/User/components/ResponsiveForm';
export const mobileEnabled = () => (window.process.env.MOBILE_ENABLED === true); export const mobileEnabled = () => (window.process.env.MOBILE_ENABLED === true);
/** createMobileFirst: Receives the store, and creates a function that chooses between two components, /** createMobileFirst: Receives the store, and creates a function that chooses between two components,
* aimed at mobile and desktop resolutions, respectively. * aimed at mobile and desktop resolutions, respectively.
* The created function returns a Component (props => jsx) * The created function returns a Component (props => jsx)
*/ */
export const createMobileFirst = store => (MobileComponent, Fallback) => props => ( export const createMobileFirst = store => (MobileComponent, Fallback) => (props) => {
<MediaQuery minWidth={770}> const { forceDesktop } = useSelector(state => state.editorAccessibility);
{matches => ((matches || (store && store.getState().editorAccessibility.forceDesktop) || (!mobileEnabled())) return (
? <Fallback {...props} /> <MediaQuery minWidth={770}>
: <MobileComponent {...props} />)} {matches => ((matches || (store && forceDesktop) || (!mobileEnabled()))
</MediaQuery>); ? <Fallback {...props} />
: <MobileComponent {...props} />)}
</MediaQuery>
);
};
export const responsiveForm = DesktopComponent => props => ( export const responsiveForm = DesktopComponent => props => (
<ResponsiveForm> <ResponsiveForm>