💄 fix Badge function name

close #20253
This commit is contained in:
afc163 2020-02-11 10:48:21 +08:00
parent 68d5e2c8ef
commit 2e419b264b

View File

@ -39,20 +39,20 @@ export default class Badge extends React.Component<BadgeProps, any> {
overflowCount: 99, overflowCount: 99,
}; };
getNumberedDispayCount() { getNumberedDisplayCount() {
const { count, overflowCount } = this.props; const { count, overflowCount } = this.props;
const displayCount = const displayCount =
(count as number) > (overflowCount as number) ? `${overflowCount}+` : count; (count as number) > (overflowCount as number) ? `${overflowCount}+` : count;
return displayCount as string | number | null; return displayCount as string | number | null;
} }
getDispayCount() { getDisplayCount() {
const isDot = this.isDot(); const isDot = this.isDot();
// dot mode don't need count // dot mode don't need count
if (isDot) { if (isDot) {
return ''; return '';
} }
return this.getNumberedDispayCount(); return this.getNumberedDisplayCount();
} }
getScrollNumberTitle() { getScrollNumberTitle() {
@ -89,8 +89,8 @@ export default class Badge extends React.Component<BadgeProps, any> {
} }
isZero() { isZero() {
const numberedDispayCount = this.getNumberedDispayCount(); const numberedDisplayCount = this.getNumberedDisplayCount();
return numberedDispayCount === '0' || numberedDispayCount === 0; return numberedDisplayCount === '0' || numberedDisplayCount === 0;
} }
isDot() { isDot() {
@ -101,7 +101,7 @@ export default class Badge extends React.Component<BadgeProps, any> {
isHidden() { isHidden() {
const { showZero } = this.props; const { showZero } = this.props;
const displayCount = this.getDispayCount(); const displayCount = this.getDisplayCount();
const isZero = this.isZero(); const isZero = this.isZero();
const isDot = this.isDot(); const isDot = this.isDot();
const isEmpty = displayCount === null || displayCount === undefined || displayCount === ''; const isEmpty = displayCount === null || displayCount === undefined || displayCount === '';
@ -114,7 +114,7 @@ export default class Badge extends React.Component<BadgeProps, any> {
return hidden || !text ? null : <span className={`${prefixCls}-status-text`}>{text}</span>; return hidden || !text ? null : <span className={`${prefixCls}-status-text`}>{text}</span>;
} }
renderDispayComponent() { renderDisplayComponent() {
const { count } = this.props; const { count } = this.props;
const customNode = count as React.ReactElement<any>; const customNode = count as React.ReactElement<any>;
if (!customNode || typeof customNode !== 'object') { if (!customNode || typeof customNode !== 'object') {
@ -131,7 +131,7 @@ export default class Badge extends React.Component<BadgeProps, any> {
renderBadgeNumber(prefixCls: string, scrollNumberPrefixCls: string) { renderBadgeNumber(prefixCls: string, scrollNumberPrefixCls: string) {
const { status, count } = this.props; const { status, count } = this.props;
const displayCount = this.getDispayCount(); const displayCount = this.getDisplayCount();
const isDot = this.isDot(); const isDot = this.isDot();
const hidden = this.isHidden(); const hidden = this.isHidden();
@ -149,7 +149,7 @@ export default class Badge extends React.Component<BadgeProps, any> {
data-show={!hidden} data-show={!hidden}
className={scrollNumberCls} className={scrollNumberCls}
count={displayCount} count={displayCount}
displayComponent={this.renderDispayComponent()} // <Badge status="success" count={<Icon type="xxx" />}></Badge> displayComponent={this.renderDisplayComponent()} // <Badge status="success" count={<Icon type="xxx" />}></Badge>
title={this.getScrollNumberTitle()} title={this.getScrollNumberTitle()}
style={this.getStyleWithOffset()} style={this.getStyleWithOffset()}
key="scrollNumber" key="scrollNumber"