-
-
Notifications
You must be signed in to change notification settings - Fork 227
/
Badge.jsx
46 lines (39 loc) · 1.07 KB
/
Badge.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
class Badge extends PureComponent {
render() {
const { prefixCls, className, theme, shape, sup, text, children, ...others } = this.props;
const cls = classnames({
[`${prefixCls}`]: true,
[className]: !!className,
[`theme-${theme}`]: !!theme,
[`shape-${shape}`]: !!shape,
});
const supCls = classnames({
[`${prefixCls}-sup`]: true,
[`${prefixCls}-sup-up`]: sup,
});
return (
<span className={cls} {...others}>
{children}
<sup className={supCls}>{text}</sup>
</span>
);
}
}
Badge.propTypes = {
prefixCls: PropTypes.string,
className: PropTypes.string,
theme: PropTypes.oneOf(['default', 'primary', 'info', 'success', 'warning', 'error']),
shape: PropTypes.oneOf(['dot', 'radius', 'round', 'circle']),
sup: PropTypes.bool,
};
Badge.defaultProps = {
prefixCls: 'za-badge',
className: null,
theme: 'error',
shape: null,
sup: false,
};
export default Badge;