Skip to content

Commit 6a9ecd4

Browse files
- add disabled attribute to Avatar;
1 parent a0fa3b3 commit 6a9ecd4

File tree

10 files changed

+48
-5
lines changed

10 files changed

+48
-5
lines changed

core/api.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ ion-app,prop,theme,"ios" | "md" | "ionic",undefined,false,false
185185
ion-app,method,setFocus,setFocus(elements: HTMLElement[]) => Promise<void>
186186

187187
ion-avatar,shadow
188+
ion-avatar,prop,disabled,boolean,false,false,false
188189
ion-avatar,prop,mode,"ios" | "md",undefined,false,false
189190
ion-avatar,prop,shape,"rectangular" | "round" | "soft" | undefined,undefined,false,false
190191
ion-avatar,prop,size,"large" | "medium" | "small" | "xlarge" | "xsmall" | "xxsmall" | undefined,undefined,false,false

core/src/components.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ export namespace Components {
343343
"theme"?: "ios" | "md" | "ionic";
344344
}
345345
interface IonAvatar {
346+
/**
347+
* If `true`, the user cannot interact with the avatar.
348+
*/
349+
"disabled": boolean;
346350
/**
347351
* The mode determines the platform behaviors of the component.
348352
*/
@@ -5759,6 +5763,10 @@ declare namespace LocalJSX {
57595763
"theme"?: "ios" | "md" | "ionic";
57605764
}
57615765
interface IonAvatar {
5766+
/**
5767+
* If `true`, the user cannot interact with the avatar.
5768+
*/
5769+
"disabled"?: boolean;
57625770
/**
57635771
* The mode determines the platform behaviors of the component.
57645772
*/

core/src/components/avatar/avatar.common.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,10 @@
2525

2626
overflow: hidden;
2727
}
28+
29+
// Disabled Checkbox
30+
// ---------------------------------------------
31+
32+
:host(.avatar-disabled) {
33+
pointer-events: none;
34+
}

core/src/components/avatar/avatar.ionic.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,9 @@
171171
:host(.avatar-xxsmall) ::slotted(ion-badge.badge-vertical-bottom:empty) {
172172
transform: translate(globals.$ion-scale-100, calc(globals.$ion-scale-100));
173173
}
174+
175+
// Avatar Disabled
176+
// --------------------------------------------------
177+
:host(.avatar-disabled) {
178+
@include globals.disabled-state();
179+
}

core/src/components/avatar/avatar.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ export class Avatar implements ComponentInterface {
4040
*/
4141
@Prop() shape?: 'soft' | 'round' | 'rectangular';
4242

43+
/**
44+
* If `true`, the user cannot interact with the avatar.
45+
*/
46+
@Prop() disabled = false;
47+
4348
get hasImage() {
4449
return !!this.el.querySelector('ion-img') || !!this.el.querySelector('img');
4550
}
@@ -93,6 +98,7 @@ export class Avatar implements ComponentInterface {
9398
[`avatar-${shape}`]: shape !== undefined,
9499
[`avatar-image`]: this.hasImage,
95100
[`avatar-icon`]: this.hasIcon,
101+
[`avatar-disabled`]: this.disabled,
96102
}}
97103
>
98104
<slot></slot>

core/src/components/avatar/test/basic/avatar.e2e.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ configs({ directions: ['ltr'] }).forEach(({ config, screenshot, title }) => {
1414
const avatarChip = page.locator('#avatar-chip');
1515
const avatarItemStart = page.locator('#avatar-item-start');
1616
const avatarItemEnd = page.locator('#avatar-item-end');
17+
const avatarCharactersDisabled = page.locator('avatar-characters-disabled');
18+
const avatarDisabled = page.locator('avatar-disabled');
1719

1820
await expect(avatar).toHaveScreenshot(screenshot(`avatar-diff`));
1921
await expect(avatarChip).toHaveScreenshot(screenshot(`avatar-chip-diff`));
2022
await expect(avatarItemStart).toHaveScreenshot(screenshot(`avatar-item-start-diff`));
2123
await expect(avatarItemEnd).toHaveScreenshot(screenshot(`avatar-item-end-diff`));
24+
await expect(avatarCharactersDisabled).toHaveScreenshot(screenshot(`avatar-characters-disabled-diff`));
25+
await expect(avatarDisabled).toHaveScreenshot(screenshot(`avatar-disabled-diff`));
2226
});
2327
});
2428
});

core/src/components/avatar/test/basic/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@
4747
</ion-avatar>
4848
<ion-label>Wide Avatar</ion-label>
4949
</ion-item>
50+
51+
<ion-item id="avatar-characters-disabled">
52+
<ion-avatar disabled> AV </ion-avatar>
53+
</ion-item>
54+
55+
<ion-item id="avatar-disabled">
56+
<ion-avatar disabled>
57+
<img src="/src/components/avatar/test/avatar.svg" />
58+
</ion-avatar>
59+
</ion-item>
5060
</ion-content>
5161
</ion-app>
5262
</body>

packages/angular/src/directives/proxies.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,14 @@ export declare interface IonApp extends Components.IonApp {}
211211

212212

213213
@ProxyCmp({
214-
inputs: ['mode', 'shape', 'size', 'theme']
214+
inputs: ['disabled', 'mode', 'shape', 'size', 'theme']
215215
})
216216
@Component({
217217
selector: 'ion-avatar',
218218
changeDetection: ChangeDetectionStrategy.OnPush,
219219
template: '<ng-content></ng-content>',
220220
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
221-
inputs: ['mode', 'shape', 'size', 'theme'],
221+
inputs: ['disabled', 'mode', 'shape', 'size', 'theme'],
222222
})
223223
export class IonAvatar {
224224
protected el: HTMLIonAvatarElement;

packages/angular/standalone/src/directives/proxies.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,14 @@ export declare interface IonApp extends Components.IonApp {}
295295

296296
@ProxyCmp({
297297
defineCustomElementFn: defineIonAvatar,
298-
inputs: ['mode', 'shape', 'size', 'theme']
298+
inputs: ['disabled', 'mode', 'shape', 'size', 'theme']
299299
})
300300
@Component({
301301
selector: 'ion-avatar',
302302
changeDetection: ChangeDetectionStrategy.OnPush,
303303
template: '<ng-content></ng-content>',
304304
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
305-
inputs: ['mode', 'shape', 'size', 'theme'],
305+
inputs: ['disabled', 'mode', 'shape', 'size', 'theme'],
306306
standalone: true
307307
})
308308
export class IonAvatar {

packages/vue/src/proxies.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ export const IonAccordionGroup: StencilVueComponent<JSX.IonAccordionGroup, JSX.I
112112

113113
export const IonAvatar: StencilVueComponent<JSX.IonAvatar> = /*@__PURE__*/ defineContainer<JSX.IonAvatar>('ion-avatar', defineIonAvatar, [
114114
'size',
115-
'shape'
115+
'shape',
116+
'disabled'
116117
]);
117118

118119

0 commit comments

Comments
 (0)