blindspot / frontend /src /app /useMediaQuery.ts
yashwrites's picture
Blindspot: initial Space deploy
54f0281 verified
Raw History Blame Contribute Delete
595 Bytes
import { useSyncExternalStore } from 'react';
export function useMediaQuery(query: string): boolean {
return useSyncExternalStore(
(cb) => {
const mq = window.matchMedia(query);
mq.addEventListener('change', cb);
return () => mq.removeEventListener('change', cb);
},
() => window.matchMedia(query).matches,
() => false,
);
}
/** Below 900 px the film is too small to read; the app shows a note instead of the viewer (SPEC §14.2 targets). */
export const NARROW_QUERY = '(max-width: 899.98px)';
export const useNarrow = () => useMediaQuery(NARROW_QUERY);