Files
compor-academy/hooks/useMediaQuery.ts
Cauê Faleiros 21085e887d
All checks were successful
CI / Validate frontend and API (push) Successful in 2m22s
CI / Build and publish Docker images (push) Successful in 1m6s
feat: finalize academy redesign and production readiness
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.
2026-11-05 15:06:53 -03:00

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);