From 77cfa255274fdcdf822e836c7ea98e769bcb865d Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 6 Oct 2021 15:27:31 +0200 Subject: mobile --- src/utils/index.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/utils/index.js') diff --git a/src/utils/index.js b/src/utils/index.js index ee9dae9..7c4ca54 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -18,3 +18,16 @@ export const capitalize = (text = "") => .split(" ") .map(capitalizeWord) .join(" "); + +/* Mobile check */ + +export const isiPhone = !!( + navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) +); +export const isiPad = !!navigator.userAgent.match(/iPad/i); +export const isAndroid = !!navigator.userAgent.match(/Android/i); +export const isMobile = isiPhone || isiPad || isAndroid; +export const isDesktop = !isMobile; + +const htmlClassList = document.body.parentNode.classList; +htmlClassList.add(isDesktop ? "desktop" : "mobile"); -- cgit v1.2.3-70-g09d2