Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
396470a
feat(badge): add recipe and tokens
thetaPC Mar 27, 2026
9a2e0d1
feat(badge): more defaults for md
thetaPC Mar 27, 2026
a93bc68
feat(badge): remove crisp
thetaPC Mar 27, 2026
cd2364c
Merge branch 'ionic-modular' of github.com:ionic-team/ionic-framework…
thetaPC Mar 30, 2026
9c691b4
feat(avatar, badge, tab-button): a lot of avatar updates
thetaPC Mar 31, 2026
b40e733
feat(avatar, badge): implement all combos
thetaPC Mar 31, 2026
bf6c885
feat(badge, avatar, button): add position utility
thetaPC Apr 3, 2026
459a508
refactor(button): cleanup for badge
thetaPC Apr 3, 2026
1493f90
feat(avatar, badge, button, tab-button): update position
thetaPC Apr 6, 2026
556b111
test(avatar, button, tab-button): update badge pages
thetaPC Apr 6, 2026
50fe67f
feat(badge): remove max-width for now
thetaPC Apr 6, 2026
89e9b04
test(avatar, button, tab-button): update test pages
thetaPC Apr 6, 2026
e029fbc
refactor(badge): update names for types
thetaPC Apr 6, 2026
3837435
feat(badge): remove old complex hue getter
thetaPC Apr 7, 2026
929929e
refactor(avatar): cleanup
thetaPC Apr 7, 2026
25f4e87
test(badge): update test pages
thetaPC Apr 7, 2026
539c476
docs(badge): remove comments
thetaPC Apr 7, 2026
9f7e6c1
refactor(badge): remove extra
thetaPC Apr 7, 2026
2a27548
docs(badge): remove todos
thetaPC Apr 7, 2026
6a8a4cc
docs(badge): remove more comments
thetaPC Apr 7, 2026
ba7f2ba
feat(badge): remove ionic styles
thetaPC Apr 7, 2026
bd801b8
feat(badge): remove theme styles
thetaPC Apr 7, 2026
57e3faf
feat(badge): remove theme
thetaPC Apr 7, 2026
47fa6d5
feat(badge): update classes
thetaPC Apr 7, 2026
cf65c7a
feat(tab-button): check for label
thetaPC Apr 7, 2026
d8ae5b5
refactor(many): cleanup
thetaPC Apr 7, 2026
6e794f2
feat(badge): add interfaces
thetaPC Apr 7, 2026
ce5d5e9
feat(badge): update interfaces and import
thetaPC Apr 7, 2026
15033a0
docs(badge): add CSS variables definitions
thetaPC Apr 7, 2026
6737cb6
feat(badge): add position utility file
thetaPC Apr 7, 2026
14e2460
feat(badge): add config type
thetaPC Apr 7, 2026
2d3ce7f
test(badge): update snapshots
thetaPC Apr 8, 2026
c468fa8
feat(themes): update badge sizes
thetaPC Apr 8, 2026
d5abd1e
test(avatar): add badge snapshots
thetaPC Apr 8, 2026
03497cb
test(button): add badge snapshots
thetaPC Apr 8, 2026
0aaca71
test(tab-button): add badge snapshots
thetaPC Apr 8, 2026
9365800
test(badge): remove vertical tests
thetaPC Apr 8, 2026
40463b7
chore(badge): run build
thetaPC Apr 8, 2026
8096abf
feat(badge): use min height for content font scaling
thetaPC Apr 8, 2026
340a4a1
chore(badge): run build
thetaPC Apr 8, 2026
0fe440f
feat(badge): add height and min-height
thetaPC Apr 8, 2026
795c0de
test(badge): update snapshots
thetaPC Apr 8, 2026
5f92eab
test(item): update badge snapshots
thetaPC Apr 8, 2026
f262f4c
feat(badge): update sizes for native
thetaPC Apr 8, 2026
593ab49
feat(badge): update sizes for md and ios
thetaPC Apr 8, 2026
fb6f80c
feat(badge): update border radius for soft
thetaPC Apr 8, 2026
6d660b7
feat(tab-button): update barge target
thetaPC Apr 8, 2026
bfb9a29
test(tab-button): update badge snapshots
thetaPC Apr 8, 2026
75175f6
feat(badge): update sizes
thetaPC Apr 8, 2026
a40e4d1
test(tab-bar): revert
thetaPC Apr 8, 2026
cbc4a19
test(tab-bar): force correct snapshot
thetaPC Apr 8, 2026
08c8eb1
test(tab-bar): correct snapshot
thetaPC Apr 8, 2026
a7240cb
test(item): update badge snapshots
thetaPC Apr 9, 2026
0ed4e14
test(many): update badge snapshots
thetaPC Apr 9, 2026
a8962a1
test(button): improve readability
thetaPC Apr 21, 2026
213a1eb
fix(badge): revert
thetaPC Apr 21, 2026
cc01ecc
feat(badge): update content padding
thetaPC Apr 21, 2026
ec64124
test(button): update layout
thetaPC Apr 21, 2026
bf60e08
feat(badge): update position utility
thetaPC Apr 21, 2026
084a391
feat(badge): clamp position on labels
thetaPC Apr 22, 2026
b4b612e
test(tab-bar): update badge snapshots
thetaPC Apr 22, 2026
ad6cdee
test(tab-button): update snapshots
thetaPC Apr 22, 2026
a8fb16d
test(badge): remove vertical page
thetaPC Apr 22, 2026
a90a769
test(tab-bar): add badge headers
thetaPC Apr 22, 2026
dab9757
test(tab-bar): add more layouts
thetaPC Apr 22, 2026
fc040a4
feat(badge): create size constant
thetaPC Apr 22, 2026
4d14936
docs(badge): update positioning utility comment for target
thetaPC Apr 22, 2026
7555cef
refactor(badge): use inset inline start
thetaPC Apr 22, 2026
b56e473
refactor(theme): remove rgb option
thetaPC Apr 22, 2026
9289827
feat(badge): update shape default for native
thetaPC Apr 22, 2026
cac393d
test(badge): update snapshots
thetaPC Apr 22, 2026
f3be02e
test(item): update badge snapshots
thetaPC Apr 22, 2026
2064468
test(badge): update more snapshots
thetaPC Apr 22, 2026
0237e00
test(tab-bar): update badge snapshots
thetaPC Apr 22, 2026
f951c5d
chore(): add updated snapshots
Ionitron Apr 22, 2026
16c6032
test(badge): update more snapshots
thetaPC Apr 22, 2026
fe25751
Merge branch 'FW-6837' of github.com:ionic-team/ionic-framework into …
thetaPC Apr 22, 2026
4de56c3
chore(badge): remove virtual prop theme
thetaPC Apr 22, 2026
286dbf8
refactor(badge): add constants
thetaPC Apr 22, 2026
d9f54cb
test(avatar): update snapshots to not be cut
thetaPC Apr 28, 2026
9a199bd
feat(badge): add large styles for ionic
thetaPC Apr 29, 2026
a5ab620
fix(badge): add mising letter spacing
thetaPC Apr 29, 2026
f3b59c2
feat(md): update content badge sizes
thetaPC Apr 29, 2026
9b8310b
test(tab-button): update badge snapshots
thetaPC Apr 29, 2026
0c5648c
test(avatar, button): clean up groups
thetaPC Apr 29, 2026
be75317
feat(ios): update sizes
thetaPC Apr 29, 2026
fd1cd35
Merge branch 'ionic-modular' of github.com:ionic-team/ionic-framework…
thetaPC Apr 29, 2026
dc3598a
chore(): run build
thetaPC Apr 29, 2026
c3b416a
test(avatar, button, tab-button): update filenames
thetaPC Apr 30, 2026
a8bd996
feat(badge): update line height for md
thetaPC Apr 30, 2026
9db6dfc
feat(badge): add line height to ios
thetaPC May 1, 2026
c6ed471
test(tab-button): update badge snapshots
thetaPC May 1, 2026
00440d3
fix(badge): use correct @prop syntax
thetaPC May 1, 2026
f7c8119
feat(avatar, button, tab-button): reinitialize badge manager on recon…
thetaPC May 1, 2026
8cdb4cd
feat(tab-button): reinitialize badge on layout change
thetaPC May 1, 2026
9d43ecc
feat(badge-position): watch badge size for arc-based repositioning
thetaPC May 1, 2026
ce00faf
feat(badge-position): improve rtl
thetaPC May 1, 2026
a0052b9
test(tab-bar): revert snapshot
thetaPC May 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
91 changes: 71 additions & 20 deletions core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -316,28 +316,79 @@ ion-badge,shadow
ion-badge,prop,color,"danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string & Record<never, never> | undefined,undefined,false,true
ion-badge,prop,hue,"bold" | "subtle" | undefined,undefined,false,false
ion-badge,prop,mode,"ios" | "md",undefined,false,false
ion-badge,prop,shape,"round | rectangular" | "soft" | undefined,undefined,false,false
ion-badge,prop,shape,"crisp" | "rectangular" | "round" | "soft" | undefined,undefined,false,false
ion-badge,prop,size,"large" | "medium" | "small" | undefined,undefined,false,false
ion-badge,prop,theme,"ios" | "md" | "ionic",undefined,false,false
ion-badge,prop,vertical,"bottom" | "top" | undefined,undefined,false,false
ion-badge,css-prop,--background,ionic
ion-badge,css-prop,--background,ios
ion-badge,css-prop,--background,md
ion-badge,css-prop,--color,ionic
ion-badge,css-prop,--color,ios
ion-badge,css-prop,--color,md
ion-badge,css-prop,--padding-bottom,ionic
ion-badge,css-prop,--padding-bottom,ios
ion-badge,css-prop,--padding-bottom,md
ion-badge,css-prop,--padding-end,ionic
ion-badge,css-prop,--padding-end,ios
ion-badge,css-prop,--padding-end,md
ion-badge,css-prop,--padding-start,ionic
ion-badge,css-prop,--padding-start,ios
ion-badge,css-prop,--padding-start,md
ion-badge,css-prop,--padding-top,ionic
ion-badge,css-prop,--padding-top,ios
ion-badge,css-prop,--padding-top,md
ion-badge,css-prop,--ion-badge-font-family
ion-badge,css-prop,--ion-badge-hue-bold-default-background
ion-badge,css-prop,--ion-badge-hue-bold-default-color
ion-badge,css-prop,--ion-badge-hue-bold-semantic-default-background
ion-badge,css-prop,--ion-badge-hue-bold-semantic-default-color
ion-badge,css-prop,--ion-badge-hue-subtle-default-background
ion-badge,css-prop,--ion-badge-hue-subtle-default-color
ion-badge,css-prop,--ion-badge-hue-subtle-semantic-default-background
ion-badge,css-prop,--ion-badge-hue-subtle-semantic-default-color
ion-badge,css-prop,--ion-badge-shape-crisp-border-radius
ion-badge,css-prop,--ion-badge-shape-rectangular-border-radius
ion-badge,css-prop,--ion-badge-shape-round-border-radius
ion-badge,css-prop,--ion-badge-shape-soft-border-radius
ion-badge,css-prop,--ion-badge-size-large-content-font-size
ion-badge,css-prop,--ion-badge-size-large-content-font-weight
ion-badge,css-prop,--ion-badge-size-large-content-height
ion-badge,css-prop,--ion-badge-size-large-content-icon-height
ion-badge,css-prop,--ion-badge-size-large-content-icon-width
ion-badge,css-prop,--ion-badge-size-large-content-letter-spacing
ion-badge,css-prop,--ion-badge-size-large-content-line-height
ion-badge,css-prop,--ion-badge-size-large-content-min-height
ion-badge,css-prop,--ion-badge-size-large-content-min-width
ion-badge,css-prop,--ion-badge-size-large-content-padding-bottom
ion-badge,css-prop,--ion-badge-size-large-content-padding-end
ion-badge,css-prop,--ion-badge-size-large-content-padding-start
ion-badge,css-prop,--ion-badge-size-large-content-padding-top
ion-badge,css-prop,--ion-badge-size-large-dot-height
ion-badge,css-prop,--ion-badge-size-large-dot-min-width
ion-badge,css-prop,--ion-badge-size-large-dot-padding-bottom
ion-badge,css-prop,--ion-badge-size-large-dot-padding-end
ion-badge,css-prop,--ion-badge-size-large-dot-padding-start
ion-badge,css-prop,--ion-badge-size-large-dot-padding-top
ion-badge,css-prop,--ion-badge-size-medium-content-font-size
ion-badge,css-prop,--ion-badge-size-medium-content-font-weight
ion-badge,css-prop,--ion-badge-size-medium-content-height
ion-badge,css-prop,--ion-badge-size-medium-content-icon-height
ion-badge,css-prop,--ion-badge-size-medium-content-icon-width
ion-badge,css-prop,--ion-badge-size-medium-content-letter-spacing
ion-badge,css-prop,--ion-badge-size-medium-content-line-height
ion-badge,css-prop,--ion-badge-size-medium-content-min-height
ion-badge,css-prop,--ion-badge-size-medium-content-min-width
ion-badge,css-prop,--ion-badge-size-medium-content-padding-bottom
ion-badge,css-prop,--ion-badge-size-medium-content-padding-end
ion-badge,css-prop,--ion-badge-size-medium-content-padding-start
ion-badge,css-prop,--ion-badge-size-medium-content-padding-top
ion-badge,css-prop,--ion-badge-size-medium-dot-height
ion-badge,css-prop,--ion-badge-size-medium-dot-min-width
ion-badge,css-prop,--ion-badge-size-medium-dot-padding-bottom
ion-badge,css-prop,--ion-badge-size-medium-dot-padding-end
ion-badge,css-prop,--ion-badge-size-medium-dot-padding-start
ion-badge,css-prop,--ion-badge-size-medium-dot-padding-top
ion-badge,css-prop,--ion-badge-size-small-content-font-size
ion-badge,css-prop,--ion-badge-size-small-content-font-weight
ion-badge,css-prop,--ion-badge-size-small-content-height
ion-badge,css-prop,--ion-badge-size-small-content-icon-height
ion-badge,css-prop,--ion-badge-size-small-content-icon-width
ion-badge,css-prop,--ion-badge-size-small-content-letter-spacing
ion-badge,css-prop,--ion-badge-size-small-content-line-height
ion-badge,css-prop,--ion-badge-size-small-content-min-height
ion-badge,css-prop,--ion-badge-size-small-content-min-width
ion-badge,css-prop,--ion-badge-size-small-content-padding-bottom
ion-badge,css-prop,--ion-badge-size-small-content-padding-end
ion-badge,css-prop,--ion-badge-size-small-content-padding-start
ion-badge,css-prop,--ion-badge-size-small-content-padding-top
ion-badge,css-prop,--ion-badge-size-small-dot-height
ion-badge,css-prop,--ion-badge-size-small-dot-min-width
ion-badge,css-prop,--ion-badge-size-small-dot-padding-bottom
ion-badge,css-prop,--ion-badge-size-small-dot-padding-end
ion-badge,css-prop,--ion-badge-size-small-dot-padding-start
ion-badge,css-prop,--ion-badge-size-small-dot-padding-top

