@coveord/plasma-mantine
Version:
A Plasma flavoured Mantine theme
27 lines (26 loc) • 837 B
JavaScript
import { useEffect, useRef, useState } from 'react';
const getElementInnerHeight = (el)=>{
const fullHeight = el.getBoundingClientRect().height;
const cs = getComputedStyle(el);
const padding = parseFloat(cs.paddingTop) + parseFloat(cs.paddingBottom);
const border = parseFloat(cs.borderTopWidth) + parseFloat(cs.borderBottomWidth);
return fullHeight - padding - border;
};
/**
* Computes the available height of the parent element on mount
*/ export const useParentHeight = ()=>{
const [height, setHeight] = useState(-1);
const ref = useRef();
useEffect(()=>{
if (ref.current) {
setHeight(getElementInnerHeight(ref.current.parentElement));
}
}, [
ref.current
]);
return [
height,
ref
];
};
//# sourceMappingURL=useParentHeight.js.map