mirror of
https://github.com/imputnet/cobalt.git
synced 2025-06-29 09:58:27 +00:00

it took way too much time to optimize the damn logo sticker under notch for all devices & zoom states also improved device lib api
33 lines
640 B
TypeScript
33 lines
640 B
TypeScript
const ua = navigator.userAgent.toLowerCase();
|
|
|
|
const iPad = ua.includes("mac os") && navigator.maxTouchPoints > 0;
|
|
const iPhone = ua.includes("iphone os");
|
|
|
|
const iOS = iPhone || iPad;
|
|
const android = ua.includes("android") || ua.includes("diordna");
|
|
|
|
const mobile = iOS || android;
|
|
|
|
const preferredLocale = navigator.language.toLowerCase().slice(0, 2);
|
|
|
|
const installed = window.matchMedia('(display-mode: standalone)').matches;
|
|
|
|
const device = {
|
|
is: {
|
|
iPad,
|
|
iPhone,
|
|
iOS,
|
|
android,
|
|
mobile,
|
|
},
|
|
preferredLocale,
|
|
}
|
|
|
|
const app = {
|
|
is: {
|
|
installed
|
|
}
|
|
}
|
|
|
|
export { device, app };
|