Skip to content

Commit

Permalink
update tag
Browse files Browse the repository at this point in the history
  • Loading branch information
BANG88 committed Jul 9, 2016
1 parent 817bfe9 commit c36cf9e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
3 changes: 3 additions & 0 deletions components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ export { Tree };

import Tabs from './tabs';
export { Tabs }

import Tag from './tag';
export { Tag }
23 changes: 18 additions & 5 deletions components/tag/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,24 @@ import classNames from 'classnames';
import splitObject from '../_util/splitObject';
import omit from 'object.omit';

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) {
Expand Down Expand Up @@ -52,6 +64,7 @@ export default class Tag extends React.Component {
this.props,
['prefixCls', 'closable', 'color','className','children']
);

const close = closable ? <Icon type="cross" onClick={this.close} /> : '';
const classString = classNames({
[prefixCls]: true,
Expand All @@ -70,13 +83,13 @@ export default class Tag extends React.Component {
transitionName={`${prefixCls}-zoom`}
transitionAppear
onEnd={this.animationEnd}
>
>
{this.state.closed ? null : (
<div data-show={!this.state.closing} {...divProps} className={classString}>
<span className={`${prefixCls}-text`}>{children}</span>
{close}
</div>
)}
) }
</Animate>
);
}
Expand Down

0 comments on commit c36cf9e

Please sign in to comment.