Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(avatar): add styles for xlarge size in ionic theme #29549

Merged
merged 10 commits into from
May 28, 2024
2 changes: 1 addition & 1 deletion core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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" | 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
Expand Down
8 changes: 4 additions & 4 deletions core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@ export namespace Components {
*/
"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, `"large"` for a larger size, or `"xlarge"` for the largest dimensions. Defaults to `"medium"` for the `ionic` theme, undefined for all other themes.
*/
"size"?: 'small' | 'medium' | 'large';
"size"?: `xsmall` | 'small' | 'medium' | 'large' | 'xlarge';
/**
* The theme determines the visual appearance of the component.
*/
Expand Down Expand Up @@ -5568,9 +5568,9 @@ declare namespace LocalJSX {
*/
"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, `"large"` for a larger size, or `"xlarge"` for the largest dimensions. Defaults to `"medium"` for the `ionic` theme, undefined for all other themes.
*/
"size"?: 'small' | 'medium' | 'large';
"size"?: `xsmall` | 'small' | 'medium' | 'large' | 'xlarge';
/**
* The theme determines the visual appearance of the component.
*/
Expand Down
26 changes: 26 additions & 0 deletions core/src/components/avatar/avatar.ionic.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@
// 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) {
--padding-end: #{globals.$ionic-space-150};
--padding-start: #{globals.$ionic-space-150};
Expand Down Expand Up @@ -57,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-500;
brandyscarney marked this conversation as resolved.
Show resolved Hide resolved

line-height: globals.$ionic-line-height-700;
}
7 changes: 4 additions & 3 deletions core/src/components/avatar/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ export class Avatar implements ComponentInterface {
@Element() el!: HTMLElement;

/**
* Set to `"small"` for a compact size, `"medium"` for the default height and width, or to
* `"large"` for a larger size.
* 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.
*/
@Prop() size?: 'small' | 'medium' | 'large';
@Prop() size?: `xsmall` | 'small' | 'medium' | 'large' | 'xlarge';

get hasImage() {
return !!this.el.querySelector('ion-img') || !!this.el.querySelector('img');
Expand Down
90 changes: 90 additions & 0 deletions core/src/components/avatar/test/size/avatar.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,51 @@ import { configs, test } from '@utils/test/playwright';
*/
configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ config, screenshot, title }) => {
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('should not have visual regressions when containing text', async ({ page }) => {
await page.setContent(
Expand Down Expand Up @@ -140,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`));
});
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions core/src/components/avatar/test/size/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,18 @@ <h2>Default</h2>

<h2>Text</h2>
<div class="container">
<ion-avatar size="xsmall">AB</ion-avatar>
<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>
<div class="container">
<ion-avatar size="xsmall">
<ion-icon name="person-outline"></ion-icon>
</ion-avatar>
<ion-avatar size="small">
<ion-icon name="person-outline"></ion-icon>
</ion-avatar>
Expand All @@ -59,10 +64,16 @@ <h2>Icons</h2>
<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>
<div class="container">
<ion-avatar size="xsmall">
<img src="/src/components/avatar/test/avatar.svg" />
</ion-avatar>
<ion-avatar size="small">
<img src="/src/components/avatar/test/avatar.svg" />
</ion-avatar>
Expand All @@ -72,6 +83,9 @@ <h2>Images</h2>
<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>
Expand Down
Loading