2015-06-19 12:29:22 +08:00
|
|
|
import React from 'react';
|
|
|
|
import Tooltip from 'rc-tooltip';
|
|
|
|
const prefixCls = 'ant-popover';
|
2015-06-17 16:58:13 +08:00
|
|
|
|
2015-06-19 12:29:22 +08:00
|
|
|
export default React.createClass({
|
2015-06-17 17:15:34 +08:00
|
|
|
getDefaultProps() {
|
2015-06-17 16:58:13 +08:00
|
|
|
return {
|
2015-06-17 17:10:10 +08:00
|
|
|
transitionName: '',
|
2015-06-17 16:58:13 +08:00
|
|
|
placement: 'top',
|
2015-08-19 20:16:20 +08:00
|
|
|
trigger: 'hover',
|
|
|
|
overlayStyle: {}
|
2015-06-17 16:58:13 +08:00
|
|
|
};
|
|
|
|
},
|
2015-06-17 17:15:34 +08:00
|
|
|
render() {
|
2015-06-24 19:20:47 +08:00
|
|
|
const overlay = <div>
|
2015-06-17 20:15:09 +08:00
|
|
|
<div className={prefixCls + '-title'}>
|
2015-06-17 16:58:13 +08:00
|
|
|
{this.props.title}
|
|
|
|
</div>
|
2015-06-17 20:15:09 +08:00
|
|
|
<div className={prefixCls + '-content'}>
|
2015-06-17 16:58:13 +08:00
|
|
|
{this.props.overlay}
|
|
|
|
</div>
|
|
|
|
</div>;
|
2015-06-17 17:10:10 +08:00
|
|
|
|
2015-06-19 12:29:22 +08:00
|
|
|
const transitionName = ({
|
2015-06-17 17:10:10 +08:00
|
|
|
top: 'zoom-down',
|
|
|
|
bottom: 'zoom-up',
|
|
|
|
left: 'zoom-right',
|
|
|
|
right: 'zoom-left'
|
|
|
|
})[this.props.placement];
|
|
|
|
|
2015-06-17 16:58:13 +08:00
|
|
|
return (
|
|
|
|
<Tooltip placement={this.props.placement}
|
2015-08-19 20:16:20 +08:00
|
|
|
prefixCls={prefixCls}
|
|
|
|
delay={0.1}
|
|
|
|
overlayStyle={this.props.overlayStyle}
|
|
|
|
transitionName={transitionName}
|
|
|
|
trigger={this.props.trigger}
|
|
|
|
overlay={overlay}>
|
2015-06-17 16:58:13 +08:00
|
|
|
{this.props.children}
|
|
|
|
</Tooltip>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|