# ngx-jdenticon

> Generate identicons in your Angular app using Jdenticon.

Latest version **2.0.0** (published 2023-03-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install ngx-jdenticon
pnpm add ngx-jdenticon
yarn add ngx-jdenticon
bun add ngx-jdenticon
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2023-03-04 |
| First published | 2020-08-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 54.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Daniel Mester Pirttijärvi |
| Maintainers | dmester |
| Keywords | javascript, identicon, jdenticon, avatar, angular |

## Links

- npm: https://www.npmjs.com/package/ngx-jdenticon
- Repository: https://github.com/dmester/ngx-jdenticon
- Homepage: https://jdenticon.com/
- Issues: https://github.com/dmester/ngx-jdenticon/issues
- npm.io page: https://npm.io/package/ngx-jdenticon

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.3.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2023-03-04
- 1.0.4 — 2021-01-06
- 1.0.3 — 2020-08-02
- 1.0.2 — 2020-08-01
- 1.0.1 — 2020-08-01
- 1.0.0 — 2020-08-01

## README

# ngx-jdenticon

Angular directives used to generate identicons using [Jdenticon](https://github.com/dmester/jdenticon).

![Sample identicons](https://jdenticon.com/hosted/github-samples.png)

[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/dmester/ngx-jdenticon/build.js.yml?branch=master&style=flat-square)](https://github.com/dmester/ngx-jdenticon/actions)
[![Downloads](https://img.shields.io/npm/dt/ngx-jdenticon.svg?style=flat-square)](https://www.npmjs.com/package/ngx-jdenticon)
[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/dmester/ngx-jdenticon/blob/master/LICENSE)

🚀 [Sample app at StackBlitz](https://stackblitz.com/edit/ngx-jdenticon-sample)

## Install

Install the [ngx-jdenticon](https://www.npmjs.com/package/ngx-jdenticon) and [jdenticon](https://www.npmjs.com/package/jdenticon) NPM packages.

```sh
npm install --save ngx-jdenticon jdenticon
```

Import `NgxJdenticonModule` into your `app.module.ts` (or another module).

```ts
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`](https://jdenticon.com/js-api/A_data-jdenticon-value.html) or
[`data-jdenticon-hash`](https://jdenticon.com/js-api/A_data-jdenticon-hash.html)
attribute.

```html
<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](https://jdenticon.com/icon-designer.html) 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.

```ts
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](https://stackblitz.com/edit/ngx-jdenticon-custom-design?file=src%2Fapp%2Fapp.module.ts)

## See also

[Jdenticon homepage](https://jdenticon.com)

---
_Source: https://npm.io/package/ngx-jdenticon · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
