UNPKG

fui-fancyui

Version:
20 lines (19 loc) 594 B
"use client"; import { useState as o, useEffect as s } from "react"; import c from "../../../design/theme/themeStore/themeStore.js"; const d = (e) => { const [n, i] = o(null), r = c((t) => t.theme); return s(() => { const t = () => { i(u(e || r.breakpoints)); }; return window.addEventListener("resize", t), t(), () => window.removeEventListener("resize", t); }, [e, r]), n; }, u = (e) => { if (!e) return null; const n = Object.entries(e).reverse().find(([i, r]) => window.matchMedia(r).matches); return n ? n[0] : null; }; export { d as useActiveBreakpoint };