UNPKG

@fefade/react

Version:

Reusable React UI components powered by the fefade core system.

27 lines (26 loc) 775 B
import { useState as w, useEffect as y } from "react"; import { I as u } from "../index-DdnSr7Dp.js"; import { l as d } from "../index-BPdhNdef.js"; function S(...a) { const [t, e, o] = a, [f, n] = w(!1); return y(() => { if (typeof window > "u" || typeof document > "u") { n(!1); return; } const r = document.documentElement, m = o ?? r, s = getComputedStyle(r).getPropertyValue(`${d.CSS_VAR_PREFIX}-${e}`).trim() || d.breakpoints[e] || e, i = new ResizeObserver((p) => { for (const l of p) { const c = l.contentRect.width; n( t === "min-width" ? c >= u(s) : c <= u(s) ); } }); return i.observe(m), () => { i.disconnect(); }; }, [t, e, o]), f; } export { S as mediaQueryHook };