11import { CommonModule } from '@angular/common' ;
22import {
3- AfterViewInit ,
43 Component ,
54 ElementRef ,
65 HostBinding ,
@@ -53,7 +52,7 @@ export enum IgxAvatarType {
5352 selector : 'igx-avatar' ,
5453 templateUrl : 'avatar.component.html'
5554} )
56- export class IgxAvatarComponent implements OnInit , AfterViewInit {
55+ export class IgxAvatarComponent implements OnInit {
5756
5857 /**
5958 * This is a reference to the avatar image element in the DOM.
@@ -256,6 +255,22 @@ export class IgxAvatarComponent implements OnInit, AfterViewInit {
256255 }
257256 }
258257
258+ /** @hidden @internal */
259+ @HostBinding ( 'class.igx-avatar--small' )
260+ get _isSmallSize ( ) : boolean {
261+ return this . size === 'small' ;
262+ }
263+ /** @hidden @internal */
264+ @HostBinding ( 'class.igx-avatar--medium' )
265+ get _isMediumSize ( ) : boolean {
266+ return this . size === 'medium' ;
267+ }
268+ /** @hidden @internal */
269+ @HostBinding ( 'class.igx-avatar--large' )
270+ get _isLargeSize ( ) : boolean {
271+ return this . size === 'large' ;
272+ }
273+
259274 /**
260275 * Returns the type of the avatar.
261276 *
@@ -280,6 +295,22 @@ export class IgxAvatarComponent implements OnInit, AfterViewInit {
280295 return IgxAvatarType . CUSTOM ;
281296 }
282297
298+ /** @hidden @internal */
299+ @HostBinding ( 'class.igx-avatar--image' )
300+ get _isImageType ( ) : boolean {
301+ return this . type === IgxAvatarType . IMAGE ;
302+ }
303+ /** @hidden @internal */
304+ @HostBinding ( 'class.igx-avatar--icon' )
305+ get _isIconType ( ) : boolean {
306+ return this . type === IgxAvatarType . ICON ;
307+ }
308+ /** @hidden @internal */
309+ @HostBinding ( 'class.igx-avatar--initials' )
310+ get _isInitialsType ( ) : boolean {
311+ return this . type === IgxAvatarType . INITIALS ;
312+ }
313+
283314 /**
284315 * Returns the template of the avatar.
285316 *
@@ -306,15 +337,6 @@ export class IgxAvatarComponent implements OnInit, AfterViewInit {
306337 this . roleDescription = this . getRole ( ) ;
307338 }
308339
309- /** @hidden @internal */
310- public ngAfterViewInit ( ) {
311- if ( this . type !== IgxAvatarType . CUSTOM ) {
312- this . elementRef . nativeElement . classList . add ( `igx-avatar--${ this . type } ` ) ;
313- }
314-
315- this . elementRef . nativeElement . classList . add ( `igx-avatar--${ this . _size } ` ) ;
316- }
317-
318340 /** @hidden @internal */
319341 private getRole ( ) : string {
320342 switch ( this . type ) {
0 commit comments