mirror of
https://github.com/grafana/grafana.git
synced 2025-07-29 23:52:19 +08:00

* AppChrome/MegaMenu: Fixes default mega menu docked state * AppChrome/MegaMenu: Fixes default mega menu docked state * Update thresholds * Update * pa11y fix * remove unnessary css * fixed pa11y config * try fix pa11y config + unit tests * just increase thresholds again... --------- Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
22 lines
725 B
TypeScript
22 lines
725 B
TypeScript
import { useEffect, useMemo, useState } from 'react';
|
|
|
|
import { ThemeBreakpointsKey } from '@grafana/data';
|
|
import { useTheme2 } from '@grafana/ui';
|
|
|
|
export function useMediaQueryMinWidth(breakpoint: ThemeBreakpointsKey): boolean {
|
|
const theme = useTheme2();
|
|
const mediaQuery = useMemo(
|
|
() => window.matchMedia(`(min-width: ${theme.breakpoints.values[breakpoint]}px)`),
|
|
[theme, breakpoint]
|
|
);
|
|
const [isMatch, setIsMatch] = useState(mediaQuery.matches);
|
|
|
|
useEffect(() => {
|
|
const onChange = (e: MediaQueryListEvent) => setIsMatch(e.matches);
|
|
mediaQuery.addEventListener('change', onChange);
|
|
return () => mediaQuery.removeEventListener('change', onChange);
|
|
}, [mediaQuery]);
|
|
|
|
return isMatch;
|
|
}
|