2015-07-28 17:08:06 +08:00
|
|
|
import React from 'react';
|
|
|
|
const prefixCls = 'ant-tag';
|
|
|
|
|
|
|
|
class AntTag extends React.Component {
|
2015-07-29 20:13:42 +08:00
|
|
|
destroy(e) {
|
2015-07-28 17:08:06 +08:00
|
|
|
let node = React.findDOMNode(this);
|
|
|
|
React.unmountComponentAtNode(node);
|
|
|
|
node.parentNode.removeChild(node);
|
2015-07-29 20:13:42 +08:00
|
|
|
this.props.onClose.call(this, e);
|
2015-07-28 17:08:06 +08:00
|
|
|
}
|
|
|
|
render() {
|
2015-07-28 20:03:10 +08:00
|
|
|
let close = this.props.closable ?
|
2015-07-28 17:08:06 +08:00
|
|
|
<i className="anticon anticon-cross" onClick={this.destroy.bind(this)}></i> : '';
|
2015-07-28 20:03:10 +08:00
|
|
|
let colorClass = this.props.prefixCls + '-' + this.props.color;
|
|
|
|
|
|
|
|
return <div className={this.props.prefixCls + ' ' + colorClass}>
|
|
|
|
<a className={this.props.prefixCls + '-text'} {...this.props} />
|
2015-07-28 17:08:06 +08:00
|
|
|
{close}
|
|
|
|
</div>;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AntTag.defaultProps = {
|
|
|
|
prefixCls: prefixCls,
|
|
|
|
closable: false,
|
|
|
|
onClose: function() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default AntTag;
|