@zohodesk/components
Version:
In this Package, we Provide Some Basic Components to Build Web App
54 lines (51 loc) • 1.39 kB
JavaScript
import { remConvert } from "../../utils/Common";
export default function useDropboxPosCalc(props) {
let {
right,
left,
top,
arrowRight,
arrowLeft,
arrowTop,
arrowBottom,
bottom,
isModel,
direction
} = props;
const unit = 'rem';
let boxstyle = {};
let arrowstyle = {};
const needBoxStyle = right || left || top || bottom;
const needArrowStyle = arrowLeft || arrowRight || arrowTop || arrowBottom;
if (needBoxStyle) {
boxstyle = !isModel ? direction === 'rtl' ? {
right: [remConvert(left)] + unit,
left: [remConvert(right)] + unit,
top: [remConvert(top)] + unit,
bottom: [remConvert(bottom)] + unit
} : {
right: [remConvert(right)] + unit,
left: [remConvert(left)] + unit,
top: [remConvert(top)] + unit,
bottom: [remConvert(bottom)] + unit
} : {};
}
if (needArrowStyle) {
arrowstyle = !isModel ? direction === 'rtl' ? {
right: [remConvert(arrowLeft)] + unit,
left: [remConvert(arrowRight)] + unit,
top: [remConvert(arrowTop)] + unit,
bottom: [remConvert(arrowBottom)] + unit
} : {
right: [remConvert(arrowRight)] + unit,
left: [remConvert(arrowLeft)] + unit,
top: [remConvert(arrowTop)] + unit,
bottom: [remConvert(arrowBottom)] + unit
} : {};
}
return {
needBoxStyle,
boxstyle,
arrowstyle
};
}