@zohodesk/components
Version:
Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development
90 lines (85 loc) • 2.65 kB
JavaScript
import { useContext } from 'react';
import LibraryContext from "../../../Provider/LibraryContextInit";
import { compileClassNames } from '@zohodesk/utils';
export default function cssJSLogic({
props,
style,
customState
}) {
const DropBoxElementContext = useContext(LibraryContext);
const {
boxPosition,
boxDirection,
boxstyle,
needBoxStyle,
isAbsolute
} = customState;
const {
isReducedMotion
} = DropBoxElementContext || {};
const {
isAnimate,
isArrow,
size,
isRadius,
animationStyle,
isActive,
isModel,
isBoxPaddingNeed,
isPadding,
customClass,
positionsOffset,
targetOffset,
zIndexStyle,
customInlineStyle
} = props;
const {
customDropBox = '',
customMobileDropBox = '',
customDropBoxWrap = '',
customMobileDropBoxWrap = ''
} = customClass;
const animationValue = animationStyle === 'default' ? 'fadeInScale' : animationStyle; // const {needBoxStyle,boxstyle} = useDropboxPosCalc(props)
let boxClassName = compileClassNames({
[]: true,
[]: !isActive,
[]: !!isModel,
[]: isAbsolute && !isModel,
[]]: isAbsolute && !isModel,
[]: !isAbsolute && !isModel,
[]]: size && !isModel,
[]: !isModel && isActive && isArrow,
[]: !isModel && isActive && isArrow && isAbsolute,
[]: !isModel && isActive && !isArrow && isPadding,
[]: !!isModel,
[]: !isModel
});
let subContainerClass = compileClassNames({
[]: true,
[]: !!isModel,
[]: !!isModel && isActive,
[]: !isModel,
[]: !isModel && isBoxPaddingNeed,
[]: !isModel && isRadius,
[]]: !isModel && isAnimate && !isReducedMotion && isActive && !!animationStyle,
[]: !!isModel,
[]: !isModel
});
let inlineStyle = !isModel ? isAbsolute ? needBoxStyle && boxstyle : positionsOffset && positionsOffset[boxPosition] || {} : {};
if (zIndexStyle) {
inlineStyle = Object.assign({}, inlineStyle, zIndexStyle);
}
if (!isModel && !isAbsolute && size === 'default' && targetOffset && isActive) {
inlineStyle = Object.assign({}, inlineStyle, {
width: targetOffset.width
});
}
if (customInlineStyle) {
inlineStyle = Object.assign({}, inlineStyle, customInlineStyle);
}
return {
boxClassName,
subContainerClass,
inlineStyle
};
}