text-dataset-tiny-code-script-py-format / ysnrfd_messenger /BACKUP2 /frontend /src /utils /responsive.js
| 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}`; | |
| }; |