UNPKG

ngx-avatars

Version:

A universal avatar component for Angular applications that fetches / generates avatar based on the information you have about the user.

115 lines (114 loc) 4.64 kB
import { EventEmitter, OnChanges, SimpleChanges, OnDestroy } from '@angular/core'; import { Source } from './sources/source'; import { SourceFactory } from './sources/source.factory'; import { AvatarService } from './avatar.service'; import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; import * as i0 from "@angular/core"; type Style = Partial<CSSStyleDeclaration>; /** * Universal avatar component that * generates avatar from different sources * * export * class AvatarComponent * implements {OnChanges} */ export declare class AvatarComponent implements OnChanges, OnDestroy { sourceFactory: SourceFactory; private avatarService; private sanitizer; round: boolean; size: string | number; textSizeRatio: number; bgColor: string | undefined; fgColor: string; borderColor: string | undefined; style: Style; cornerRadius: string | number; facebook?: string | null; twitter?: string | null; google?: string | null; instagram?: string | null; vkontakte?: string | null; skype?: string | null; gravatar?: string | null; github?: string | null; custom?: string | SafeUrl | null; customAlt?: string | null; initials?: string | null; value?: string | null; referrerpolicy?: string | null; placeholder?: string; initialsSize: string | number; clickOnAvatar: EventEmitter<Source>; isAlive: boolean; avatarSrc: SafeUrl | null; avatarAlt: SafeUrl | null; avatarText: string | null; avatarStyle: Style; hostStyle: Style; private currentIndex; private sources; constructor(sourceFactory: SourceFactory, avatarService: AvatarService, sanitizer: DomSanitizer); onAvatarClicked(): void; /** * Detect inputs change * * param {{ [propKey: string]: SimpleChange }} changes * * memberof AvatarComponent */ ngOnChanges(changes: SimpleChanges): void; /** * Fetch avatar source * * memberOf AvatarComponent */ fetchAvatarSource(): void; private findNextSource; ngOnDestroy(): void; /** * Initialize the avatar component and its fallback system */ private initializeAvatar; private sortAvatarSources; private buildTextAvatar; private buildImageAvatar; /** * * returns initials style * * memberOf AvatarComponent */ private getInitialsStyle; /** * * returns image style * * memberOf AvatarComponent */ private getImageStyle; /** * Fetch avatar image asynchronously. * * param {Source} source represents avatar source * memberof AvatarComponent */ private fetchAndProcessAsyncAvatar; /** * Add avatar source * * param sourceType avatar source type e.g facebook,twitter, etc. * param sourceValue source value e.g facebookId value, etc. */ private addSource; /** * Remove avatar source * * param sourceType avatar source type e.g facebook,twitter, etc. */ private removeSource; static ɵfac: i0.ɵɵFactoryDeclaration<AvatarComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<AvatarComponent, "ngx-avatars", never, { "round": { "alias": "round"; "required": false; }; "size": { "alias": "size"; "required": false; }; "textSizeRatio": { "alias": "textSizeRatio"; "required": false; }; "bgColor": { "alias": "bgColor"; "required": false; }; "fgColor": { "alias": "fgColor"; "required": false; }; "borderColor": { "alias": "borderColor"; "required": false; }; "style": { "alias": "style"; "required": false; }; "cornerRadius": { "alias": "cornerRadius"; "required": false; }; "facebook": { "alias": "facebookId"; "required": false; }; "twitter": { "alias": "twitterId"; "required": false; }; "google": { "alias": "googleId"; "required": false; }; "instagram": { "alias": "instagramId"; "required": false; }; "vkontakte": { "alias": "vkontakteId"; "required": false; }; "skype": { "alias": "skypeId"; "required": false; }; "gravatar": { "alias": "gravatarId"; "required": false; }; "github": { "alias": "githubId"; "required": false; }; "custom": { "alias": "src"; "required": false; }; "customAlt": { "alias": "alt"; "required": false; }; "initials": { "alias": "name"; "required": false; }; "value": { "alias": "value"; "required": false; }; "referrerpolicy": { "alias": "referrerpolicy"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "initialsSize": { "alias": "initialsSize"; "required": false; }; }, { "clickOnAvatar": "clickOnAvatar"; }, never, never, false, never>; } export {};