-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #722 from Ekep-Obasi/added-signposting-for-mobile-…
…users Added signposting for mobile users
- Loading branch information
Showing
4 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions
56
src/components/App/DeviceCompatibilityNotification/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Button } from '@mui/material' | ||
import { useEffect, useState } from 'react' | ||
import styled from 'styled-components' | ||
import { Flex } from '~/components/common/Flex' | ||
import { Text } from '~/components/common/Text' | ||
import { useIsMobile } from '~/hooks/useIsMobile' | ||
|
||
export const DeviceCompatibilityNotice = () => { | ||
const [isVisible, setIsVisible] = useState(true) | ||
const isMobile = useIsMobile() | ||
|
||
useEffect(() => { | ||
setIsVisible(true) | ||
}, [isMobile]) | ||
|
||
const handleClick = () => { | ||
setIsVisible(false) | ||
} | ||
|
||
return isMobile && isVisible ? ( | ||
<Wrapper align="center" direction="column" justify="center" onClick={handleClick}> | ||
<img alt="screen" src="jamboard_kiosk.png" /> | ||
<Flex align="center" direction="column" justify="center"> | ||
<StyledText>Second Brain is currently</StyledText> | ||
<StyledText style={{ fontWeight: 600 }}>optimized for Desktop.</StyledText> | ||
<StyledText>Mobile support coming soon.</StyledText> | ||
</Flex> | ||
<Button color="secondary" onClick={handleClick} variant="contained"> | ||
Got It | ||
</Button> | ||
</Wrapper> | ||
) : null | ||
} | ||
|
||
const Wrapper = styled(Flex)` | ||
height: 100vh; | ||
width: 100vw; | ||
background: rgba(0, 0, 0, 0.75); | ||
gap: 28px; | ||
z-index: 2000000000; | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
` | ||
|
||
const StyledText = styled(Text)` | ||
color: #fff; | ||
text-align: center; | ||
font-family: Barlow; | ||
font-size: 18px; | ||
font-style: normal; | ||
font-weight: 400; | ||
line-height: 24px; | ||
margin: 1px; | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useEffect, useState } from 'react' | ||
|
||
const compatibilityBreakPoint = 620 | ||
|
||
export const useIsMobile = () => { | ||
const query = `(max-width: ${compatibilityBreakPoint}px)` | ||
|
||
const [isMobile, setIsMobile] = useState(() => { | ||
const mediaQuery = window.matchMedia(query) | ||
|
||
return mediaQuery.matches | ||
}) | ||
|
||
useEffect(() => { | ||
const mediaQuery = window.matchMedia(query) | ||
|
||
setIsMobile(mediaQuery.matches) | ||
|
||
const handleScreenResize = () => { | ||
setIsMobile(mediaQuery.matches) | ||
} | ||
|
||
window.addEventListener('resize', handleScreenResize) | ||
|
||
return () => mediaQuery.removeEventListener('change', handleScreenResize) | ||
}, [query]) | ||
|
||
return isMobile | ||
} |