DocSpace-client/packages/components/utils/device.js

57 lines
1.3 KiB
JavaScript
Raw Normal View History

import { checkIsSSR } from "@docspace/common/utils";
export const size = {
mobile: 375,
hugeMobile: 428,
smallTablet: 600,
tablet: 1024,
desktop: 1025,
2022-10-26 12:15:57 +00:00
hugeDesktop: 1439,
};
export const mobile = `(max-width: ${size.mobile}px)`;
export const hugeMobile = `(max-width: ${size.hugeMobile}px)`;
export const smallTablet = `(max-width: ${size.smallTablet}px)`;
export const tablet = `(max-width: ${size.tablet}px)`;
export const desktop = `(min-width: ${size.desktop}px)`;
2022-10-25 13:24:18 +00:00
export const hugeDesktop = `(max-width: ${size.hugeDesktop}px)`;
export const isMobile = () => {
2022-04-26 12:28:03 +00:00
return window.innerWidth <= size.mobile;
};
export const isHugeMobile = () => {
return window.innerWidth <= size.hugeMobile;
};
export const isSmallTablet = () => {
return window.innerWidth < size.smallTablet;
};
export const isTablet = () => {
return (
window.innerWidth <= size.tablet && window.innerWidth >= size.hugeMobile
);
};
export const isDesktop = () => {
if (!checkIsSSR()) {
return window.innerWidth >= size.desktop;
} else return false;
};
export const isTouchDevice = !!(
typeof window !== "undefined" &&
typeof navigator !== "undefined" &&
("ontouchstart" in window || navigator.msMaxTouchPoints > 0)
);
2021-10-04 16:37:01 +00:00
export const getModalType = () => {
return window.innerWidth < size.desktop ? "aside" : "modal";
};