New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ng-hub-ui-avatar

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-hub-ui-avatar

A powerful, flexible, and standalone Angular avatar component that generates and fetches user avatars from multiple sources including social media, Gravatar, or custom images with intelligent fallback system

  • 19.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
21
decreased by-66.67%
Maintainers
0
Weekly downloads
 
Created
Source

ng-hub-ui-avatar

npm version npm

Part of ng-hub-ui Family

This component is part of the ng-hub-ui ecosystem, which includes:

Credits and Attribution

This library is a fork of ngx-avatars, originally created by HaithemMosbahi and maintained by Tiago Casinhas.

The original work provided an excellent foundation for avatar management in Angular applications. This fork was created to:

  • Provide a standalone component architecture
  • Ensure compatibility with the latest Angular versions
  • Integrate seamlessly with the ng-hub-ui component ecosystem
  • Add new features and improvements while maintaining the original functionality

All credit for the original implementation goes to the original authors and contributors of ngx-avatars.

Description

A versatile avatar component for Angular applications that fetches or generates avatars based on user information. The component includes a sophisticated fallback system that attempts different sources if the primary source fails.

You can use this component with either a single source or multiple avatar sources, with the fallback system automatically selecting the first valid avatar.

Additionally, the component can display name initials or custom values as avatars.

Supported avatar sources:

  • Facebook
  • Google
  • Twitter
  • Instagram
  • Vkontakte (VK)
  • Skype
  • Gravatar (🚧 Under construction)
  • GitHub
  • Custom image
  • Name initials
  • Value

The fallback system follows the same order as the source list above, with Facebook having the highest priority.

Installation

Install the avatar component using npm:

npm install ng-hub-ui-avatar --save

Or using yarn:

yarn add ng-hub-ui-avatar

Usage

As this is a standalone component, you don't need to import any module. Just import the component directly in your standalone components or pages:

import { Component } from '@angular/core';
import { NgHubUiAvatar } from 'ng-hub-ui-avatar';

@Component({
  selector: 'app-my-component',
  standalone: true,
  imports: [NgHubUiAvatar],
  template: `
    <ng-hub-ui-avatar></ng-hub-ui-avatar>
  `
})
export class MyComponent { }

If you're using NgModule (legacy approach), you can import it in your components array:

import { NgModule } from '@angular/core';
import { NgHubUiAvatar } from 'ng-hub-ui-avatar';

@NgModule({
  imports: [
    // other imports...
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent]
})
export class AppModule { }

Use it in your components:

<ng-hub-ui-avatar></ng-hub-ui-avatar>

Examples

<ng-hub-ui-avatar facebookId="1508319875"></ng-hub-ui-avatar>
<ng-hub-ui-avatar googleId="1508319875"></ng-hub-ui-avatar>
<ng-hub-ui-avatar twitterId="1508319875"></ng-hub-ui-avatar>
<ng-hub-ui-avatar instagramId="dccomics" size="70"></ng-hub-ui-avatar>
<ng-hub-ui-avatar name="John Doe"></ng-hub-ui-avatar>
<ng-hub-ui-avatar value="75%"></ng-hub-ui-avatar>

<!-- Multiple sources with fallback -->
<ng-hub-ui-avatar 
  facebookId="userFacebookID" 
  skypeId="userSkypeID"
  googleId="google" 
  name="John Doe" 
  src="assets/avatar.jpg"
  value="28%" 
  size="100" 
  [round]="true">
</ng-hub-ui-avatar>

Options

AttributeTypeDefaultDescription
facebookIdstringnullFacebook ID
googleIdstringnullGoogle ID
twitterIdstringnullTwitter Handle
instagramIdstringnullInstagram Handle
vkontakteIdstringnullVK ID
skypeIdstringnullSkype ID
githubIdstringnullGithub ID
srcstringnullFallback image to use
namestringnullWill be used to generate avatar based on initials
valuestringnullShow a value as avatar
initialsSizenumber0Limits the number of characters in initials (0 = no limit)
bgColorstringrandomBackground color (hex format, e.g., #FF0000)
fgColorstring#FFFText color (hex format, e.g., #FF0000)
sizenumber50Size of the avatar
textSizeRationumber3Text size as a fraction of avatar size
roundbooleantrueRound the avatar corners
cornerRadiusnumber0Border radius for square avatars
borderColorstringundefinedBorder color
styleobjectCustom styles for root element
clickOnAvatarOutputEvent emitted on avatar click
referrerpolicystringnullReferrer policy for image requests

Support the Project

If you find this library helpful, consider supporting its development:

"Buy Me A Coffee"

Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin feature/my-new-feature
  5. Submit a pull request

License

MIT © Carlos Morcillo

Keywords

FAQs

Package last updated on 03 Jan 2025

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc