Add component tag

This commit is contained in:
afc163 2015-07-28 17:08:06 +08:00
parent b6fe8021f8
commit 6344e9151b
3 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,17 @@
# 基本
- order: 0
标签。
---
````jsx
var Tag = antd.Tag;
React.render(<div>
<Tag>标签一</Tag>
<Tag closable>标签二</Tag>
<Tag>标签三</Tag>
</div>, document.getElementById('components-tag-demo-basic'));
````

29
components/tag/index.jsx Normal file
View File

@ -0,0 +1,29 @@
import React from 'react';
const prefixCls = 'ant-tag';
class AntTag extends React.Component {
destroy() {
let node = React.findDOMNode(this);
React.unmountComponentAtNode(node);
node.parentNode.removeChild(node);
this.props.onClose.call(this);
}
render() {
var close = this.props.closable ?
<i className="anticon anticon-cross" onClick={this.destroy.bind(this)}></i> : '';
return <div className={this.props.prefixCls}>
<span className={this.props.prefixCls + '-text'}>
{this.props.children}
</span>
{close}
</div>;
}
}
AntTag.defaultProps = {
prefixCls: prefixCls,
closable: false,
onClose: function() {}
};
export default AntTag;

View File

@ -19,6 +19,7 @@ var antd = {
Switch: require('./components/switch'),
Checkbox: require('./components/checkbox'),
Table: require('./components/table'),
Tag: require('./components/tag'),
Collapse: require('./components/collapse'),
message: require('./components/message'),
Slider: require('./components/slider'),