diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-08-30 16:18:21 -0700 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2023-08-30 16:18:21 -0700 |
commit | f9cab178b9ee2a0ccfde7e0e2cbabff7600de69c (patch) | |
tree | c8609bd39cad46a232153a3d3a598ed1b667a027 /src/view/com/util/layouts/withBreakpoints.tsx | |
parent | 9446c67880331452b3f79dabda183c23718edfa1 (diff) | |
parent | 59dcedeea25804188b3503dbf166fa794af20612 (diff) | |
download | voidsky-f9cab178b9ee2a0ccfde7e0e2cbabff7600de69c.tar.zst |
Merge branch 'ansh/app-812-add-custom-feed-discovery-to-onboarding' into main
Diffstat (limited to 'src/view/com/util/layouts/withBreakpoints.tsx')
-rw-r--r-- | src/view/com/util/layouts/withBreakpoints.tsx | 21 |
1 files changed, 21 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..dc3f50dc9 --- /dev/null +++ b/src/view/com/util/layouts/withBreakpoints.tsx @@ -0,0 +1,21 @@ +import React from 'react' +import {isNative} from 'platform/detection' +import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' + +export const withBreakpoints = + <P extends object>( + Mobile: React.ComponentType<P>, + Tablet: React.ComponentType<P>, + Desktop: React.ComponentType<P>, + ): React.FC<P> => + (props: P) => { + const {isMobile, isTabletOrMobile} = useWebMediaQueries() + + if (isMobile || isNative) { + return <Mobile {...props} /> + } + if (isTabletOrMobile) { + return <Tablet {...props} /> + } + return <Desktop {...props} /> + } |