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

dekob-avatar

v0.0.4

Published

Simple way to change your profile picture

Downloads

1

Readme

Profile Picture (React Component)

Demo | jQuery Version

demo gif

NPM Package

Now you can install this package using NPM or Yarn.

yarn add @dsalvagni/react-profile-picure or

npm i --save @dsalvagni/react-profile-picture

Read more at: https://github.com/dsalvagni/react-profile-picture/blob/v1.0.0/README.md

Setup

The better option would be to add this component into your project by cloning this repository and building it yourself with the design changes that you might want to make. I'm not sure if this is going to be published on NPM.

Anyway, you can always add it to your project also by installing using NPM + Github:

npm i --save git+https://github.com/dsalvagni/react-profile-picture.git

Example

import React, { Component } from 'react';

import ProfilePicture from "profile-picture"
import "profile-picture/build/ProfilePicture.css"

class App extends Component {
  constructor(props) {
    super(props)

    this.profilePictureRef = React.createRef();
  }

  handleUpload() {
    const PP = this.profilePicture.current;
    const imageData = PP.getData();
    const file = imageData.file;
    const imageAsDataURL = PP.getImageAsDataUrl();

    ...
    //add here the upload logic...
  }

  render() {
    return <ProfilePicture
      ref={this.profilePictureRef}
      useHelper={true}
      debug={true}
    />

    <button onClick={this.handleUpload.bind(this)}>Upload</button>
  }
}

Options

| Property | Type | Description | |---|---|---| | image | PropTypes.string | Set an startup image | | frameSize | PropTypes.number.isRequired | Set the app editor preview size | | frameFormat | PropTypes.oneOf(["circle", "square", "rounded-square"]) | Set the app editor preview format | | cropSize | PropTypes.number.isRequired | Set the size of cropped image. | | minZoom | PropTypes.number.isRequired | Minimum zoom required. | | maxZoom | PropTypes.number.isRequired | Maximum zoom required. | | minImageSize | PropTypes.number.isRequired | Minimum image size desired. | | maxImageSize | PropTypes.number.isRequired | Maximum image size desired. | | useHelper | PropTypes.bool.isRequired | Enable/Disable the use of a background helper image. | | debug | PropTypes.bool.isRequired | Enable/Disable logging events on console | | messages | PropTypes.object | Custom status messages |

Status Messages

| Property | Default Value | Description | |---|---|---| | DEFAULT | Drop your photo here or tap to select. | Default states, when there's no phot selected | | DRAGOVER | Drop your photo | When the user is dragging the photo over the component | | INVALID_FILE_TYPE | Only images allowed. | File different from image type | | INVALID_IMAGE_SIZE | Your photo must be larger than 350px. | Invalid image size |

Status Message Object Example

messages: {
  DEFAULT: "Drop your photo here or tap to select.",
  DRAGOVER: "Drop your photo",
  INVALID_FILE_TYPE: "Only images allowed.",
  INVALID_IMAGE_SIZE: "Your photo must be larger than 350px."
}

Callbacks

| Callback | Description | |---|---| | onImagePropertiesChange | Triggered always that any image property changes: Zoom, Position, etc.. Returns image data object. | | onImageLoading | Triggered while the image is being processed. | | onImageLoaded | Triggered when the image processing is finished. | | onImageRemoved | Triggered when the user removes the image. | | onError | Triggered when something goes wrong. Returns an error code. | | onZoomChange | Triggered when the image scale is changed. | | onStatusChange | Triggered when the app status changes, e.g: empty, loaded, drag over, etc. |

Methods

| Method | Parameters | Description | |---|---|---| | getImageAsDataUrl | quality. Image quality from 0.1 to 1 where 1 is the max quality. | Returns the image result as a Base64 image string. Use this if you want to use an image string to upload. | | getData | | Returns the image data. Use this to upload an image to be cropped by backend. | | setImage | image url/File | Set a new image to app trough API. |

Contributing

Contributions, issues and feature requests are very welcome. Please make sure to read the Contributing Guide before making a pull request.

Code of conduct

Find here our code of conduct.