about summary refs log tree commit diff
path: root/src/view/com/util/layouts/withBreakpoints.tsx
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-08-30 14:57:03 -0700
committerPaul Frazee <pfrazee@gmail.com>2023-08-30 14:57:03 -0700
commit05d1d8d8a4565e7d042f8c09760186b4037dcd2f (patch)
treee103178d643356dbe06fbaa9867e8a0dbff272a3 /src/view/com/util/layouts/withBreakpoints.tsx
parentcd8ae1298e6ef67e5c40cdde24449b49ae2d914b (diff)
downloadvoidsky-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.tsx22
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} />
+  }