web: respect reduced motion & transparency preferences

also cleaned up settings & device libs
This commit is contained in:
wukko
2024-07-12 18:49:29 +06:00
parent 1160b90c17
commit d27bed7add
10 changed files with 71 additions and 52 deletions

View File

@@ -8,10 +8,13 @@ const android = ua.includes("android") || ua.includes("diordna");
const mobile = iOS || android;
const preferredLocale = navigator.language.toLowerCase().slice(0, 2);
const language = navigator.language.toLowerCase().slice(0, 2);
const installed = window.matchMedia('(display-mode: standalone)').matches;
const reducedMotion = window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;
const reducedTransparency = window.matchMedia(`(prefers-reduced-transparency: reduce)`).matches;
const device = {
is: {
iPhone,
@@ -20,7 +23,11 @@ const device = {
android,
mobile,
},
preferredLocale,
prefers: {
language,
reducedMotion,
reducedTransparency,
},
userAgent: navigator.userAgent,
}