Skip to content

Commit 6cc8ce4

Browse files
committed
fix badge
1 parent f100f0d commit 6cc8ce4

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

components/badge/Badge.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ export default {
4545
$slots,
4646
numberStyle,
4747
} = this
48-
const isDot = dot || status
4948
let displayCount = count > overflowCount ? `${overflowCount}+` : count
49+
const isZero = displayCount === '0' || displayCount === 0
50+
const isDot = (dot && !isZero) || status
5051
// dot mode don't need count
5152
if (isDot) {
5253
displayCount = ''
5354
}
5455
const children = filterEmpty($slots.default)
55-
const isZero = displayCount === '0' || displayCount === 0
5656
const isEmpty = displayCount === null || displayCount === undefined || displayCount === ''
5757
const hidden = (isEmpty || (isZero && !showZero)) && !isDot
5858
const statusCls = classNames({
@@ -62,7 +62,7 @@ export default {
6262
const scrollNumberCls = classNames({
6363
[`${prefixCls}-dot`]: isDot,
6464
[`${prefixCls}-count`]: !isDot,
65-
[`${prefixCls}-multiple-words`]: count && count.toString && count.toString().length > 1,
65+
[`${prefixCls}-multiple-words`]: !isDot && count && count.toString && count.toString().length > 1,
6666
[`${prefixCls}-status-${status}`]: !!status,
6767
})
6868
const badgeCls = classNames(prefixCls, {

components/badge/demo/dot.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<us>
77
#### Red badge
88
This will simply display a red badge, without a specific count.
9+
If count equals 0, it won't display the dot.
910
</us>
1011

1112
```html
@@ -14,6 +15,9 @@ This will simply display a red badge, without a specific count.
1415
<a-badge dot>
1516
<a-icon type="notification" />
1617
</a-badge>
18+
<a-badge :count="0" dot>
19+
<a-icon type="notification" />
20+
</a-badge>
1721
<a-badge dot>
1822
<a href="#">Link something</a>
1923
</a-badge>

components/badge/style/index.less

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@
113113
top: auto;
114114
display: block;
115115
position: relative;
116-
transform: none !important;
116+
}
117+
&-not-a-wrapper .@{badge-prefix-cls}-count {
118+
transform: none;
117119
}
118120
}
119121

0 commit comments

Comments
 (0)