How to use the @dicebear/avatars function in @dicebear/avatars

To help you get started, we’ve selected a few @dicebear/avatars examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DiceBear / avatars / server / server / actions / v2.ts View on Github external
// Check whether the image exists at Gravatar.
          await request.head(gravatarUrl).promise();

          res.redirect(gravatarUrl);

          return;
        } catch (e) {
          // No image available at Gravtar, therefore no forwarding.
        }
      }

      res.status(200);
      res.setHeader('Content-Type', 'image/svg+xml');
      res.setHeader('Cache-Control', 'public, max-age=' + ms(privateConfig.apiHttpCaching) / 1000);
      res.end(new Avatars(spriteCollectionPackage(options.cast(requestOptions))).create(seed));
    } catch (e) {
      console.error(e);

      res.status(500).end('Failed to load package ' + spriteCollection.name);
    }
  }
);
github oipwg / oip-platform-react / src / components / PublisherIcon.js View on Github external
import React, { Component } from 'react';

import Avatars from '@dicebear/avatars';
import MaleSpriteCollection from '@dicebear/avatars-male-sprites';
import FemaleSpriteCollection from '@dicebear/avatars-female-sprites';

let maleAvatars = new Avatars(MaleSpriteCollection);
let femaleAvatars = new Avatars(FemaleSpriteCollection);

class PublisherIcon extends Component {
	constructor(props){
		super(props);

		this.state = {
			avatarSrc: ""
		}

		this.updateAvatar = this.updateAvatar.bind(this);
		this.setDiceBearAvatar = this.setDiceBearAvatar.bind(this);
	}
	componentDidMount(){
		// Every time the state changes, log it
		this.updateAvatar(this.props)
	}
github oipwg / oip-platform-react / src / components / PublisherIcon.js View on Github external
import React, { Component } from 'react';

import Avatars from '@dicebear/avatars';
import MaleSpriteCollection from '@dicebear/avatars-male-sprites';
import FemaleSpriteCollection from '@dicebear/avatars-female-sprites';

let maleAvatars = new Avatars(MaleSpriteCollection);
let femaleAvatars = new Avatars(FemaleSpriteCollection);

class PublisherIcon extends Component {
	constructor(props){
		super(props);

		this.state = {
			avatarSrc: ""
		}

		this.updateAvatar = this.updateAvatar.bind(this);
		this.setDiceBearAvatar = this.setDiceBearAvatar.bind(this);
	}
	componentDidMount(){
		// Every time the state changes, log it
		this.updateAvatar(this.props)
github luniehq / lunie / src / components / common / Avatar.vue View on Github external
svg() {
      const options = {}
      const avatars = new Avatars(sprites(options))
      return avatars.create(this.address)
    }
  }

@dicebear/avatars

An avatar library for designers and developers.

MIT
Latest version published 2 years ago

Package Health Score

58 / 100
Full package analysis