Skip to content

Commit 3a32a7b

Browse files
committed
fix(badge): use bold hue for avatar
1 parent 36ba15c commit 3a32a7b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

core/src/components/badge/badge.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,23 @@ export class Badge implements ComponentInterface {
9494
}
9595

9696
// The 'subtle' hue is the default for badges containing text or icons
97-
// The 'bold' hue is used when inside of a button, tab button, or when
98-
// the badge is empty (no text or icon)
97+
// The 'bold' hue is used when inside of an avatar, button, tab button,
98+
// or when the badge is empty (no text or icon)
9999
private getHue(): string | undefined {
100100
const { hue } = this;
101101

102102
if (hue !== undefined) {
103103
return hue;
104104
}
105105

106+
const inAvatar = hostContext('ion-avatar', this.el);
106107
const inButton = hostContext('ion-button', this.el);
107108
const inTabButton = hostContext('ion-tab-button', this.el);
108109
const hasContent = this.el.textContent?.trim() !== '' || this.el.querySelector('ion-icon') !== null;
109110

110-
// Return 'bold' if the badge is inside a button, tab button, or has no content
111-
if (inButton || inTabButton || !hasContent) {
111+
// Return 'bold' if the badge is inside an avatar, button, tab button,
112+
// or has no content
113+
if (inAvatar || inButton || inTabButton || !hasContent) {
112114
return 'bold';
113115
}
114116

0 commit comments

Comments
 (0)