diff --git a/src/components/ui/toast.tsx b/src/components/ui/toast.tsx index bb837146..0c861e2d 100644 --- a/src/components/ui/toast.tsx +++ b/src/components/ui/toast.tsx @@ -14,7 +14,7 @@ const ToastViewport = React.forwardRef< = MD_BREAKPOINT) + + useEffect(() => { + const mql = window.matchMedia(`(min-width: ${MD_BREAKPOINT}px)`) + const onChange = () => setIsMdScreen(mql.matches) + mql.addEventListener("change", onChange) + return () => mql.removeEventListener("change", onChange) + }, []) return ( - + {toasts.map(function ({ id, title, description, action, ...props }) { return ( diff --git a/src/hooks/useIsMobile.tsx b/src/hooks/useIsMobile.tsx index 0fae2179..b6194015 100644 --- a/src/hooks/useIsMobile.tsx +++ b/src/hooks/useIsMobile.tsx @@ -1,6 +1,8 @@ import { useEffect, useState } from "react" -const MOBILE_BREAKPOINT = 768; +import tailwindConfig from "../../tailwind.config" + +const MOBILE_BREAKPOINT = parseFloat(tailwindConfig.theme.screens.md); export function useIsMobile(): boolean { const [isMobile, setIsMobile] = useState(window.innerWidth < MOBILE_BREAKPOINT);