feat: enhance responsive design and layout consistency across various components, including dashboard, statistics, and rules pages

This commit is contained in:
Julien Froidefond
2025-12-01 08:34:28 +01:00
parent 86236aeb04
commit b3b25412ad
19 changed files with 731 additions and 349 deletions

View File

@@ -8,13 +8,22 @@ export function useIsMobile() {
);
React.useEffect(() => {
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
const onChange = () => {
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
const checkMobile = () => {
const mobile = window.innerWidth < MOBILE_BREAKPOINT;
setIsMobile((prev) => {
// Éviter les re-renders inutiles si la valeur n'a pas changé
if (prev === mobile) return prev;
return mobile;
});
};
mql.addEventListener("change", onChange);
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
return () => mql.removeEventListener("change", onChange);
// Vérification initiale
checkMobile();
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
mql.addEventListener("change", checkMobile);
return () => mql.removeEventListener("change", checkMobile);
}, []);
return !!isMobile;