Socket
Socket
Sign inDemoInstall

ngx-jdenticon

Package Overview
Dependencies
9
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ngx-jdenticon

Generate identicons in your Angular app using Jdenticon.


Version published
Weekly downloads
517
decreased by-11.47%
Maintainers
1
Install size
136 kB
Created
Weekly downloads
 

Readme

Source

ngx-jdenticon

Angular directives used to generate identicons using Jdenticon.

Sample identicons

GitHub Workflow Status Downloads License MIT

🚀 Sample app at StackBlitz

Install

Install the ngx-jdenticon and jdenticon NPM packages.

npm install --save ngx-jdenticon jdenticon

Import NgxJdenticonModule into your app.module.ts (or another module).

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { NgxJdenticonModule } from 'ngx-jdenticon'; // <--- Add

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

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NgxJdenticonModule, // <--- Add
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Add an icon by decorating either an <svg> or <canvas> element with the data-jdenticon-value or data-jdenticon-hash attribute.

<svg width="100" height="100" data-jdenticon-value="John Doe"></svg>

Customize look

If you don't like the default colors, use the icon designer to customize the look of identicons generated by ngx-jdenticon.

Icon style configurations are applied by adding a provider for the JDENTICON_CONFIG injection token.

import { NgxJdenticonModule, JDENTICON_CONFIG } from 'ngx-jdenticon';

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    NgxJdenticonModule,
  ],
  providers: [
    { 
      // Custom identicon style
      // https://jdenticon.com/icon-designer.html?config=222222ff014132321e363f52
      provide: JDENTICON_CONFIG,
      useValue: {
        lightness: {
          color: [0.31, 0.54],
          grayscale: [0.63, 0.82],
        },
        saturation: {
          color: 0.50,
          grayscale: 0.50,
        },
        backColor: '#222',
      },
    }
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

🚀 Run on StackBlitz

See also

Jdenticon homepage

Keywords

FAQs

Last updated on 04 Mar 2023

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