Giter VIP home page Giter VIP logo

vue-avatar-component's Introduction

vue-avatar-component

This vue.js component provide a simple way to generate rounded and colored avatar stickers to use in your applications.

If you just provide a name to the component, i will show a colored patch showing the provided name's initials. Its color is depending and is unique for each given name.

If you provide an image url, this image will be shown, sized and truncated to fit into the component's placeholder.

Installation

npm install --save-dev vue-avatar-component

Example Usage from within a .vue component

<template>
  <div>
    <avatar fullname="My Sticker" size="96"></avatar>
  </div>
</template>

<script>
  import Avatar from 'vue-avatar-component'
  export default {
    components: { Avatar }
  }
</script>

This will show this avatar as result :

avatar

Parameters

fullname : the full name from which the initials and the color will be computed. Initials are extracted taking the first letter of each word, separated by a space or an hyphen. If there is more, only the 3 first initials are kept. For example, Foo Bar gives FB, My Foo-Bar gives MFB, FOO gives F and My Fantastic Vue Component gives MFV. If not provided, fullname defaults to '##'.

size : the size of the sticker to generate, in pixels. If not provided, the size defaults to 48 pixels. The font size inside the avatar is computed from its overall size (half if 1 or 2 letters, third for 3 letters).

image : the url of the image to fit in the avatar sticker. If provided not empty, initials will not show and the image wil be shown. Be careful that if the provided image url is wrong, the component has its size but shows nothing.

radius : percentage of the overall size to show the rounded corners of the avatar. Provide a number beetween 0 and 50 : at 0%, the avatar will be a square, at 50% it will be exactly circular. This percentage defaults to 50 if not provided.

color : If provided, overides the computed color for the initials based avatar. Just provide a CSS color (named, hex or rgba fits).

examples

If images don't show, go to this component's github repository to see the full README.

<avatar fullname="My Fabulous Component"></avatar> will show :
<avatar fullname="Foo Bar" size="60"></avatar> will show :
<avatar image="http://lorempicsum.com/simpsons/255/200/9" size="96"></avatar> will show :
<avatar image="http://lorempicsum.com/simpsons/255/200/5" size="96" radius="0"></avatar> will show :
<avatar fullname="Foo Bar" radius="25" color="red"></avatar> will show :

License

This Vue.js component is licensed under MIT License :

Copyright © 2016, Stéphane Souron

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

The Software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software. Except as contained in this notice, the name of the Stéphane Souron shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from Stéphane Souron.

vue-avatar-component's People

Contributors

onexdata avatar ssouron avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.