diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-08-30 14:57:03 -0700 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2023-08-30 14:57:03 -0700 |
commit | 05d1d8d8a4565e7d042f8c09760186b4037dcd2f (patch) | |
tree | e103178d643356dbe06fbaa9867e8a0dbff272a3 /src/view/com/util/layouts/withBreakpoints.tsx | |
parent | cd8ae1298e6ef67e5c40cdde24449b49ae2d914b (diff) | |
download | voidsky-05d1d8d8a4565e7d042f8c09760186b4037dcd2f.tar.zst |
Fix onboarding on mobile web
Diffstat (limited to 'src/view/com/util/layouts/withBreakpoints.tsx')
-rw-r--r-- | src/view/com/util/layouts/withBreakpoints.tsx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/view/com/util/layouts/withBreakpoints.tsx b/src/view/com/util/layouts/withBreakpoints.tsx new file mode 100644 index 000000000..4214c1040 --- /dev/null +++ b/src/view/com/util/layouts/withBreakpoints.tsx @@ -0,0 +1,22 @@ +import React from 'react' +import {useMediaQuery} from 'react-responsive' +import {isNative} from 'platform/detection' + +export const withBreakpoints = + <P extends object>( + Mobile: React.ComponentType<P>, + Tablet: React.ComponentType<P>, + Desktop: React.ComponentType<P>, + ): React.FC<P> => + (props: P) => { + const isTabletOrMobile = useMediaQuery({query: '(max-width: 1224px)'}) + const isMobile = useMediaQuery({query: '(max-width: 800px)'}) + + if (isMobile || isNative) { + return <Mobile {...props} /> + } + if (isTabletOrMobile) { + return <Tablet {...props} /> + } + return <Desktop {...props} /> + } |