2020-08-21 20:09:20 +00:00
|
|
|
import React from 'react';
|
2020-08-21 21:07:41 +00:00
|
|
|
import { useSelector } from 'react-redux';
|
2020-08-21 20:09:20 +00:00
|
|
|
import MediaQuery from 'react-responsive';
|
|
|
|
import ResponsiveForm from '../modules/User/components/ResponsiveForm';
|
|
|
|
|
|
|
|
export const mobileEnabled = () => (window.process.env.MOBILE_ENABLED === true);
|
|
|
|
|
2020-08-21 21:10:17 +00:00
|
|
|
export const mobileFirst = (MobileComponent, Fallback) => (props) => {
|
2020-08-21 21:07:41 +00:00
|
|
|
const { forceDesktop } = useSelector(state => state.editorAccessibility);
|
|
|
|
return (
|
|
|
|
<MediaQuery minWidth={770}>
|
2020-08-21 21:10:17 +00:00
|
|
|
{matches => ((matches || forceDesktop || (!mobileEnabled()))
|
2020-08-21 21:07:41 +00:00
|
|
|
? <Fallback {...props} />
|
|
|
|
: <MobileComponent {...props} />)}
|
|
|
|
</MediaQuery>
|
|
|
|
);
|
|
|
|
};
|
2020-08-21 20:09:20 +00:00
|
|
|
|
|
|
|
export const responsiveForm = DesktopComponent => props => (
|
|
|
|
<ResponsiveForm>
|
|
|
|
<DesktopComponent {...props} />
|
|
|
|
</ResponsiveForm>
|
|
|
|
);
|