ion-breadcrumb,shadow
ion-breadcrumb,prop,active,boolean,false,false,false
Expand Down
42 changes: 18 additions & 24 deletions core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ActionSheetButton } from "./components/action-sheet/action-sheet-interf
import { OverlayEventDetail } from "./utils/overlays-interface";
import { IonicSafeString } from "./utils/sanitization";
import { AlertButton, AlertInput } from "./components/alert/alert-interface";
import { IonBadgeHue, IonBadgeShape, IonBadgeSize, IonBadgeVerticalPosition } from "./components/badge/badge.interfaces";
import { RouteID, RouterDirection, RouterEventDetail, RouteWrite } from "./components/router/utils/interface";
import { BreadcrumbCollapsedClickEventDetail } from "./components/breadcrumb/breadcrumb-interface";
import { CheckboxChangeEventDetail } from "./components/checkbox/checkbox-interface";
Expand Down Expand Up @@ -52,6 +53,7 @@ export { ActionSheetButton } from "./components/action-sheet/action-sheet-interf
export { OverlayEventDetail } from "./utils/overlays-interface";
export { IonicSafeString } from "./utils/sanitization";
export { AlertButton, AlertInput } from "./components/alert/alert-interface";
export { IonBadgeHue, IonBadgeShape, IonBadgeSize, IonBadgeVerticalPosition } from "./components/badge/badge.interfaces";
export { RouteID, RouterDirection, RouterEventDetail, RouteWrite } from "./components/router/utils/interface";
export { BreadcrumbCollapsedClickEventDetail } from "./components/breadcrumb/breadcrumb-interface";
export { CheckboxChangeEventDetail } from "./components/checkbox/checkbox-interface";
Expand Down Expand Up @@ -471,29 +473,25 @@ export namespace Components {
*/
"color"?: Color;
/**
* Set to `"bold"` for a badge with vibrant, bold colors or to `"subtle"` for a badge with muted, subtle colors. Only applies to the `ionic` theme.
* Set to `"bold"` for a badge with vibrant, bold colors or to `"subtle"` for a badge with muted, subtle colors. Defaults to `"bold"` if both the hue property and theme config are unset.
*/
"hue"?: 'bold' | 'subtle';
"hue"?: IonBadgeHue;
/**
* The mode determines the platform behaviors of the component.
*/
"mode"?: "ios" | "md";
/**
* Set to `"rectangular"` for non-rounded corners. Set to `"soft"` for slightly rounded corners. Set to `"round"` for fully rounded corners. Defaults to `"round"` for the `ionic` theme, undefined for all other themes.
* Set to `"crisp"` for a badge with even slightly rounded corners, `"soft"` for a badge with slightly rounded corners, `"round"` for a badge with fully rounded corners, or `"rectangular"` for a badge without rounded corners. Defaults to `"soft"` if both the shape property and theme config are unset.
*/
"shape"?: 'soft' | 'round | rectangular';
"shape"?: IonBadgeShape;
/**
* Set to `"small"` for a small badge. Set to `"medium"` for a medium badge. Set to `"large"` for a large badge, when it is empty (no text or icon). Defaults to `"small"` for the `ionic` theme, undefined for all other themes.
* Set to `"small"` for a smaller size. Set to `"medium"` for a medium size. Set to `"large"` for a larger size. Defaults to `"small"` if both the size property and theme config are unset.
*/
"size"?: 'small' | 'medium' | 'large';
/**
* The theme determines the visual appearance of the component.
*/
"theme"?: "ios" | "md" | "ionic";
"size"?: IonBadgeSize;
/**
* Set to `"top"` to position the badge on top right absolute position of the parent element. Set to `"bottom"` to position the badge on bottom right absolute position of the parent element.
*/
"vertical"?: 'top' | 'bottom';
"vertical"?: IonBadgeVerticalPosition;
}
interface IonBreadcrumb {
/**
Expand Down Expand Up @@ -900,7 +898,7 @@ export namespace Components {
*/
"shape"?: IonChipShape;
/**
* Set to `"small"` for a chip with less height and padding. Defaults to `"large"` if both the size property and theme config are unset.
* Set to `"small"` for a chip with less height and padding, or `"large"` for a chip with more height and padding. Defaults to `"large"` if both the size property and theme config are unset.
*/
"size"?: IonChipSize;
}
Expand Down Expand Up @@ -6398,29 +6396,25 @@ declare namespace LocalJSX {
*/
"color"?: Color;
/**
* Set to `"bold"` for a badge with vibrant, bold colors or to `"subtle"` for a badge with muted, subtle colors. Only applies to the `ionic` theme.
* Set to `"bold"` for a badge with vibrant, bold colors or to `"subtle"` for a badge with muted, subtle colors. Defaults to `"bold"` if both the hue property and theme config are unset.
*/
"hue"?: 'bold' | 'subtle';
"hue"?: IonBadgeHue;
/**
* The mode determines the platform behaviors of the component.
*/
"mode"?: "ios" | "md";
/**
* Set to `"rectangular"` for non-rounded corners. Set to `"soft"` for slightly rounded corners. Set to `"round"` for fully rounded corners. Defaults to `"round"` for the `ionic` theme, undefined for all other themes.
* Set to `"crisp"` for a badge with even slightly rounded corners, `"soft"` for a badge with slightly rounded corners, `"round"` for a badge with fully rounded corners, or `"rectangular"` for a badge without rounded corners. Defaults to `"soft"` if both the shape property and theme config are unset.
*/
"shape"?: 'soft' | 'round | rectangular';
"shape"?: IonBadgeShape;
/**
* Set to `"small"` for a small badge. Set to `"medium"` for a medium badge. Set to `"large"` for a large badge, when it is empty (no text or icon). Defaults to `"small"` for the `ionic` theme, undefined for all other themes.
* Set to `"small"` for a smaller size. Set to `"medium"` for a medium size. Set to `"large"` for a larger size. Defaults to `"small"` if both the size property and theme config are unset.
*/
"size"?: 'small' | 'medium' | 'large';
/**
* The theme determines the visual appearance of the component.
*/
"theme"?: "ios" | "md" | "ionic";
"size"?: IonBadgeSize;
/**
* Set to `"top"` to position the badge on top right absolute position of the parent element. Set to `"bottom"` to position the badge on bottom right absolute position of the parent element.
*/
"vertical"?: 'top' | 'bottom';
"vertical"?: IonBadgeVerticalPosition;
}
interface IonBreadcrumb {
/**
Expand Down Expand Up @@ -6862,7 +6856,7 @@ declare namespace LocalJSX {
*/
"shape"?: IonChipShape;
/**
* Set to `"small"` for a chip with less height and padding. Defaults to `"large"` if both the size property and theme config are unset.
* Set to `"small"` for a chip with less height and padding, or `"large"` for a chip with more height and padding. Defaults to `"large"` if both the size property and theme config are unset.
*/
"size"?: IonChipSize;
}
Expand Down
73 changes: 0 additions & 73 deletions core/src/components/avatar/avatar.ionic.scss
Original file line number Diff line number Diff line change
Expand Up @@ -169,79 +169,6 @@
height: globals.$ion-scale-800;
}

