Skip to content

Commit 2db15bb

Browse files
authored
feat(avatar): support new badge hint feature (#30223)
Issue number: internal --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Added css on avatar to support the new badge vertical prop on md, ios and ionic theme - Added support on ionic theme for different position, according to the Avatar size. - There's no figma for md/iOS implementation, so just added for now a best effort on how it looks. - re-organized tests and added new screenshots for the avatar use-case. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer for more information. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> - [Badge hint](https://ionic-framework-git-rou-11628-ionic1.vercel.app/src/components/badge/test/hint?ionic:theme=ionic)
1 parent 17f3046 commit 2db15bb

23 files changed

+104
-4
lines changed

core/src/components/avatar/avatar.common.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
@include border-radius(var(--border-radius));
1111

1212
display: block;
13+
14+
position: relative;
1315
}
1416

1517
::slotted(ion-img),

core/src/components/avatar/avatar.ionic.scss

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,22 @@
152152
width: globals.$ion-scale-1000;
153153
height: globals.$ion-scale-1000;
154154
}
155+
156+
// Avatar Empty Badge (hint)
157+
// --------------------------------------------------
158+
159+
:host(.avatar-xxsmall) ::slotted(ion-badge.badge-vertical-top:empty) {
160+
transform: translate(globals.$ion-scale-100, calc(globals.$ion-scale-100 * -1));
161+
}
162+
163+
:host(:not(.avatar-xxsmall)) ::slotted(ion-badge.badge-vertical-top:empty) {
164+
transform: translate(globals.$ion-scale-050, calc(globals.$ion-scale-050 * -1));
165+
}
166+
167+
:host(.avatar-xxsmall) ::slotted(ion-badge.badge-vertical-bottom:empty) {
168+
transform: translate(globals.$ion-scale-100, calc(globals.$ion-scale-100));
169+
}
170+
171+
:host(:not(.avatar-xxsmall)) ::slotted(ion-badge.badge-vertical-bottom:empty) {
172+
transform: translate(0, globals.$ion-scale-100);
173+
}

core/src/components/avatar/avatar.md.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,14 @@
1010
width: $avatar-md-width;
1111
height: $avatar-md-height;
1212
}
13+
14+
// Avatar Empty Badge (hint)
15+
// --------------------------------------------------
16+
17+
::slotted(ion-badge.badge-vertical-top:empty) {
18+
transform: translate(-50%, 50%);
19+
}
20+
21+
::slotted(ion-badge.badge-vertical-bottom:empty) {
22+
transform: translateX(-100%);
23+
}

core/src/components/badge/test/hint/badge.e2e.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,23 @@ import { expect } from '@playwright/test';
22
import { configs, test } from '@utils/test/playwright';
33

44
configs({ directions: ['ltr'], modes: ['md', 'ios', 'ionic-md'] }).forEach(({ config, screenshot, title }) => {
5-
test.describe(title('badge: hint'), () => {
5+
test.describe(title('badge: hint empty'), () => {
66
test('should not have visual regressions', async ({ page }) => {
77
await page.goto('/src/components/badge/test/hint', config);
88

9-
const container = page.locator('ion-list');
9+
const container = page.locator('#empty');
1010

11-
await expect(container).toHaveScreenshot(screenshot(`badge-hint`));
11+
await expect(container).toHaveScreenshot(screenshot(`badge-hint-empty`));
12+
});
13+
});
14+
15+
test.describe(title('badge: hint inside avatar'), () => {
16+
test('should not have visual regressions', async ({ page }) => {
17+
await page.goto('/src/components/badge/test/hint', config);
18+
19+
const container = page.locator('#avatar');
20+
21+
await expect(container).toHaveScreenshot(screenshot(`badge-hint-avatar`));
1222
});
1323
});
1424
});
13.9 KB
Loading
16.4 KB
Loading
14.8 KB
Loading
7.22 KB
Loading
9.2 KB
Loading
11.2 KB
Loading

0 commit comments

Comments
 (0)