Socket
Socket
Sign inDemoInstall

ngx-avatar

Package Overview
Dependencies
9
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ngx-avatar

[![npm version](https://badge.fury.io/js/ngx-avatar.svg)](https://badge.fury.io/js/ngx-avatar) [![Build Status](https://travis-ci.org/HaithemMosbahi/ngx-avatar.svg?branch=master)](https://travis-ci.org/HaithemMosbahi/ngx-avatar)


Version published
Weekly downloads
5.9K
decreased by-18.6%
Maintainers
1
Install size
3.13 MB
Created
Weekly downloads
 

Readme

Source

# <ngx-avatar>

npm version Build Status

A universal avatar component for Angular 2+ applications that fetches / generates avatar based on the informations you have about the user. The component has a fallback system that if for example an invalid Facebook ID is used it will try google ID and so on.

You can use this component whether you have a single source or a multiple avatar sources. In this case the fallback system will fetch the first valid avatar.

Moreover, the component can shows name initials or simple value as avatar.

Angular Avatar component preview

Supported avatar sources:

  • Facebook
  • Google
  • Twitter
  • Skype
  • Gravatar
  • Custom image
  • name initials
  • value

The fallback system uses the same order as the above source list, Facebook has the highest priority, if it fails, google source will be used, and so on.

Installation

Install avatar component using NPM::

$ npm install ngx-avatar --save

Or download as ZIP.

Usage

  1. Import AvatarModule :

Once you have installed ngx-avatar, you can import it in your AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

// Import your AvatarModule
import { AvatarModule } from 'ngx-avatar';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    // Specify AvatarModule as an import
    AvatarModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
  1. Start using it:

Once the AvatarModule is imported, you can start using the component in your Angular application:

<ngx-avatar></ngx-avatar>

Examples

<ngx-avatar facebookId="1508319875"></ngx-avatar>
<ngx-avatar googleId="1508319875"></ngx-avatar>
<ngx-avatar twitterId="1508319875"></ngx-avatar>
<ngx-avatar skypeId="1508319875"></ngx-avatar>
<ngx-avatar gravatarId="adde9b2b981a8083cf084c63ad86f753"></ngx-avatar>
<ngx-avatar gravatarId="user@gmail.com"></ngx-avatar>
<ngx-avatar src="assets/avatar.jpg"></ngx-avatar>
<ngx-avatar name="John Doe"></ngx-avatar>
<ngx-avatar value="75%"></ngx-avatar>

<ngx-avatar facebookId="userFacebookID" skypeId="userSkypeID"
 googleId="google" name="Haithem Mosbahi" src="assets/avatar.jpg"
 value="28%"  twitterId="twitter"
 gravatarId="adde9b2b981a8083cf084c63ad86f753" 
 size="100" [round]="true">
</ngx-avatar>

Options

AttributeTypeDefaultDescription
facebookIdstringFacebook ID
googleIdstringGoogle ID
twitterIdstringTwitter Handle
skypeIdstringSkype ID
gravatarIdstringemail or md5 email related to gravatar
srcstringFallback image to use
namestringWill be used to generate avatar based on the initials of the person
valuestringShow a value as avatar
bgColorstringrandomGive the background a fixed color with a hex like for example #FF0000
fgColorstring#FFFUsed Give the text a fixed color with a hex like for example #FF0000
sizenumber50Size of the avatar
textSizeRationumber3For text based avatars the size of the text as a fragment of size (size / textSizeRatio)
roundbooltrueRound the avatar corners
styleobjectStyle that will be applied on the root element

Release Notes

  • 1.0 : Avatar component that fetches / generates user avatar from different sources.

Development

To generate all *.js, *.d.ts and *.metadata.json files:

$ npm run build

To lint all *.ts files:

$ npm run lint

License

MIT © Haithem Mosbahi

Keywords

FAQs

Last updated on 30 May 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc