Add brewery discovery & detail pages with location-based search (#253)

This commit is contained in:
Aaron Po
2026-08-29 00:44:33 -04:00
committed by GitHub
parent 92a30b11db
commit a580314583
90 changed files with 3874 additions and 187 deletions

View File

@@ -0,0 +1,22 @@
import { useSyncExternalStore } from 'react';
const subscribe = (query: string) => (callback: () => void) => {
const media = window.matchMedia(query);
media.addEventListener('change', callback);
return () => media.removeEventListener('change', callback);
};
/**
* Tracks whether a CSS media query currently matches the viewport, updating on change.
*
* @example
* const isSmallScreen = useMediaQuery('(max-width: 640px)');
*/
const useMediaQuery = (query: `(${string})`) =>
useSyncExternalStore(
subscribe(query),
() => window.matchMedia(query).matches,
() => false,
);
export default useMediaQuery;