fix(frontend): update Share interface property from download_count to downloads
All checks were successful
Automated Container Build / build-and-push (push) Successful in 3m25s
All checks were successful
Automated Container Build / build-and-push (push) Successful in 3m25s
This commit is contained in:
parent
ed3eed6bb7
commit
1f83d57942
21 changed files with 241 additions and 137 deletions
|
|
@ -2,23 +2,20 @@ import { useState, useEffect } from 'react';
|
|||
|
||||
const MOBILE_BREAKPOINT = 768;
|
||||
|
||||
export function useIsMobile() {
|
||||
export function useIsMobile(breakpoint = 768) {
|
||||
const [isMobile, setIsMobile] = useState<boolean>(false);
|
||||
const [hasMounted, setHasMounted] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
// Initial check
|
||||
const checkIsMobile = () => {
|
||||
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
||||
};
|
||||
|
||||
checkIsMobile();
|
||||
setHasMounted(true);
|
||||
const mql = window.matchMedia(`(max-width: ${breakpoint}px)`);
|
||||
setIsMobile(mql.matches);
|
||||
|
||||
// Add resize listener
|
||||
window.addEventListener('resize', checkIsMobile);
|
||||
|
||||
// Cleanup
|
||||
return () => window.removeEventListener('resize', checkIsMobile);
|
||||
}, []);
|
||||
const handler = (e: MediaQueryListEvent) => setIsMobile(e.matches);
|
||||
mql.addEventListener('change', handler);
|
||||
return () => mql.removeEventListener('change', handler);
|
||||
}, [breakpoint]);
|
||||
|
||||
if (!hasMounted) return false;
|
||||
return isMobile;
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue