Datasets:
text-dataset-tiny-code-script-py-format / ysnrfd_messenger /BACKUP4 /frontend /src /utils /responsive.js
Download ysnrfd_messenger/BACKUP4/frontend/src/utils/responsive.js from ysn-rfd/text-dataset-tiny-code-script-py-format: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/datasets/ysn-rfd/text-dataset-tiny-code-script-py-format/resolve/main/ysnrfd_messenger/BACKUP4/frontend/src/utils/responsive.js
- Command line
-
hf download hf://datasets/ysn-rfd/text-dataset-tiny-code-script-py-format/ysnrfd_messenger/BACKUP4/frontend/src/utils/responsive.js
-
curl -L -o responsive.js https://huggingface.co/datasets/ysn-rfd/text-dataset-tiny-code-script-py-format/resolve/main/ysnrfd_messenger/BACKUP4/frontend/src/utils/responsive.js
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}`; | |
| }; |