mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 12:43:09 -05:00
24 lines
807 B
TypeScript
24 lines
807 B
TypeScript
import { useWindowSize } from 'usehooks-ts';
|
|
|
|
import { breakpoints } from '../tokens';
|
|
|
|
export function useResponsive() {
|
|
const { height, width } = useWindowSize({
|
|
debounceDelay: 250,
|
|
});
|
|
|
|
// Possible view modes: narrow, small, medium, wide
|
|
// To check if we're at least small width, check !isNarrowWidth
|
|
return {
|
|
// atLeastMediumWidth is provided to avoid checking (isMediumWidth || isWideWidth)
|
|
atLeastMediumWidth: width >= breakpoints.medium,
|
|
isNarrowWidth: width < breakpoints.small,
|
|
isSmallWidth: width >= breakpoints.small && width < breakpoints.medium,
|
|
isMediumWidth: width >= breakpoints.medium && width < breakpoints.wide,
|
|
// No atLeastWideWidth because that's identical to isWideWidth
|
|
isWideWidth: width >= breakpoints.wide,
|
|
height,
|
|
width,
|
|
};
|
|
}
|