refactor main.js into smaller pieces, and moved navbar.js to assets

This commit is contained in:
Aaron Qian 2022-11-10 23:23:50 -08:00 committed by Aaron Qian
parent fd8eeb3330
commit 177dffe553
No known key found for this signature in database
GPG key ID: BF1A987C395B5B0E
19 changed files with 214 additions and 207 deletions

View file

@ -0,0 +1,36 @@
let deviceState = {
isMobile: false,
isTablet: false,
isLaptop: false,
};
function detectDeviceState() {
if (window.innerWidth <= 425) {
deviceState = {
isMobile: true,
isTablet: false,
isLaptop: false,
};
} else if (window.innerWidth <= 768) {
deviceState = {
isMobile: false,
isTablet: true,
isLaptop: false,
};
} else {
deviceState = {
isMobile: false,
isTablet: false,
isLaptop: true,
};
}
}
detectDeviceState();
window.addEventListener('resize', detectDeviceState);
// returns a copy of the device state
// so other parts of code can't override this.
export function getDeviceState() {
return { ... deviceState };
}

View file

@ -0,0 +1 @@
export * from './device';