// Avatar Badge Empty (hint)
// --------------------------------------------------

:host ::slotted(ion-badge.badge-vertical-top:empty) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These styles were removed in favor of the positionBadge utility that generates the position. The same goes for any styles like these for the other files.

@include globals.transform(translate(globals.$ion-scale-050, calc(globals.$ion-scale-050 * -1)));
}

:host(.avatar-xxsmall) ::slotted(ion-badge.badge-vertical-top:empty) {
@include globals.transform(translate(globals.$ion-scale-100, calc(globals.$ion-scale-100 * -1)));
}

:host ::slotted(ion-badge.badge-vertical-bottom:empty) {
@include globals.transform(translate(0, globals.$ion-scale-100));
}

:host(.avatar-xxsmall) ::slotted(ion-badge.badge-vertical-bottom:empty) {
@include globals.transform(translate(globals.$ion-scale-100, globals.$ion-scale-100));
}

// Avatar Badge Bottom (hint)
// --------------------------------------------------

:host ::slotted(ion-badge.badge-vertical-bottom:not(:empty)) {
@include globals.transform(translate(50%, 50%));
}

:host(.avatar-xxsmall) ::slotted(ion-badge.badge-vertical-bottom:not(:empty)) {
@include globals.position(null, globals.$ion-scale-100, globals.$ion-scale-100, null);
@include globals.transform(translate(100%, 100%));
}

