feat(avatar): add styles for large size in ionic theme (#29541)
Issue number: internal --------- ## What is the current behavior? Avatar does not have styles for the `"large"` size in the ionic theme. ## What is the new behavior? - Adds the styles for the large size (width, height, padding, font size) - Adds e2e test for large size to the existing avatar test for sizes ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information [Preview](https://ionic-framework-git-rou-10736-ionic1.vercel.app/src/components/avatar/test/size?ionic:theme=ionic)
@ -184,7 +184,7 @@ ion-app,prop,theme,"ios" | "md" | "ionic",undefined,false,false
|
||||
|
||||
ion-avatar,shadow
|
||||
ion-avatar,prop,mode,"ios" | "md",undefined,false,false
|
||||
ion-avatar,prop,size,"medium" | "small" | undefined,undefined,false,false
|
||||
ion-avatar,prop,size,"large" | "medium" | "small" | undefined,undefined,false,false
|
||||
ion-avatar,prop,theme,"ios" | "md" | "ionic",undefined,false,false
|
||||
ion-avatar,css-prop,--border-radius,ionic
|
||||
ion-avatar,css-prop,--border-radius,ios
|
||||
|
8
core/src/components.d.ts
vendored
@ -336,9 +336,9 @@ export namespace Components {
|
||||
*/
|
||||
"mode"?: "ios" | "md";
|
||||
/**
|
||||
* Set to `"small"` for a compact size, or to `"medium"` for the default height and width. Defaults to `"medium"` for the `ionic` theme, undefined for all other themes.
|
||||
* Set to `"small"` for a compact size, `"medium"` for the default height and width, or to `"large"` for a larger size. Defaults to `"medium"` for the `ionic` theme, undefined for all other themes.
|
||||
*/
|
||||
"size"?: 'small' | 'medium';
|
||||
"size"?: 'small' | 'medium' | 'large';
|
||||
/**
|
||||
* The theme determines the visual appearance of the component.
|
||||
*/
|
||||
@ -5568,9 +5568,9 @@ declare namespace LocalJSX {
|
||||
*/
|
||||
"mode"?: "ios" | "md";
|
||||
/**
|
||||
* Set to `"small"` for a compact size, or to `"medium"` for the default height and width. Defaults to `"medium"` for the `ionic` theme, undefined for all other themes.
|
||||
* Set to `"small"` for a compact size, `"medium"` for the default height and width, or to `"large"` for a larger size. Defaults to `"medium"` for the `ionic` theme, undefined for all other themes.
|
||||
*/
|
||||
"size"?: 'small' | 'medium';
|
||||
"size"?: 'small' | 'medium' | 'large';
|
||||
/**
|
||||
* The theme determines the visual appearance of the component.
|
||||
*/
|
||||
|
@ -47,3 +47,13 @@
|
||||
|
||||
font-size: globals.$ionic-font-size-400;
|
||||
}
|
||||
|
||||
:host(.avatar-large) {
|
||||
--padding-end: #{globals.$ionic-space-250};
|
||||
--padding-start: #{globals.$ionic-space-250};
|
||||
|
||||
width: globals.$ionic-scale-1200;
|
||||
height: globals.$ionic-scale-1200;
|
||||
|
||||
font-size: globals.$ionic-font-size-450;
|
||||
}
|
||||
|
@ -20,11 +20,12 @@ export class Avatar implements ComponentInterface {
|
||||
@Element() el!: HTMLElement;
|
||||
|
||||
/**
|
||||
* Set to `"small"` for a compact size, or to `"medium"` for the default height and width.
|
||||
* Set to `"small"` for a compact size, `"medium"` for the default height and width, or to
|
||||
* `"large"` for a larger size.
|
||||
*
|
||||
* Defaults to `"medium"` for the `ionic` theme, undefined for all other themes.
|
||||
*/
|
||||
@Prop() size?: 'small' | 'medium';
|
||||
@Prop() size?: 'small' | 'medium' | 'large';
|
||||
|
||||
get hasImage() {
|
||||
return !!this.el.querySelector('ion-img') || !!this.el.querySelector('img');
|
||||
|
@ -95,5 +95,50 @@ configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ config, screens
|
||||
await expect(avatar).toHaveScreenshot(screenshot(`avatar-size-medium-image`));
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('large', () => {
|
||||
test('should not have visual regressions when containing text', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<ion-avatar size="large">AB</ion-avatar>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const avatar = page.locator('ion-avatar');
|
||||
|
||||
await expect(avatar).toHaveScreenshot(screenshot(`avatar-size-large-text`));
|
||||
});
|
||||
|
||||
test('should not have visual regressions when containing an icon', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<ion-avatar size="large">
|
||||
<ion-icon name="person-outline"></ion-icon>
|
||||
</ion-avatar>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const avatar = page.locator('ion-avatar');
|
||||
|
||||
await expect(avatar).toHaveScreenshot(screenshot(`avatar-size-large-icon`));
|
||||
});
|
||||
|
||||
test('should not have visual regressions when containing an image', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<ion-avatar size="large">
|
||||
<img src="/src/components/avatar/test/avatar.svg"/>
|
||||
</ion-avatar>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const avatar = page.locator('ion-avatar');
|
||||
|
||||
await expect(avatar).toHaveScreenshot(screenshot(`avatar-size-large-image`));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
After Width: | Height: | Size: 652 B |
After Width: | Height: | Size: 578 B |
After Width: | Height: | Size: 592 B |
After Width: | Height: | Size: 740 B |
After Width: | Height: | Size: 688 B |
After Width: | Height: | Size: 728 B |
After Width: | Height: | Size: 798 B |
After Width: | Height: | Size: 819 B |
After Width: | Height: | Size: 721 B |
@ -45,6 +45,7 @@
|
||||
<div class="container">
|
||||
<ion-avatar size="small">AB</ion-avatar>
|
||||
<ion-avatar size="medium">AB</ion-avatar>
|
||||
<ion-avatar size="large">AB</ion-avatar>
|
||||
</div>
|
||||
|
||||
<h2>Icons</h2>
|
||||
@ -55,6 +56,9 @@
|
||||
<ion-avatar size="medium">
|
||||
<ion-icon name="person-outline"></ion-icon>
|
||||
</ion-avatar>
|
||||
<ion-avatar size="large">
|
||||
<ion-icon name="person-outline"></ion-icon>
|
||||
</ion-avatar>
|
||||
</div>
|
||||
|
||||
<h2>Images</h2>
|
||||
@ -65,6 +69,9 @@
|
||||
<ion-avatar size="medium">
|
||||
<img src="/src/components/avatar/test/avatar.svg" />
|
||||
</ion-avatar>
|
||||
<ion-avatar size="large">
|
||||
<img src="/src/components/avatar/test/avatar.svg" />
|
||||
</ion-avatar>
|
||||
</div>
|
||||
</ion-content>
|
||||
</ion-app>
|
||||
|