Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[web] Add a hook for detecting mobile sized screens

Manav Rathi471a6eff0d99
diff --git a/web/packages/base/hooks.ts b/web/packages/base/hooks.ts
new file mode 100644
index 0000000000..1fd954377c
--- /dev/null
+++ b/web/packages/base/hooks.ts
@@ -0,0 +1,10 @@
+import { useMediaQuery, useTheme } from "@mui/material";
+
+/**
+ * Return true if the screen width is classified as a "mobile" size.
+ *
+ * We use the MUI "sm" (small, 600px) breakpoint as the cutoff. This hook will
+ * return true if the size of the window's width is less than 600px.
+ */
+export const useIsMobileWidth = () =>
+ useMediaQuery(useTheme().breakpoints.down("sm"));