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

react-cropper-angeloog

v1.8.0

Published

This is a light library without any dependencies for cropping image for avatar

Downloads

7

Readme

React Avatar Image Cropper

A light library without any dependencies cropping tool for React. Both working for web and mobile.

Installation

npm i react-cropper-angeloog --save

Usage

Include the main js module, e.g:

import AvatarImageCropper from 'react-cropper-angeloog'

also you can implement the library as external js, add the script in build directory like below:

<script src='/dist/index.js'></script>

you will get the AvatarImageCropper in window object.

Set the container for cropper and pass apply function for handling cropped file, e.g:

apply = (file) => {
    // handle the blob file you want
    // such as get the image src
    var src = window.URL.createObjectURL(file);
}
render() {
    return (
        <div style={{ width: '250px', height: '250px', margin: 'auto', border: '1px solid black' }}>
            <AvatarImageCr apply={this.apply} />
        </div>
    );
}

Props

Most of the props is used for customizing the display:

apply(required, function)

The apply function will get the cropped blob file, you can handle it whatever you want.

cancel(optional, function)

The cancel function fired when you cancel cropping.

errorHandler(optional, function)

When the file is not image of png/jpg/jpeg or the file size exceed maxsize(default is 2M), the error message will displayed inside container as default. You can handle the error with errorHandler, then the default behavoir will not be fired again. With errorHandler, when file is not image return "not_image", when exceeded size return "maxsize".

errorHandler = (type) => {
  console.log(type)
}
;<AvatarImageCr apply={this.apply} errorHandler={this.errorHandler} />

isBack(optional, bool, default:false)

when there is a background image in container, pass true to change the avatar background and text color

text(optional, string or react component, default:Upload photo)

replace the initial text.

previewBorderRadius(optional, string or react component, default: 0)

when an borderRadius is needed for the avatar and/or for the preview of the avatar.

AvatarImageCropper previewBorderRadius='300px'

actions(optional, array of react components)

replace the cancel/apply buttons with customized button. The first one must be as cancel, and the second one must be as apply

const actions = [
        <button key={0}>test_cancel</button>,
        <button key={1}>test_apply</button>,
    ]
    <AvatarImageCr apply={this.apply} actions={actions} />

icon(optional, react component)

replace the initial display of icon.

const icon = (
                <svg viewBox="0 0 24 24" style={this.iconStyle}>
                    <circle cx="12" cy="12" r="3.2"></circle>
                    <path
                        d="M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"></path>
                </svg>
                )

<AvatarImageCr apply={this.apply} icon={icon}/>

loadingNode(optional, react component)

replace the initial display of loading component.

maxsize(optional, number)

set the maxsize of uploaded image, default value is 2M

const maxsize= 1024 * 1024 *5

<AvatarImageCr apply={this.apply} maxsize={maxsize}/>

className(optional, string)

set the class for the root element

iconStyle(optional, object)

set the initial icon style

textStyle(optional, object)

set the initial text style

errorStyle(optional, object)

set the error text style

rootStyle(optional, object)

set the root element style

sliderConStyle(optional, object)

set the container of slider style

sliderChildrenDiv(optional, object)

set the container div of slider style

cancelBtnStyle(optional, object)

set the cancel button style(if the there is actions prop, then the style is no working)

applyBtnStyle(optional, object)

set the apply button style(if the there is actions prop, then the style is no working)

Contributing / Developing

To view the demo or develop,open the demo directory and under it,

npm install
npm start

you can open localhost:8080 in a browser to try.

License

MIT