@difizen/mana-react
Version:
61 lines • 1.43 kB
JavaScript
import { defaultPrefixCls } from "../constant";
export var DEFAULT_TOP = 24;
export var DEFAULT_BOTTOM = 24;
export var DEFAULT_OFFSET = 24;
export var DEFAULT_DURATION = 4.5;
export var DEFAULT_PLACEMENT = 'bottomRight';
export var NOTIFICATION_PREFIX_CLS = "".concat(defaultPrefixCls, "-notification");
export function getPlacementStyle(placement) {
var top = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_TOP;
var bottom = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_BOTTOM;
var style;
switch (placement) {
case 'top':
style = {
left: '50%',
transform: 'translateX(-50%)',
right: 'auto',
top: top,
bottom: 'auto'
};
break;
case 'topLeft':
style = {
left: 0,
top: top,
bottom: 'auto'
};
break;
case 'topRight':
style = {
right: 0,
top: top,
bottom: 'auto'
};
break;
case 'bottom':
style = {
left: '50%',
transform: 'translateX(-50%)',
right: 'auto',
top: 'auto',
bottom: bottom
};
break;
case 'bottomLeft':
style = {
left: 0,
top: 'auto',
bottom: bottom
};
break;
default:
style = {
right: 0,
top: 'auto',
bottom: bottom
};
break;
}
return style;
}