Giter Site home page Giter Site logo

react-animals's Introduction

react-animals

React Animals

A React component to add customizable animal avatars to any project. Inspired by the Google Docs "Anonymous Animals", all images designed by Jefferson Cheng and property of Google. Images from Github repo by wayou.

Installation Process

Install from NPM:

npm install react-animals

Register the component globally (inside main.js):

import Animal from "react-animals";

Once you've successfully imported the component, simply add it to a file:

<Animal />

By default, this avatar is circular, 70px wide, and has a random color and animal. The available customizations are below.

Select an Animal

Animals

To specify an animal, use the name prop:

<Animal name="alligator" />

If you provide an invalid name, a random name will be used by default and a console error will be thrown. A full list of animals is available here.

Select a Color

Colors

To specify an color, use the color prop:

<!--Use a predefined color-->
<Animal color="red" />
<!--Use a hex-code -->
<Animal color="#856EE7" />

For colors, you may use pre-selected colors like red, orange, yellow, green, purple, teal (all dark-mode friendly), or you may use none for a transparent background. You can also provide a valid CSS hexcode as well. If you provide an invalid color, a random color will be used by default and a console error will be thrown.

Select a Size

Sizes

To specify a size, use the size prop:

<Animal size="100px" />
<Animal size="10vw" />
<Animal size="25%" />

Although pixel (px units) are preferred, this component supports any valid CSS width unit. By design, the height and width of the avatar will be the same. If you provide an invalid CSS width, a standard width of 70px will be used instead and a console error will be thrown. The max-width and height are 200px (to preserve image quality)

Select a Shape

Sizes

To specify a shape, you'll need to provide a particular shape prop:

<!--Use default circular shape, no prop needed-->
<Animal />
<!--Use a rounded square -->
<Animal rounded />
<!--Use a normal square -->
<Animal square />

If you provide both a square and rounded prop, the rounded option will be preferred. By default, all avatars will be circular.

Dance!

Dance

To animate an avatar, use the dance prop:

<!--Use default circular shape, no prop needed-->
<Animal dance />

This will make the avatar do a repeated dancing animation. You can apply this prop dynamically so that an avatar selectively dances (such as when a cursor is hovering over it).

All customizations

Below are some examples of react-animals that use multiple customization props at once:

<!--Alligator image, rounded square shape, random color, 70px size-->
<Animal name="alligator" rounded />

<!--Elephant image, square shape, blue color, 50px size-->
<Animal name="elephant" color="blue" size="50px" square />

<!--Animated dolphin image, circular shape, orange color, 80px size-->
<Animal name="dolphin" color="orange" size="80px" dance />

Lastly, all props can be dynamically generated using computed properties

<Animal name="{animalVar}" rounded="{isRounded}" />

react-animals's People

Contributors

arvinpoddar 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.