3034f4ce6c
* bring in ody styles; modify; cleanup * workflow * workflow * v0.52.6-alpha.teststyles.1 * fix hook * v0.52.6-alpha.teststyles.2 * style fixes * fix pagination styling * v0.52.6-alpha.teststyles.3 * wallet icon was bad * restore deploy script * fixes * fix player close button * modal inputs * cleanup * cleanup * fix staked indicator * fix profile menu button skel delay * fix view-all-playlists hover * fix overlay buttons on collection page * fix header buttons
40 lines
983 B
JavaScript
40 lines
983 B
JavaScript
// Widths are taken from "ui/scss/init/vars.scss"
|
|
import React from 'react';
|
|
|
|
function useWindowSize() {
|
|
const isWindowClient = typeof window === 'object';
|
|
const [windowSize, setWindowSize] = React.useState(isWindowClient ? window.innerWidth : undefined);
|
|
|
|
React.useEffect(() => {
|
|
function setSize() {
|
|
setWindowSize(window.innerWidth);
|
|
}
|
|
|
|
if (isWindowClient) {
|
|
window.addEventListener('resize', setSize);
|
|
|
|
return () => window.removeEventListener('resize', setSize);
|
|
}
|
|
}, [isWindowClient, setWindowSize]);
|
|
|
|
return windowSize;
|
|
}
|
|
|
|
export function useIsMobile() {
|
|
const windowSize = useWindowSize();
|
|
return windowSize < 901;
|
|
}
|
|
|
|
export function useIsMediumScreen() {
|
|
const windowSize = useWindowSize();
|
|
return windowSize < 1151;
|
|
}
|
|
|
|
export function useIsLargeScreen() {
|
|
const windowSize = useWindowSize();
|
|
return windowSize > 1600;
|
|
}
|
|
|
|
export function isTouch() {
|
|
return 'ontouchstart' in window || 'onmsgesturechange' in window;
|
|
}
|