Skip to content

Commit

Permalink
identiconSvg tree shaking + node <14 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentpayot committed Feb 10, 2022
1 parent e5f3e6e commit 833ffb3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ By default the color saturation and lightness are set to 50%. But you can change
```html
<identicon-svg username="alienHead66" saturation="95" lightness="60">
```

Play with [the demo](https://laurentpayot.github.io/minidenticons/) to find a combination of saturation and lightness that matches your website theme colors: light, dark, pastel or whatever :sunglasses:

![Minidenticons](minidenticons_light.png)
Expand All @@ -77,6 +78,8 @@ npm install minidenticons
import { identicon } from 'minidenticons'
```

The `identicon-svg` custom element should be tree-shaken from your bundle, for an even smaller size of minidenticons :grin:

### Usage

```typescript
Expand Down
3 changes: 2 additions & 1 deletion minidenticons.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export function identicon(username, saturation=DEFAULT_SATURATION, lightness=DEF
}

export const identiconSvg =
globalThis.customElements?.define('identicon-svg',
// optional chaining only available on node 14+
globalThis.customElements && /*@__PURE__*/customElements.define('identicon-svg',
class extends HTMLElement {
constructor() { super() }
connectedCallback() { this.identiconSvg() }
Expand Down
2 changes: 1 addition & 1 deletion minidenticons.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion minidenticons.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 833ffb3

Please sign in to comment.