0.0.2 • Published 7 years ago

react-get-avatar v0.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

react-get-avatar

React Component that allows you to get an avatar using a webcam or upload from a file and crop it.

See browser support here

Demo

Usage

<GetAvatar width={400} height={400} handleGet={ handleGetAvatar } />

You can use something like this to upload the image on server:

handleGetAvatar(dataURI) {
  const blob = dataURItoBlob(dataURI);
  const formData = new FormData();
  formData.append('image', blob);

  postData('/upload', formData);
}

Installation

npm install react-get-avatar

Properties

PropertyRequiredTypeDefault ValueAvailable ValuesDescription
widthtruenumber0Any numberAvatar width
heighttruenumber0Any numberAvatar height
imageTypefalsestringimage/jpegimage/jpeg, image/png, image/gif, image/webpAvatar image type
imageQualityfalsenumber0.5from 0.1 to 1Avatar image quality
classNamefalsestringComponent className
navClassNamefalsestringNavigation className
buttonClassNamefalseshape({ toggle: string, upload: string, save: string, cancel: string })Buttons classNames
handleGettruefuncCallback that returns image dataURI

More