diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2021-10-06 15:27:31 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2021-10-06 15:27:31 +0200 |
| commit | 77cfa255274fdcdf822e836c7ea98e769bcb865d (patch) | |
| tree | 872e272eaeeacb0c48724826b14fed2bdd11e093 /src/utils/index.js | |
| parent | 995c5c4b3769f8402092aba1777d29ebcc259230 (diff) | |
mobile
Diffstat (limited to 'src/utils/index.js')
| -rw-r--r-- | src/utils/index.js | 13 |
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"); |
