ysn-rfd's picture
Upload 302 files
057576a verified
raw
history blame
1.08 kB
import { useState, useEffect } from 'react';
export const useScreenSize = () => {
const [screenSize, setScreenSize] = useState({
width: window.innerWidth,
height: window.innerHeight,
isMobile: window.innerWidth < 768,
isTablet: window.innerWidth >= 768 && window.innerWidth < 1024,
isDesktop: window.innerWidth >= 1024
});
useEffect(() => {
const handleResize = () => {
setScreenSize({
width: window.innerWidth,
height: window.innerHeight,
isMobile: window.innerWidth < 768,
isTablet: window.innerWidth >= 768 && window.innerWidth < 1024,
isDesktop: window.innerWidth >= 1024
});
};
window.addEventListener('resize', handleResize);
return () => window.removeEventListener('resize', handleResize);
}, []);
return screenSize;
};
export const breakpoints = {
mobile: 768,
tablet: 1024,
desktop: 1280
};
export const getResponsiveClass = (base, mobile, tablet, desktop) => {
return `${base} ${mobile} md:${tablet} lg:${desktop}`;
};