carbon-react
Version:
A library of reusable React components for easily building user interfaces.
2 lines (1 loc) • 692 B
JavaScript
import{jsx as e}from"react/jsx-runtime";import{createContext as r,useState as t,useCallback as o,useEffect as i}from"react";import n from"../../../hooks/__internal__/useResizeObserver/useResizeObserver.js";const s=r({}),a=({position:r,orientation:a,offset:u,children:v,navbarRef:f})=>{var l;const[c,d]=t(null===(l=f.current)||void 0===l?void 0:l.offsetHeight),m=o((()=>{var e;return d(null===(e=f.current)||void 0===e?void 0:e.offsetHeight)}),[f]);let h;return i((()=>{m()}),[m]),n(f,m),"fixed"===r&&("top"===a&&void 0!==c?h=`calc(100vh - ${c}px - ${u})`:"bottom"===a&&(h=u)),e(s.Provider,{value:{submenuMaxHeight:h},children:v})};export{a as FixedNavigationBarContextProvider,s as default};