Window.res.mjs
1// Generated by ReScript, PLEASE EDIT WITH CARE
2
3import * as Log from "../utils/Log.res.mjs";
4import * as Signals from "@preact/signals";
5
6function isMobileDeviceWidth() {
7 let ref = document.querySelector("#root");
8 if (ref == null) {
9 return true;
10 } else {
11 return ref.getBoundingClientRect().width < 1440;
12 }
13}
14
15let isMobile = Signals.signal(isMobileDeviceWidth());
16
17Signals.effect(() => Log.debug("mobile detection", {
18 mobile: isMobile.value
19}));
20
21function getSize() {
22 let ref = document.querySelector("#root");
23 if (!(ref == null)) {
24 return ref.getBoundingClientRect();
25 }
26}
27
28window.onresize = () => {
29 Log.debug("resize", undefined);
30 isMobile.value = isMobileDeviceWidth();
31};
32
33export {
34 isMobileDeviceWidth,
35 isMobile,
36 getSize,
37}
38/* isMobile Not a pure module */