mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 16:51:38 +10:00
fix: styling updates
This commit is contained in:
@ -1,35 +1,27 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
// This hook is used to get the window size
|
||||
// It returns an object with the width and height of the window
|
||||
// Works with window resizing as well, not to be confused with isMobile from is-mobile package
|
||||
|
||||
interface WindowSize {
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
export function useWindowSize(): WindowSize {
|
||||
const [windowSize, setWindowSize] = useState<WindowSize>({
|
||||
export function useWindowSize() {
|
||||
const [size, setSize] = useState({
|
||||
width: 0,
|
||||
height: 0,
|
||||
});
|
||||
|
||||
const handleSize = () => {
|
||||
setWindowSize({
|
||||
const onResize = () => {
|
||||
setSize({
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
handleSize();
|
||||
window.addEventListener('resize', handleSize);
|
||||
onResize();
|
||||
|
||||
window.addEventListener('resize', onResize);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('resize', handleSize);
|
||||
window.removeEventListener('resize', onResize);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return windowSize;
|
||||
return size;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user