@primer/react-brand
Version:
Primer Brand is a GitHub's design system for creating React-based marketing websites and digital experiences.
33 lines (32 loc) • 735 B
JavaScript
import e from "./AnchorNav.module.js";
import { useEffect as t } from "react";
//#region src/AnchorNav/useExpandedMenu.ts
var n = (n, r, i, a, o) => {
t(() => {
n && a ? document.body.classList.add(e["AnchorNav--no-bg-scroll"]) : document.body.classList.remove(e["AnchorNav--no-bg-scroll"]);
}, [n, a]), t(() => {
n && a && (r.current?.firstChild)?.focus();
}, [
n,
a,
r
]), t(() => {
let e = i.current;
if (e && n && a) {
let t = (t) => {
e.contains(t.relatedTarget) || o();
};
return e.addEventListener("focusout", t), () => {
e.removeEventListener("focusout", t);
};
}
}, [
n,
a,
i,
o
]);
};
//#endregion
export { n as useExpandedMenu };
//# sourceMappingURL=useExpandedMenu.js.map