Initial Mobile UI
All checks were successful
Automated Container Build / build-and-push (push) Successful in 40s
All checks were successful
Automated Container Build / build-and-push (push) Successful in 40s
This commit is contained in:
parent
322685e3a3
commit
95a2b3ad0e
2 changed files with 171 additions and 62 deletions
24
frontend/src/hooks/useIsMobile.ts
Normal file
24
frontend/src/hooks/useIsMobile.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { useState, useEffect } from 'react';
|
||||
|
||||
const MOBILE_BREAKPOINT = 768;
|
||||
|
||||
export function useIsMobile() {
|
||||
const [isMobile, setIsMobile] = useState<boolean>(false);
|
||||
|
||||
useEffect(() => {
|
||||
// Initial check
|
||||
const checkIsMobile = () => {
|
||||
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
||||
};
|
||||
|
||||
checkIsMobile();
|
||||
|
||||
// Add resize listener
|
||||
window.addEventListener('resize', checkIsMobile);
|
||||
|
||||
// Cleanup
|
||||
return () => window.removeEventListener('resize', checkIsMobile);
|
||||
}, []);
|
||||
|
||||
return isMobile;
|
||||
}
|
||||
Reference in a new issue