:host(.avatar-xsmall) ::slotted(ion-badge.badge-vertical-bottom:not(:empty)) {
@include globals.position(null, calc(globals.$ion-scale-050 * -1), calc(globals.$ion-scale-050 * -1), null);
}

:host(.avatar-small) ::slotted(ion-badge.badge-vertical-bottom:not(:empty)),
:host(.avatar-medium) ::slotted(ion-badge.badge-vertical-bottom:not(:empty)),
:host(.avatar-large) ::slotted(ion-badge.badge-vertical-bottom:not(:empty)) {
@include globals.position(null, globals.$ion-scale-050, globals.$ion-scale-050, null);
}

:host(.avatar-xlarge) ::slotted(ion-badge.badge-vertical-bottom:not(:empty)) {
@include globals.position(null, globals.$ion-scale-150, globals.$ion-scale-150, null);
}

// Avatar Badge Top (hint)
// --------------------------------------------------

:host ::slotted(ion-badge.badge-vertical-top:not(:empty)) {
@include globals.transform(translate(50%, -50%));
}

:host(.avatar-xxsmall) ::slotted(ion-badge.badge-vertical-top:not(:empty)) {
@include globals.position(globals.$ion-scale-050, 0, null, null);
Comment thread
brandyscarney marked this conversation as resolved.
}

