Skip to content

Commit

Permalink
added mobile warning
Browse files Browse the repository at this point in the history
  • Loading branch information
kholmogorov27 committed Mar 8, 2023
1 parent 7e41d8f commit 089a65e
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 40 deletions.
49 changes: 46 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"minisearch": "^6.0.1",
"react": "^18.2.0",
"react-colorful": "^5.6.1",
"react-device-detect": "^2.2.3",
"react-dom": "^18.2.0",
"react-fast-marquee": "^1.3.5",
"react-icons": "^4.7.1",
Expand Down
92 changes: 55 additions & 37 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ import LayoutButton from './components/LayoutButton/LayoutButton'
import { BsGearFill, BsChevronRight } from 'react-icons/bs'
import { RiMenu5Fill } from 'react-icons/ri'
import { allowedModes } from './rules'
import styles from './App.module.css'
import { isMobile } from 'react-device-detect'
import classes from './App.module.css'
import './App.css'

const ignoreMobile = localStorage.getItem('ignoreMobile')

function App() {
// settings
const settings = useContext(SettingsContext)
Expand Down Expand Up @@ -112,42 +115,57 @@ function App() {

return (
<div className='app'>
<AnimatePresence>
{
showSettings
? <Settings key='settings' onClose={() => {
setShowSettings(false)
resetStore()}}/>
:
<motion.div
key={timestamp}
onClick={() => inputRef.current && inputRef.current.focus()}
className={styles['container']}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={redirected || { opacity: 0 }}>
<ActiveElements/>
<QueryField ref={inputRef}/>
<LayoutButton
id='settings'
style={{ right: 0, top: 0 }}
onClick={() => setShowSettings(state => !state)}>
<BsGearFill/>
</LayoutButton>
<LayoutButton
id='macros-menu'
style={{ right: 0, bottom: 0 }}
onClick={switchMacrosMenu}>
{
mode === 'default' && <RiMenu5Fill/>
}
{
mode === 'opened' && <BsChevronRight/>
}
</LayoutButton>
</motion.div>
}
</AnimatePresence>
{
!isMobile || ignoreMobile
? <AnimatePresence>
{
showSettings
? <Settings key='settings' onClose={() => {
setShowSettings(false)
resetStore()}}/>
:
<motion.div
key={timestamp}
onClick={() => inputRef.current && inputRef.current.focus()}
className={classes['container']}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={redirected || { opacity: 0 }}>
<ActiveElements/>
<QueryField ref={inputRef}/>
<LayoutButton
id='settings'
style={{ right: 0, top: 0 }}
onClick={() => setShowSettings(state => !state)}>
<BsGearFill/>
</LayoutButton>
<LayoutButton
id='macros-menu'
style={{ right: 0, bottom: 0 }}
onClick={switchMacrosMenu}>
{
mode === 'default' && <RiMenu5Fill/>
}
{
mode === 'opened' && <BsChevronRight/>
}
</LayoutButton>
</motion.div>
}
</AnimatePresence>
: <div className={classes['mobile-warning']}>
<div>
Mobile devices are not supported :( <br />
<span className={classes['ignore-mobile-button']}
onClick={() => {
localStorage.setItem('ignoreMobile', true)
location.reload()
}}>
ignore this warning
</span>
</div>
</div>
}
</div>
)
}
Expand Down
16 changes: 16 additions & 0 deletions src/App.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,20 @@
margin: 0;
width: 100vw;
height: 100vh;
}

.mobile-warning {
width: 100vw;
height: 100vh;
display: flex;
flex-wrap: nowrap;
align-items: center;
justify-content: center;
}
.mobile-warning > div {
text-align: center;
}
.ignore-mobile-button {
text-decoration: underline;
cursor: pointer;
}

0 comments on commit 089a65e

Please sign in to comment.