mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 14:13:37 +08:00
refactor(Tag): rewrite Tag
This commit is contained in:
parent
893eec74dd
commit
c198beef85
@ -1,3 +1,6 @@
|
||||
export { default as Affix } from './affix';
|
||||
|
||||
export { default as Tabs } from './Tabs';
|
||||
|
||||
export { default as Tag } from './Tag';
|
||||
|
||||
|
@ -1,15 +1,28 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import Animate from 'rc-animate';
|
||||
import Icon from '../icon';
|
||||
import classNames from 'classnames';
|
||||
import splitObject from '../_util/splitObject';
|
||||
export default class Tag extends React.Component {
|
||||
|
||||
export interface TagProps {
|
||||
/** 标签是否可以关闭*/
|
||||
closable?: boolean,
|
||||
/** 关闭时的回调*/
|
||||
onClose?: Function,
|
||||
/** 动画关闭后的回调*/
|
||||
afterClose?: Function,
|
||||
/** 标签的色彩*/
|
||||
color?: string,
|
||||
|
||||
style?: React.CSSProperties
|
||||
}
|
||||
export default class Tag extends React.Component<TagProps, any> {
|
||||
static defaultProps = {
|
||||
prefixCls: 'ant-tag',
|
||||
closable: false,
|
||||
onClose() {},
|
||||
afterClose() {},
|
||||
onClose() { },
|
||||
afterClose() { },
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
@ -47,8 +60,8 @@ export default class Tag extends React.Component {
|
||||
render() {
|
||||
const [{
|
||||
prefixCls, closable, color, className, children
|
||||
},restProps] = splitObject(this.props,
|
||||
['prefixCls', 'closable', 'color','className','children']);
|
||||
}, restProps] = splitObject(this.props,
|
||||
['prefixCls', 'closable', 'color', 'className', 'children']);
|
||||
const close = closable ? <Icon type="cross" onClick={this.close} /> : '';
|
||||
const classString = classNames({
|
||||
[prefixCls]: true,
|
||||
@ -68,7 +81,7 @@ export default class Tag extends React.Component {
|
||||
<span className={`${prefixCls}-text`}>{children}</span>
|
||||
{close}
|
||||
</div>
|
||||
)}
|
||||
) }
|
||||
</Animate>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user