:host(.avatar-xsmall) ::slotted(ion-badge.badge-vertical-top:not(:empty)) {
@include globals.position(globals.$ion-scale-100, calc(globals.$ion-scale-050 * -1), null, null);
}

:host(.avatar-small) ::slotted(ion-badge.badge-vertical-top:not(:empty)),
:host(.avatar-medium) ::slotted(ion-badge.badge-vertical-top:not(:empty)) {
@include globals.position(globals.$ion-scale-150, 0, null, null);
}

:host(.avatar-large) ::slotted(ion-badge.badge-vertical-top:not(:empty)) {
@include globals.position(globals.$ion-scale-150, globals.$ion-scale-050, null, null);
}

:host(.avatar-xlarge) ::slotted(ion-badge.badge-vertical-top:not(:empty)) {
@include globals.position(globals.$ion-scale-150, globals.$ion-scale-150, null, null);
}

// Avatar Disabled
// --------------------------------------------------
:host(.avatar-disabled)::after {
Expand Down
19 changes: 0 additions & 19 deletions core/src/components/avatar/avatar.md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,3 @@
width: $avatar-md-width;
height: $avatar-md-height;
}

// Avatar Empty Badge (hint)
// --------------------------------------------------

::slotted(ion-badge.badge-vertical-top:empty) {
@include globals.transform(translate(-50%, 50%));
}

