feat(avatar): add styles for xsmall size in ionic theme (#29548)
Issue number: internal --------- ## What is the current behavior? Avatar does not have styles for the `"xsmall"` size in the ionic theme. ## What is the new behavior? - Adds the styles for the xsmall size (width, height, padding, font size, font weight and line height) - Adds e2e test for xsmall 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-10733-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,shadow
|
||||||
ion-avatar,prop,mode,"ios" | "md",undefined,false,false
|
ion-avatar,prop,mode,"ios" | "md",undefined,false,false
|
||||||
ion-avatar,prop,size,"large" | "medium" | "small" | undefined,undefined,false,false
|
ion-avatar,prop,size,"large" | "medium" | "small" | "xsmall" | undefined,undefined,false,false
|
||||||
ion-avatar,prop,theme,"ios" | "md" | "ionic",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,ionic
|
||||||
ion-avatar,css-prop,--border-radius,ios
|
ion-avatar,css-prop,--border-radius,ios
|
||||||
|
8
core/src/components.d.ts
vendored
@ -336,9 +336,9 @@ export namespace Components {
|
|||||||
*/
|
*/
|
||||||
"mode"?: "ios" | "md";
|
"mode"?: "ios" | "md";
|
||||||
/**
|
/**
|
||||||
* 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.
|
* 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.
|
||||||
*/
|
*/
|
||||||
"size"?: 'small' | 'medium' | 'large';
|
"size"?: `xsmall` | 'small' | 'medium' | 'large';
|
||||||
/**
|
/**
|
||||||
* The theme determines the visual appearance of the component.
|
* The theme determines the visual appearance of the component.
|
||||||
*/
|
*/
|
||||||
@ -5568,9 +5568,9 @@ declare namespace LocalJSX {
|
|||||||
*/
|
*/
|
||||||
"mode"?: "ios" | "md";
|
"mode"?: "ios" | "md";
|
||||||
/**
|
/**
|
||||||
* 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.
|
* 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.
|
||||||
*/
|
*/
|
||||||
"size"?: 'small' | 'medium' | 'large';
|
"size"?: `xsmall` | 'small' | 'medium' | 'large';
|
||||||
/**
|
/**
|
||||||
* The theme determines the visual appearance of the component.
|
* The theme determines the visual appearance of the component.
|
||||||
*/
|
*/
|
||||||
|
@ -28,6 +28,20 @@
|
|||||||
// Avatar Sizes
|
// Avatar Sizes
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
|
:host(.avatar-xsmall) {
|
||||||
|
--padding-end: #{globals.$ionic-space-050};
|
||||||
|
--padding-start: #{globals.$ionic-space-050};
|
||||||
|
|
||||||
|
width: globals.$ionic-scale-600;
|
||||||
|
height: globals.$ionic-scale-600;
|
||||||
|
|
||||||
|
font-size: globals.$ionic-font-size-300;
|
||||||
|
|
||||||
|
font-weight: globals.$ionic-font-weight-medium;
|
||||||
|
|
||||||
|
line-height: globals.$ionic-line-height-500;
|
||||||
|
}
|
||||||
|
|
||||||
:host(.avatar-small) {
|
:host(.avatar-small) {
|
||||||
--padding-end: #{globals.$ionic-space-150};
|
--padding-end: #{globals.$ionic-space-150};
|
||||||
--padding-start: #{globals.$ionic-space-150};
|
--padding-start: #{globals.$ionic-space-150};
|
||||||
|
@ -20,12 +20,12 @@ export class Avatar implements ComponentInterface {
|
|||||||
@Element() el!: HTMLElement;
|
@Element() el!: HTMLElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set to `"small"` for a compact size, `"medium"` for the default height and width, or to
|
* Set to `"xsmall"` for the smallest size, `"small"` for a compact size, `"medium"`
|
||||||
* `"large"` for a larger size.
|
* 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.
|
* Defaults to `"medium"` for the `ionic` theme, undefined for all other themes.
|
||||||
*/
|
*/
|
||||||
@Prop() size?: 'small' | 'medium' | 'large';
|
@Prop() size?: `xsmall` | 'small' | 'medium' | 'large';
|
||||||
|
|
||||||
get hasImage() {
|
get hasImage() {
|
||||||
return !!this.el.querySelector('ion-img') || !!this.el.querySelector('img');
|
return !!this.el.querySelector('ion-img') || !!this.el.querySelector('img');
|
||||||
|
@ -6,6 +6,51 @@ import { configs, test } from '@utils/test/playwright';
|
|||||||
*/
|
*/
|
||||||
configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ config, screenshot, title }) => {
|
configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ config, screenshot, title }) => {
|
||||||
test.describe(title('avatar: size'), () => {
|
test.describe(title('avatar: size'), () => {
|
||||||
|
test.describe('xsmall', () => {
|
||||||
|
test('should not have visual regressions when containing text', async ({ page }) => {
|
||||||
|
await page.setContent(
|
||||||
|
`
|
||||||
|
<ion-avatar size="xsmall">AB</ion-avatar>
|
||||||
|
`,
|
||||||
|
config
|
||||||
|
);
|
||||||
|
|
||||||
|
const avatar = page.locator('ion-avatar');
|
||||||
|
|
||||||
|
await expect(avatar).toHaveScreenshot(screenshot(`avatar-size-xsmall-text`));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should not have visual regressions when containing an icon', async ({ page }) => {
|
||||||
|
await page.setContent(
|
||||||
|
`
|
||||||
|
<ion-avatar size="xsmall">
|
||||||
|
<ion-icon name="person-outline"></ion-icon>
|
||||||
|
</ion-avatar>
|
||||||
|
`,
|
||||||
|
config
|
||||||
|
);
|
||||||
|
|
||||||
|
const avatar = page.locator('ion-avatar');
|
||||||
|
|
||||||
|
await expect(avatar).toHaveScreenshot(screenshot(`avatar-size-xsmall-icon`));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should not have visual regressions when containing an image', async ({ page }) => {
|
||||||
|
await page.setContent(
|
||||||
|
`
|
||||||
|
<ion-avatar size="xsmall">
|
||||||
|
<img src="/src/components/avatar/test/avatar.svg"/>
|
||||||
|
</ion-avatar>
|
||||||
|
`,
|
||||||
|
config
|
||||||
|
);
|
||||||
|
|
||||||
|
const avatar = page.locator('ion-avatar');
|
||||||
|
|
||||||
|
await expect(avatar).toHaveScreenshot(screenshot(`avatar-size-xsmall-image`));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test.describe('small', () => {
|
test.describe('small', () => {
|
||||||
test('should not have visual regressions when containing text', async ({ page }) => {
|
test('should not have visual regressions when containing text', async ({ page }) => {
|
||||||
await page.setContent(
|
await page.setContent(
|
||||||
|
After Width: | Height: | Size: 390 B |
After Width: | Height: | Size: 396 B |
After Width: | Height: | Size: 384 B |
After Width: | Height: | Size: 438 B |
After Width: | Height: | Size: 376 B |
After Width: | Height: | Size: 418 B |
After Width: | Height: | Size: 490 B |
After Width: | Height: | Size: 525 B |
After Width: | Height: | Size: 456 B |
@ -43,6 +43,7 @@
|
|||||||
|
|
||||||
<h2>Text</h2>
|
<h2>Text</h2>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
<ion-avatar size="xsmall">AB</ion-avatar>
|
||||||
<ion-avatar size="small">AB</ion-avatar>
|
<ion-avatar size="small">AB</ion-avatar>
|
||||||
<ion-avatar size="medium">AB</ion-avatar>
|
<ion-avatar size="medium">AB</ion-avatar>
|
||||||
<ion-avatar size="large">AB</ion-avatar>
|
<ion-avatar size="large">AB</ion-avatar>
|
||||||
@ -50,6 +51,9 @@
|
|||||||
|
|
||||||
<h2>Icons</h2>
|
<h2>Icons</h2>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
<ion-avatar size="xsmall">
|
||||||
|
<ion-icon name="person-outline"></ion-icon>
|
||||||
|
</ion-avatar>
|
||||||
<ion-avatar size="small">
|
<ion-avatar size="small">
|
||||||
<ion-icon name="person-outline"></ion-icon>
|
<ion-icon name="person-outline"></ion-icon>
|
||||||
</ion-avatar>
|
</ion-avatar>
|
||||||
@ -63,6 +67,9 @@
|
|||||||
|
|
||||||
<h2>Images</h2>
|
<h2>Images</h2>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
<ion-avatar size="xsmall">
|
||||||
|
<img src="/src/components/avatar/test/avatar.svg" />
|
||||||
|
</ion-avatar>
|
||||||
<ion-avatar size="small">
|
<ion-avatar size="small">
|
||||||
<img src="/src/components/avatar/test/avatar.svg" />
|
<img src="/src/components/avatar/test/avatar.svg" />
|
||||||
</ion-avatar>
|
</ion-avatar>
|
||||||
|