Align admin, community, search, library, learning and course management with the mockup. Add saved courses, download history, public community feed, instructor directory, backend search, course views, admin content tools and community moderation. Harden API and Nginx for production.
19 lines
686 B
TypeScript
19 lines
686 B
TypeScript
import { useEffect, useState } from 'react';
|
|
|
|
export const MOBILE_QUERY = '(max-width: 900px)';
|
|
|
|
export const useMediaQuery = (query: string) => {
|
|
const [matches, setMatches] = useState(() => typeof window !== 'undefined' && window.matchMedia(query).matches);
|
|
useEffect(() => {
|
|
const media = window.matchMedia(query);
|
|
const update = () => setMatches(media.matches);
|
|
update();
|
|
media.addEventListener('change', update);
|
|
return () => media.removeEventListener('change', update);
|
|
}, [query]);
|
|
return matches;
|
|
};
|
|
|
|
/** Mobile (≤900px) has its own navigation and screens, not the desktop squeezed. */
|
|
export const useIsMobile = () => useMediaQuery(MOBILE_QUERY);
|