zent
Version:
一套前端设计语言和基于React的实现
31 lines (27 loc) • 587 B
text/typescript
import { IPositionFunction } from '../position-function';
import { prefix } from './prefix';
/**
* ---------
* |popover|
* ----------------
* | anchor |
* | |
* ----------------
*/
export const TopRight: IPositionFunction = ({
contentRect,
relativeRect,
cushion,
}) => {
const { right, top } = relativeRect;
const x = right - contentRect.width;
const y = top - contentRect.height - cushion;
return {
style: {
position: 'absolute',
left: x,
top: y,
},
className: prefix('position-top-right'),
};
};