npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

exif-avatar

v0.0.1

Published

Auto Rotate, load, crop, and preview avatars

Downloads

3

Readme

react-avatar

👤 Load, crop and preview avatar with ReactJS component

npm version

Demo

Demo website

Install

npm i react-avatar-edit

Usage

import React from 'react'
import ReactDOM from 'react-dom'
import Avatar from 'react-avatar-edit'

class App extends React.Component {

  constructor(props) {
    super(props)
    const src = './example/einshtein.jpg'
    this.state = {
      preview: null,
      src
    }
    this.onCrop = this.onCrop.bind(this)
    this.onClose = this.onClose.bind(this)
    this.onBeforeFileLoad = this.onBeforeFileLoad.bind(this)
  }
  
  onClose() {
    this.setState({preview: null})
  }
  
  onCrop(preview) {
    this.setState({preview})
  }

  onBeforeFileLoad(elem) {
    if(elem.target.files[0].size > 71680){
      alert("File is too big!");
      elem.target.value = "";
    };
  }
  
  render () {
    return (
      <div>
        <Avatar
          width={390}
          height={295}
          onCrop={this.onCrop}
          onClose={this.onClose}
          onBeforeFileLoad={this.onBeforeFileLoad}
          src={this.state.src}
        />
        <img src={this.state.preview} alt="Preview" />
      </div>
    )
  }
}

ReactDOM.render(<App /> , document.getElementById('root'))

Component properties

| Prop | Type | Description | ---------------------- | ---------------- | --------------- | img | Image | The Image object to display | src | String/Base64 | The url to base64 string to load (use urls from your domain to prevent security errors) | width | Number | The width of the editor | height | Number | The height of the editor (image will fit to this height if neither imageHeight, nor imageWidth is set) | imageWidth | Number | The desired width of the image, can not be used together with imageHeight | imageHeight | Number | The desired height of the image, can not be used together with imageWidth | cropRadius | Number | The crop area radius in px (default: calculated as min image with/height / 3) | cropColor | String | The crop border color (default: white) | lineWidth | Number | The crop border width (default: 4) | minCropRadius | Number | The min crop area radius in px (default: 30) | backgroundColor | Sting | The color of the image background (default: white) | closeIconColor | String | The close button color (default: white) | shadingColor | String | The shading color (default: grey) | shadingOpacity | Number | The shading area opacity (default: 0.6) | mimeTypes | String | The mime types used to filter loaded files (default: image/jpeg,image/png) | label | String | Label text (default: Choose a file) | labelStyle | Object | The style object for preview label (use camel case for css properties fore example: fontSize) | borderStyle | Object | The style for object border preview (use camel case for css properties fore example: fontSize) | onImageLoad(image) | Function | Invoked when image based on src prop finish loading | onCrop(image) | Function | Invoked when user drag&drop event stop and return croped image in base64 sting | onBeforeFileLoad(file) | Function | Invoked when user before upload file with internal file loader (etc. check file size) | onFileLoad(file) | Function | Invoked when user upload file with internal file loader | onClose() | Function | Invoked when user clicks on close editor button

Contributing

  • To start developer server please use npm run start
  • To build production bundle use npm run build