::slotted(ion-badge.badge-vertical-bottom:empty) {
@include globals.transform(translateX(-100%));
}

:host ::slotted(ion-badge.badge-vertical-top:not(:empty)) {
@include globals.transform(translate(0, 100%));
}

:host ::slotted(ion-badge.badge-vertical-bottom:not(:empty)) {
@include globals.transform(translate(0, -100%));
}
34 changes: 27 additions & 7 deletions core/src/components/avatar/avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ComponentInterface } from '@stencil/core';
import { Component, Element, Host, Prop, h } from '@stencil/core';
import { createBadgeManager } from '@utils/badge-position';

import { getIonTheme } from '../../global/ionic-global';

Expand All @@ -19,6 +20,12 @@ import { getIonTheme } from '../../global/ionic-global';
export class Avatar implements ComponentInterface {
@Element() el!: HTMLElement;

private hasLoaded = false;

private badgeManager = createBadgeManager(this.el, () => ({
target: this.el,
}));

/**
* Set to `"xxsmall"` for the smallest size.
* Set to `"xsmall"` for a very small size.
Expand All @@ -45,6 +52,21 @@ export class Avatar implements ComponentInterface {
*/
@Prop() disabled = false;

connectedCallback() {
if (this.hasLoaded) {
this.badgeManager.init();
}
}

componentDidLoad() {
Comment thread
ShaneK marked this conversation as resolved.
this.hasLoaded = true;
this.badgeManager.init();
}

disconnectedCallback() {
this.badgeManager.destroy();
}

get hasImage() {
return !!this.el.querySelector('ion-img') || !!this.el.querySelector('img');
}
Expand All @@ -53,15 +75,13 @@ export class Avatar implements ComponentInterface {
return !!this.el.querySelector('ion-icon');
}

private onSlotChanged = () => {
this.badgeManager.onSlotChanged();
};

private getSize(): string | undefined {
const theme = getIonTheme(this);
const { size } = this;

// TODO(ROU-10752): Remove theme check when sizes are defined for all themes.
if (theme !== 'ionic') {
return undefined;
}

if (size === undefined) {
return 'medium';
}
Expand Down Expand Up @@ -102,7 +122,7 @@ export class Avatar implements ComponentInterface {
[`avatar-disabled`]: disabled,
}}
>
<slot></slot>
<slot onSlotchange={this.onSlotChanged}></slot>
</Host>
);
}
Expand Down
Loading
Loading