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

vue-boring-avatars

v1.4.0

Published

vue-boring-avatars is a Vue.js port of Boring Avatars, a JS library that generates custom, SVG-based avatars from any username and color palette.

Downloads

71,380

Readme

vue-boring-avatars

hi License: MIT MadeWithVueJs.com shield

vue-boring-avatars is a Vue 3 port of Boring Avatars, a JS library that generates custom, SVG-based avatars from any username and color palette.

Features

  • Supports Vue 3 (for Vue 2, look at this implementation).
  • Built using TypeScript and comes with TS types.
  • Similar API with the React version of Boring Avatars.

Installation

NPM:

pnpm i vue-boring-avatars
# or
yarn add vue-boring-avatars
# or
npm install vue-boring-avatars

CDN:

<!-- ESM version -->
<script type="module">
  import Avatar from "https://unpkg.com/vue-boring-avatars/dist/vue-boring-avatars.js";
</script>

<!-- UMD version -->
<script src="https://unpkg.com/vue-boring-avatars/dist/vue-boring-avatars.umd.cjs"></script>

Props

Props:

  • size: number
    • Default: 40
    • Determines the size of the Avatar.
  • square: boolean
    • Default: false
    • Whether the Avatar is shaped as a square or circle (default).
  • title: boolean
    • Default: false
    • Whether to generate the <title> element or not.
  • name: string
    • Default: "Clara Barton"
    • Name that determines the pattern of the Avatar, and appears in the <title> element if title is true.
  • variant: string
    • Accepts either of the following: "bauhaus", "beam", "marble", "pixel", "ring", "sunset".
    • Default: "marble"
    • Determines the variant of the Avatar.
  • colors: string[]
    • Accepts a string of colors.
    • Default: ["#92A1C6", "#146A7C", "#F0AB3D", "#C271B4", "#C20D90"]
    • Determines the range of colors in the Avatar.
  • id: string
    • ID for the SVG element.

Usage

Basic usage (with default props):

<template>
  <Avatar />
</template>

<script>
import Avatar from "vue-boring-avatars";

export default {
  components: {
    Avatar,
  },
};
</script>

Basic usage with <script setup> (with default props):

<script setup>
import Avatar from "vue-boring-avatars";
</script>

<template>
  <Avatar />
</template>

With props:

<template>
  <Avatar :size="80" variant="bauhaus" name="Mujahid Anuar" :colors="colors" />
</template>

<script>
import Avatar from "vue-boring-avatars";

export default {
  data() {
    return {
      colors: ["#92A1C6", "#146A7C", "#F0AB3D", "#C271B4", "#C20D90"],
    };
  },
  components: {
    Avatar,
  },
};
</script>

With Composition API:

<template>
  <input type="text" v-model="name" />
  <input type="number" v-model.number="size" />

  <Avatar :size="size" variant="bauhaus" :name="name" />
  <Avatar
    :size="size"
    variant="beam"
    :name="name"
    :square="true"
    :title="true"
  />
  <Avatar :size="size" variant="marble" :name="name" />
  <Avatar
    :size="size"
    variant="pixel"
    :name="name"
    :square="true"
    :title="true"
  />
  <Avatar :size="size" variant="ring" :name="name" />
  <Avatar
    :size="size"
    variant="sunset"
    :name="name"
    :square="true"
    :title="true"
  />
</template>

<script lang="ts">
import { defineComponent, ref } from "vue";
import Avatar from "vue-boring-avatars";

export default defineComponent({
  name: "App",
  setup() {
    const name = ref("Clara Barton");
    const size = ref(80);

    return {
      name,
      size,
    };
  },
  components: {
    Avatar,
  },
});
</script>

Development

pnpm i # install packages
pnpm dev # launch in browser
pnpm test # run tests (download react-boring-avatars, lint, type check, then run tests)
pnpm build # build the dist

Credits

Credits to @hihayk (GitHub) and @josep_martins (GitHub) for creating the original Boring Avatars library at boringdesigners!