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-drag-drop-files-myv

v2.3.16

Published

Light React Drag & Drop files and images library styled by styled-components

Downloads

730

Readme

React Drag and Drop Files

Version code style: prettier npm download

Light and simple reactjs drag and drop files library to use with very flexible options to change, so you put whatever the design you want for your drop-area. Users can drag and drop or even select the file anywhere in the window.

Demo

Edit react-drag-drop-files

Installation

Install it from npm (using NPM).

npm i --save react-drag-drop-files

or:

yarn add react-drag-drop-files

Usage

Using react hooks just as simple as:

import React, { useState } from "react";
import { FileUploader } from "react-drag-drop-files";

const fileTypes = ["JPG", "PNG", "GIF"];

function DragDrop() {
  const [file, setFile] = useState(null);
  const handleChange = (file) => {
    setFile(file);
  };
  return (
    <FileUploader handleChange={handleChange} name="file" types={fileTypes} />
  );
}

export default DragDrop;

Options

| Option | Type | Description | value example | | ------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- | | name | string | the name for your form (if exist) | "myFile" | | multiple | boolean | a boolean to determine whether the multiple files is enabled or not | true OR false - false by default | | label | string | the label (text) for your form (if exist) inside the uploading box - first word underlined | "Upload or drop a file right here" | | required | boolean | Conditionally set the input field as required | true or false| | disabled | boolean | this for disabled the input | true OR false | | hoverTitle | string | text appears(hover) when trying to drop a file | "Drop here" | | fileOrFiles | Array or File or null | this mainly made because if you would like to remove uploaded file(s) pass null or pass another file as initial | | classes | string | string with the classes wished to add | "drop_area drop_zone" | | types | Array | array of strings with extensions to check and go throw | ['png', 'jpeg', ...] | | onTypeError | function | function that will be called only of error occurred related to type | (err) => console.log(err) | | children | JSX Element, any | if you want to replace the current design inside the box of drop zone. (it will remove the default exist style) | <div><p>this is inside drop area</p></div> or just text | | maxSize | number | the maximum size of the file (number in mb) | 2 | | minSize | number | the minimum size of the file (number in mb) | 1 | | onSizeError | function | function that will be called only if error related to min or max size occurred | (file) => console.log(file) | | onDrop | function | function that will be called when the user drops file(s) on the drop area only | (file) => console.log(file) | | onSelect | function | function that will be called when the user selects file(s) on click the file area only | (file) => console.log(file) | | handleChange | function | function that will be called when the user selects or drops file(s) | (file) => console.log(file) | | onDraggingStateChange | function | function that will be called with the state of dragging | (dragging) => console.log(dragging) | | dropMessageStyle | CSS Properties | A CSS property to style the hover message | {backgroundColor: 'red'} |

How to contribute:

  • Please follow the instructions inside this file: here

Upcoming...

  • [X] Contribution Guide
  • [X] Github actions

License

MIT