summaryrefslogtreecommitdiff
path: root/src/utils/index.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2021-10-06 15:27:31 +0200
committerJules Laplace <julescarbon@gmail.com>2021-10-06 15:27:31 +0200
commit77cfa255274fdcdf822e836c7ea98e769bcb865d (patch)
tree872e272eaeeacb0c48724826b14fed2bdd11e093 /src/utils/index.js
parent995c5c4b3769f8402092aba1777d29ebcc259230 (diff)
mobile
Diffstat (limited to 'src/utils/index.js')
-rw-r--r--src/utils/index.js13
1 files changed, 13 insertions, 0 deletions
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");