ngx-avatar
Version:
A universal avatar component for Angular applications that fetches / generates avatar based on the information you have about the user.
37 lines (36 loc) • 1.3 kB
TypeScript
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { AvatarConfigService } from './avatar-config.service';
import { AvatarSource } from './sources/avatar-source.enum';
import { Source } from './sources/source';
/**
* list of Supported avatar sources
*/
export declare const defaultSources: AvatarSource[];
/**
* list of default colors
*/
export declare const defaultColors: string[];
/**
* Provides utilities methods related to Avatar component
*/
export declare class AvatarService {
private http;
private avatarConfigService;
avatarSources: AvatarSource[];
avatarColors: string[];
private readonly failedSources;
constructor(http: HttpClient, avatarConfigService: AvatarConfigService);
fetchAvatar(avatarUrl: string): Observable<unknown>;
getRandomColor(avatarText: string): string;
compareSources(sourceType1: AvatarSource, sourceType2: AvatarSource): number;
isSource(source: string): boolean;
isTextAvatar(sourceType: AvatarSource): boolean;
private buildSourceKey;
sourceHasFailedBefore(source: Source): boolean;
markSourceAsFailed(source: Source): void;
private overrideAvatarSources;
private overrideAvatarColors;
private calculateAsciiCode;
private getSourcePriority;
}