feat(avatar): add styles for xlarge size in ionic theme (#29549)
Issue number: internal --------- ## What is the current behavior? Avatar does not have styles for the `"xlarge"` size in the ionic theme. ## What is the new behavior? - Adds the styles for the xlarge size (width, height, padding, font size and line height) - Adds e2e test for xlarge 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-10737-ionic1.vercel.app/src/components/avatar/test/size?ionic:theme=ionic) --------- Co-authored-by: Giuliana Silva <108938618+OS-giulianasilva@users.noreply.github.com>
@@ -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,"large" | "medium" | "small" | "xsmall" | undefined,undefined,false,false
|
||||
ion-avatar,prop,size,"large" | "medium" | "small" | "xlarge" | "xsmall" | 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 `"xsmall"` for the smallest size, `"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.
|
||||
* Set to `"xsmall"` for the smallest size, `"small"` for a compact size, `"medium"` for the default height and width, `"large"` for a larger size, or `"xlarge"` for the largest dimensions. Defaults to `"medium"` for the `ionic` theme, undefined for all other themes.
|
||||
*/
|
||||
"size"?: `xsmall` | 'small' | 'medium' | 'large';
|
||||
"size"?: `xsmall` | 'small' | 'medium' | 'large' | 'xlarge';
|
||||
/**
|
||||
* The theme determines the visual appearance of the component.
|
||||
*/
|
||||
@@ -5568,9 +5568,9 @@ declare namespace LocalJSX {
|
||||
*/
|
||||
"mode"?: "ios" | "md";
|
||||
/**
|
||||
* Set to `"xsmall"` for the smallest size, `"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.
|
||||
* Set to `"xsmall"` for the smallest size, `"small"` for a compact size, `"medium"` for the default height and width, `"large"` for a larger size, or `"xlarge"` for the largest dimensions. Defaults to `"medium"` for the `ionic` theme, undefined for all other themes.
|
||||
*/
|
||||
"size"?: `xsmall` | 'small' | 'medium' | 'large';
|
||||
"size"?: `xsmall` | 'small' | 'medium' | 'large' | 'xlarge';
|
||||
/**
|
||||
* The theme determines the visual appearance of the component.
|
||||
*/
|
||||
|
||||
@@ -71,3 +71,15 @@
|
||||
|
||||
font-size: globals.$ionic-font-size-450;
|
||||
}
|
||||
|
||||
:host(.avatar-xlarge) {
|
||||
--padding-end: #{globals.$ionic-space-300};
|
||||
--padding-start: #{globals.$ionic-space-300};
|
||||
|
||||
width: globals.$ionic-scale-1400;
|
||||
height: globals.$ionic-scale-1400;
|
||||
|
||||
font-size: globals.$ionic-font-size-550;
|
||||
|
||||
line-height: globals.$ionic-line-height-700;
|
||||
}
|
||||
|
||||
@@ -21,11 +21,12 @@ export class Avatar implements ComponentInterface {
|
||||
|
||||
/**
|
||||
* Set to `"xsmall"` for the smallest size, `"small"` for a compact size, `"medium"`
|
||||
* for the default height and width, or to `"large"` for a larger size.
|
||||
* for the default height and width, `"large"` for a larger size, or `"xlarge"` for
|
||||
* the largest dimensions.
|
||||
*
|
||||
* Defaults to `"medium"` for the `ionic` theme, undefined for all other themes.
|
||||
*/
|
||||
@Prop() size?: `xsmall` | 'small' | 'medium' | 'large';
|
||||
@Prop() size?: `xsmall` | 'small' | 'medium' | 'large' | 'xlarge';
|
||||
|
||||
get hasImage() {
|
||||
return !!this.el.querySelector('ion-img') || !!this.el.querySelector('img');
|
||||
|
||||
@@ -185,5 +185,50 @@ configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ config, screens
|
||||
await expect(avatar).toHaveScreenshot(screenshot(`avatar-size-large-image`));
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('xlarge', () => {
|
||||
test('should not have visual regressions when containing text', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<ion-avatar size="xlarge">AB</ion-avatar>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const avatar = page.locator('ion-avatar');
|
||||
|
||||
await expect(avatar).toHaveScreenshot(screenshot(`avatar-size-xlarge-text`));
|
||||
});
|
||||
|
||||
test('should not have visual regressions when containing an icon', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<ion-avatar size="xlarge">
|
||||
<ion-icon name="person-outline"></ion-icon>
|
||||
</ion-avatar>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const avatar = page.locator('ion-avatar');
|
||||
|
||||
await expect(avatar).toHaveScreenshot(screenshot(`avatar-size-xlarge-icon`));
|
||||
});
|
||||
|
||||
test('should not have visual regressions when containing an image', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<ion-avatar size="xlarge">
|
||||
<img src="/src/components/avatar/test/avatar.svg"/>
|
||||
</ion-avatar>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const avatar = page.locator('ion-avatar');
|
||||
|
||||
await expect(avatar).toHaveScreenshot(screenshot(`avatar-size-xlarge-image`));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
After Width: | Height: | Size: 784 B |
|
After Width: | Height: | Size: 671 B |
|
After Width: | Height: | Size: 771 B |
|
After Width: | Height: | Size: 849 B |
|
After Width: | Height: | Size: 780 B |
|
After Width: | Height: | Size: 866 B |
|
After Width: | Height: | Size: 957 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 871 B |
@@ -47,6 +47,7 @@
|
||||
<ion-avatar size="small">AB</ion-avatar>
|
||||
<ion-avatar size="medium">AB</ion-avatar>
|
||||
<ion-avatar size="large">AB</ion-avatar>
|
||||
<ion-avatar size="xlarge">AB</ion-avatar>
|
||||
</div>
|
||||
|
||||
<h2>Icons</h2>
|
||||
@@ -63,6 +64,9 @@
|
||||
<ion-avatar size="large">
|
||||
<ion-icon name="person-outline"></ion-icon>
|
||||
</ion-avatar>
|
||||
<ion-avatar size="xlarge">
|
||||
<ion-icon name="person-outline"></ion-icon>
|
||||
</ion-avatar>
|
||||
</div>
|
||||
|
||||
<h2>Images</h2>
|
||||
@@ -79,6 +83,9 @@
|
||||
<ion-avatar size="large">
|
||||
<img src="/src/components/avatar/test/avatar.svg" />
|
||||
</ion-avatar>
|
||||
<ion-avatar size="xlarge">
|
||||
<img src="/src/components/avatar/test/avatar.svg" />
|
||||
</ion-avatar>
|
||||
</div>
|
||||
</ion-content>
|
||||
</ion-app>
|
||||
|
||||