diff --git a/core/api.txt b/core/api.txt index cb233e2d7e..8d4287501c 100644 --- a/core/api.txt +++ b/core/api.txt @@ -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,shape,"round" | undefined,undefined,false,false +ion-avatar,prop,shape,"rectangular" | "round" | 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 diff --git a/core/src/components.d.ts b/core/src/components.d.ts index 07d039058e..2bd6f5c617 100644 --- a/core/src/components.d.ts +++ b/core/src/components.d.ts @@ -336,9 +336,9 @@ export namespace Components { */ "mode"?: "ios" | "md"; /** - * Set to `"round"` for an avatar with fully rounded corners. Defaults to `"round"` for the `ionic` theme, undefined for all other themes. + * Set to `"round"` for an avatar with fully rounded corners, or `"rectangular"` for an avatar without rounded corners. Defaults to `"round"` for the `ionic` theme, undefined for all other themes. */ - "shape"?: 'round'; + "shape"?: 'round' | 'rectangular'; /** * 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. */ @@ -5572,9 +5572,9 @@ declare namespace LocalJSX { */ "mode"?: "ios" | "md"; /** - * Set to `"round"` for an avatar with fully rounded corners. Defaults to `"round"` for the `ionic` theme, undefined for all other themes. + * Set to `"round"` for an avatar with fully rounded corners, or `"rectangular"` for an avatar without rounded corners. Defaults to `"round"` for the `ionic` theme, undefined for all other themes. */ - "shape"?: 'round'; + "shape"?: 'round' | 'rectangular'; /** * 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. */ diff --git a/core/src/components/avatar/avatar.ionic.scss b/core/src/components/avatar/avatar.ionic.scss index 9e8c228944..ac0d116ede 100644 --- a/core/src/components/avatar/avatar.ionic.scss +++ b/core/src/components/avatar/avatar.ionic.scss @@ -92,3 +92,7 @@ :host(.avatar-round) { --border-radius: #{globals.$ionic-border-radius-full}; } + +:host(.avatar-rectangular) { + --border-radius: #{globals.$ionic-border-radius-0}; +} diff --git a/core/src/components/avatar/avatar.tsx b/core/src/components/avatar/avatar.tsx index 6e3db222f3..016b7a5eb4 100644 --- a/core/src/components/avatar/avatar.tsx +++ b/core/src/components/avatar/avatar.tsx @@ -29,11 +29,12 @@ export class Avatar implements ComponentInterface { @Prop() size?: `xsmall` | 'small' | 'medium' | 'large' | 'xlarge'; /** - * Set to `"round"` for an avatar with fully rounded corners. + * Set to `"round"` for an avatar with fully rounded corners, or `"rectangular"` + * for an avatar without rounded corners. * * Defaults to `"round"` for the `ionic` theme, undefined for all other themes. */ - @Prop() shape?: 'round'; + @Prop() shape?: 'round' | 'rectangular'; get hasImage() { return !!this.el.querySelector('ion-img') || !!this.el.querySelector('img'); diff --git a/core/src/components/avatar/test/shape/avatar.e2e.ts b/core/src/components/avatar/test/shape/avatar.e2e.ts index 7a54762782..f44a119bb1 100644 --- a/core/src/components/avatar/test/shape/avatar.e2e.ts +++ b/core/src/components/avatar/test/shape/avatar.e2e.ts @@ -50,5 +50,50 @@ configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ config, screens await expect(avatar).toHaveScreenshot(screenshot(`avatar-shape-round-image`)); }); }); + + test.describe('rectangular', () => { + test('should not have visual regressions when containing text', async ({ page }) => { + await page.setContent( + ` + AB + `, + config + ); + + const avatar = page.locator('ion-avatar'); + + await expect(avatar).toHaveScreenshot(screenshot(`avatar-shape-rectangular-text`)); + }); + + test('should not have visual regressions when containing an icon', async ({ page }) => { + await page.setContent( + ` + + + + `, + config + ); + + const avatar = page.locator('ion-avatar'); + + await expect(avatar).toHaveScreenshot(screenshot(`avatar-shape-rectangular-icon`)); + }); + + test('should not have visual regressions when containing an image', async ({ page }) => { + await page.setContent( + ` + + + + `, + config + ); + + const avatar = page.locator('ion-avatar'); + + await expect(avatar).toHaveScreenshot(screenshot(`avatar-shape-rectangular-image`)); + }); + }); }); }); diff --git a/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-icon-ionic-md-ltr-light-Mobile-Chrome-linux.png b/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-icon-ionic-md-ltr-light-Mobile-Chrome-linux.png new file mode 100644 index 0000000000..dfb50e7fdc Binary files /dev/null and b/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-icon-ionic-md-ltr-light-Mobile-Chrome-linux.png differ diff --git a/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-icon-ionic-md-ltr-light-Mobile-Firefox-linux.png b/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-icon-ionic-md-ltr-light-Mobile-Firefox-linux.png new file mode 100644 index 0000000000..d3f2a5e314 Binary files /dev/null and b/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-icon-ionic-md-ltr-light-Mobile-Firefox-linux.png differ diff --git a/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-icon-ionic-md-ltr-light-Mobile-Safari-linux.png b/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-icon-ionic-md-ltr-light-Mobile-Safari-linux.png new file mode 100644 index 0000000000..cdbb3cec21 Binary files /dev/null and b/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-icon-ionic-md-ltr-light-Mobile-Safari-linux.png differ diff --git a/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-image-ionic-md-ltr-light-Mobile-Chrome-linux.png b/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-image-ionic-md-ltr-light-Mobile-Chrome-linux.png new file mode 100644 index 0000000000..771f594575 Binary files /dev/null and b/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-image-ionic-md-ltr-light-Mobile-Chrome-linux.png differ diff --git a/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-image-ionic-md-ltr-light-Mobile-Firefox-linux.png b/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-image-ionic-md-ltr-light-Mobile-Firefox-linux.png new file mode 100644 index 0000000000..a566b986a1 Binary files /dev/null and b/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-image-ionic-md-ltr-light-Mobile-Firefox-linux.png differ diff --git a/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-image-ionic-md-ltr-light-Mobile-Safari-linux.png b/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-image-ionic-md-ltr-light-Mobile-Safari-linux.png new file mode 100644 index 0000000000..4b80c96bab Binary files /dev/null and b/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-image-ionic-md-ltr-light-Mobile-Safari-linux.png differ diff --git a/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-text-ionic-md-ltr-light-Mobile-Chrome-linux.png b/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-text-ionic-md-ltr-light-Mobile-Chrome-linux.png new file mode 100644 index 0000000000..841ddb2029 Binary files /dev/null and b/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-text-ionic-md-ltr-light-Mobile-Chrome-linux.png differ diff --git a/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-text-ionic-md-ltr-light-Mobile-Firefox-linux.png b/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-text-ionic-md-ltr-light-Mobile-Firefox-linux.png new file mode 100644 index 0000000000..ff8f260ae6 Binary files /dev/null and b/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-text-ionic-md-ltr-light-Mobile-Firefox-linux.png differ diff --git a/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-text-ionic-md-ltr-light-Mobile-Safari-linux.png b/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-text-ionic-md-ltr-light-Mobile-Safari-linux.png new file mode 100644 index 0000000000..e8849fc65a Binary files /dev/null and b/core/src/components/avatar/test/shape/avatar.e2e.ts-snapshots/avatar-shape-rectangular-text-ionic-md-ltr-light-Mobile-Safari-linux.png differ diff --git a/core/src/components/avatar/test/shape/index.html b/core/src/components/avatar/test/shape/index.html index a70ecdcb8d..bd07c0e55f 100644 --- a/core/src/components/avatar/test/shape/index.html +++ b/core/src/components/avatar/test/shape/index.html @@ -49,6 +49,15 @@ AB AB + +

Rectangular

+
+ AB + AB + AB + AB + AB +