Giter Club home page Giter Club logo

react-avatar's Introduction

<Avatar>

Universal avatar makes it possible to fetch/generate an avatar based on the information you have about that user. We use a fallback system that if for example an invalid Facebook ID is used it will try Google, and so on.

For the moment we support following types:

  • Facebook
  • Google
  • Skype
  • Gravatar
  • Name initials
  • Custom text
  • Custom image

The fallbacks are in the same order as the list above were Facebook has the highest priority.

Demo

Check it live!

Install

Install the component using NPM:

$ npm install react-avatar --save

Or download as ZIP.

Usage

  1. Import Custom Element:

    var Avatar = require('react-avatar');
  2. Start using it!

    <Avatar />

Some examples:

<Avatar google-id="118096717852922241760" size="100" round="true" />
<Avatar facebook-id="100008343750912" size="150" />
<Avatar skype-id="sitebase" size="200" />
<Avatar name="Wim Mostmans" size="150" />
<Avatar value="86%" size="40" />
<Avatar size="100" facebook-id="invalidfacebookusername" src="http://www.gravatar.com/avatar/a16a38cdfe8b2cbd38e8a56ab93238d3" />

Options

Attribute Options Default Description
email string String of the email address of the user. You can also provide an MD5 hash.
facebook-id int OR string
google-id int
skype-id string
name string Will be used to generate avatar based on the initials of the person
value string Show a value as avatar
color string random Used in combination with name and value
size int 50 Size of the avatar
round bool false Round the avatar corners
src string Fallback image to use

Development

In order to run it locally you'll need to fetch some dependencies and a basic server setup.

  • Install Grunt:

    $ [sudo] npm install -g grunt-cli
  • Install local dependencies:

    $ npm install
  • Auto build new test version when developing that can be run with grunt connect:

    $ grunt watch
  • To test your project, start the development server and open http://localhost:8000.

    $ grunt connect
  • To provide a live demo, send everything to gh-pages branch.

    $ grunt deploy

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

History

For detailed changelog, check Releases.

License

MIT License

Todo

  • Add Jest unit tests

react-avatar's People

Contributors

sitebase avatar ronnross avatar hartmamt avatar

Watchers

 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.