This repository has been archived on 2025-03-19. You can view files and clone it, but cannot push or open issues or pull requests.
feishin/src/renderer/hooks/use-container-query.ts
2023-07-01 19:14:12 -07:00

21 lines
581 B
TypeScript

import { useElementSize } from '@mantine/hooks';
interface UseContainerQueryProps {
lg?: number;
md?: number;
sm?: number;
xl?: number;
}
export const useContainerQuery = (props?: UseContainerQueryProps) => {
const { lg, md, sm, xl } = props || {};
const { ref, width, height } = useElementSize();
const isXs = width >= 0;
const isSm = width >= (sm || 600);
const isMd = width >= (md || 768);
const isLg = width >= (lg || 1200);
const isXl = width >= (xl || 1500);
return { height, isLg, isMd, isSm, isXl, isXs, ref, width };
};