npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@frnak/vuevatar

v0.2.2

Published

A flexible svg based vue.js component to create an avatar.

Downloads

1

Readme

vuevatar

A flexible svg based vue.js component to create an avatar.

Important Note: The component is still under development and not yet meant for productive use. Issues can be tracked on Github.

Demo

A demo can be found here

Usage

npm install --save @frnak/vuevatar

Single File Components

<template>
  <div class="page">
    <vue-avatar 
      @load="onAvatarLoad" 
      v-model="user.avatar"
    ></vue-avatar>
  </div>
</template>

<script>
import Vuevatar from '@frnak/vuevatar'

export default {
  data () {
    return {
      user: {
        avatar: null
      }
    }
  },

  methods: {
    onAvatarLoad (data) {
      this.user.avatar = data.random
    }
  },

  components: {
    'vue-avatar': Vuevatar
  }
}
</script>

Using the Test.vue

You can clone this repo and play with the Test.vue file in the test directory. You'll need vue-cli and the services intalled globally in order to make it run. (See the docs for more infromation)[https://cli.vuejs.org/guide/prototyping.html]

  • npm install -g @vue/cli-service-global
  • npm install
  • npm run test

Features

Most important is the value property that can be bound to the component. This can either be done using v-model or :value. The passed object can set the different attributes of the avatar. An avatar consists of

  • background
  • backgroundColor
  • head
  • headColor
  • mouth
  • eyes
  • eyebrows
  • clothes
  • clothesColor
  • hair
  • hairColor
  • accessoir
  • beard

Each of these has a predefined set of options that can be passed via the value property of the component.

To make it easy to build an editor for the avatar component, the component will emit a load event after it is setup. The event will contain the information about the options that can be passed to the different properties of value and in addition it will contain a random avatar setup.

The data payload looks like

{
  options: {
    accessoir: {
      Flower: Object,
      Ninja: Object
    },
    background: {
      ...
    },
    ...
  }
  random: {
    accessoir: "Ninja",
    background: "Circle",
    ...
  }
}

The properties that are represented in random can directly passed to the value prop of the component as shown in the basic example at the very top. You can ofcourse also set every attribute individually.

data () {
  return {
    avatar: {
      background: "Circle",
      backgroundColor: "Blue",
      accessoir: "Ninja"
      clothes: "Shirt",
      clothesColor: "Green",
      eyebrows: "Mono",
      eyes: "Closed",
      hair: "WorkerHelmet",
      head: "Default",
      headColor: "Black",
      mouth: "Grin",
      beard: "None"
    }
  }
}

And bind these directly to the component

<vue-avatar :value="avatar"></vue-avatar>

Available Options

| Property | Allowed Values | | --------------- | ------------- | | background | Circle,Box | | backgroundColor | Black,White,Blue,Green,Grey,Pink,Purple,Red | | accessoir | None,Ninja,Flower,Glasses,Devil,Feather | | clothes | Shirt,vNeckShirt,FancyShirt,Hoodie,Dress | | clothesColor | Black,White,Blue,Green,Grey,Pink,Purple,Red,Yellow | | eyebrows | None,Concerned,Mono,Angry,Bushy,Evil | | hair | None,Male01,Male02,Female01,Female02,Female03,Female04,Bommel,WorkerHelmet | | hairColor | Black,Blonde,Red,Brown | | head | Default | | headColor | White,Brown,Yellow,Black | | mouth | Gap,Grin,Kiss,Neutral,Sad,Shocked,ShowTeeth,Smile,Tongue | | beard | None,Walrus,Goaty |

Not every hair accepts a color via hairColor. Not every clothes accepts a color via clothesColor.

Download

The vuevatar component has a download method that will trigger the download of the currently configured avatar. Example

Define a ref to make the component accessible via this.$refs

<vue-avatar 
  ref="avatar"
  ...
></vue-avatar>

<button @click="download">Download</button>

Get the component and call the download method.

methods: {
  download () {
    this.$refs.avatar.download()
  }
}