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

ipfs-image-drop

v1.0.9

Published

Drag and drop an image file to store it on IPFS

Downloads

101

Readme

A React component that allows dropping image files into the browser for automatic upload to IPFS

Installation

npm install ipfs-image-drop

Usage

import React from "react";
import ReactDOM from "react-dom";
import IpfsImageDrop from "ipfs-image-drop";

ReactDOM.render(
    <IpfsImageDrop
        ipfsHost="ipfs.infura.io"
        ipfsPort="5001"
        resizeWidth="100"
        onUpload={console.log} 
    />,
  document.getElementById("root")
);

Please see the examples folder for a more detailed example.

The following props are available:

ipfsHost

The host name of the IPFS node

ipfsPort

The port number of the IPFS node

resizeWidth/resizeHeight

If specified, the image will be resized to have this width/height, retaining the original aspect ratio. Note that only one resize attribute may be specified; resizeHeight or resizeWidth. If both are specified, one will be ignored.

onUpload

Function to call when the file has been uploaded to IPFS. The function will be called with an object of the following structure as the parameter:

{
    ipfsData: {
        hash: String, //IPFS hash of stored file
        path: String, //IPFS path of stored file
    },
    dataURL: String //Data URL of stored file
}

Styling

The component contains almost no styling. However, the drop zone element changes its class to reflect the current state. The following CSS selectors may be used to change the style of the drop zone depending on the state:


.IpfsImageDrop .iid-dropZone {
    /* Base style for the drop zone. */
}

.IpfsImageDrop .iid-dropZone.ready {
    /* The drop zone is ready for a file to be dropped, or a dropped file has been successfully uploaded. */
}

.IpfsImageDrop .iid-dropZone.draggingOver {
    /* A file has been dragged over the drop zone. */
}

.IpfsImageDrop .iid-dropZone.uploading {
    /* A file has been dropped into the drop zone and is being uploaded. */
}