1.0.2 • Published 4 years ago

react-katar v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

react-katar

Create random avatars from user IDs, no need to store it on the server

NPM JavaScript Style Guide

img

Demo

https://lnquy065.github.io/react-katar

Install

npm install --save react-katar

Usage

import React, { Component } from 'react'

import { Avatar } from 'react-katar'

class Example extends Component {
  render() {
    return <Avatar id="Hello" />
  }
}

Customize

Shapes

  • Square (default)
  • Circle

img

// square
<Avatar  id="Hello"/>

// circle
<Avatar  id="Hello" shape="circle"/>

Border

  • None (default)
  • Border color (the same with avatar's color as default)
  • Border width (default: 3px)

img

// default
<Avatar  id="Hello" shape="circle" border/>

// custom border width
<Avatar  id="Hello" shape="circle" border borderWidth="5px"/>

// custom border color
<Avatar  id="Hello" shape="circle" border borderColor="black"/>

Size

  • width (default: 90px)
  • height (the same with width but can't manual setting)

img

// default
 <Avatar  id="Hello" shape="circle" border/>

// custom size
<Avatar  id="Hello" shape="circle" border width="100"/>
<Avatar  id="Hello" shape="circle" border width="120"/>

Salt

You can add salt to avatar to create another avatar from the same Id

img

<Avatar id="Hello" shape="circle" border salt="hello"/>

<Avatar id="Hello" shape="circle" border salt="my-name"/>

<Avatar id="Hello" shape="circle" border  salt="is-quy"/>

Properties

property nametypedefaultdescription
idstringrequiredUse for create avatar
saltstringnoneAppended after the id
widthnumber90Avatar's width, base on px unit
shapesquare,circlesquareAvatar's shape
backgroundColorstring#FFFFFFAvatar's background color
borderboolfalseEnable border
borderWidthstring3pxBorder's width
borderColorstringnoneBorder's color, leave empty if you want to set avatar color to this property
canvasStyleobjectnoneStyle object for canvas

License

MIT © lnquy065

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago