mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-21 02:11:35 +03:00
c140b9c517
* 💄 The chat sidebar takes the full height * 💄 redesign of the action section and buttons in the sidebar * ✨ Sidebar header * ♻️ Refact sidebar filesystem structure * ♻️ Create a separate reusable sidebar component * 🐛 Fix sidebar quick open/close on mobile * 💄 New open/close sidebar button * fix: error message + sidebar height issue + mobile width incoherence * ♻️ Rename and move the sidebar footer * 💄 sidebar toggle: color on hover * apply sidebar to brains-management * 💄 Larger sidebar * 🚨Pass existing tests * ✅ Test the sidebar * ✅ Test the open and close buttons in the sidebar
30 lines
737 B
TypeScript
30 lines
737 B
TypeScript
import { useEffect, useState } from "react";
|
|
|
|
// Max width for mobile device: 640px
|
|
// Match small min-width media query in tailwind
|
|
const MOBILE_MAX_WIDTH = 640;
|
|
|
|
export const useDevice = (): { isMobile: boolean } => {
|
|
const [isMobile, setIsMobile] = useState(true);
|
|
|
|
useEffect(() => {
|
|
const handleResize = () => {
|
|
const screenWidth = window.innerWidth;
|
|
setIsMobile(screenWidth < MOBILE_MAX_WIDTH);
|
|
};
|
|
|
|
// Initial check
|
|
handleResize();
|
|
|
|
// Event listener for screen resize
|
|
window.addEventListener("resize", handleResize);
|
|
|
|
// Clean up event listener on component unmount
|
|
return () => {
|
|
window.removeEventListener("resize", handleResize);
|
|
};
|
|
}, []);
|
|
|
|
return { isMobile };
|
|
};
|