Add overflowCount for badge, close #660

This commit is contained in:
afc163 2015-12-11 17:57:09 +08:00
parent dd050bed0c
commit 5e18c37cce
2 changed files with 6 additions and 3 deletions

View File

@ -8,10 +8,10 @@ class AntBadge extends React.Component {
}
render() {
let { count, prefixCls } = this.props;
let { count, prefixCls, overflowCount } = this.props;
const dot = this.props.dot;
count = count >= 100 ? '99+' : count;
count = count > overflowCount ? '${overflowCount}+' : count;
// dot mode don't need count
if (dot) {
@ -43,6 +43,7 @@ AntBadge.defaultProps = {
prefixCls: 'ant-badge',
count: null,
dot: false,
overflowCount: 99,
};
AntBadge.propTypes = {
@ -51,6 +52,7 @@ AntBadge.propTypes = {
React.PropTypes.number
]),
dot: React.PropTypes.bool,
overflowCount: React.PropTypes.number,
};
export default AntBadge;

View File

@ -22,5 +22,6 @@
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|----------------|----------------------------------|------------|---------|--------|
| count | 展示的数字,大于 99 时显示为 99+,为 0 时隐藏 | Number | | |
| count | 展示的数字,大于 overflowCount 时显示为 `${overflowCount}+`,为 0 时隐藏 | Number | | |
| overflowCount | 展示封顶的数字值 | Number | | 99 |
| dot | 不展示数字,只有一个小红点 | boolean | | false |