Giter Club home page Giter Club logo

image-uploader's Introduction

Image Uploader

  • A simple image uploading interface for React

Installation

npm i react-image-upload-interface
import { ImageUploader } from 'react-image-upload-interface'

Usage

  <ImageUploader
    Width='80vh'
    Height='60vh'
    submitButtonStyle={submitButtonStyle}
    handleFileSubmit={handleFileSubmit}
  />

Required Props

  • Use the Width and Height props to specify the width and height of the component
  • To access an array of submitted files, it's important to pass in a handleFileSubmit callback function:
  handleFileSubmit = (files) => /* code to handle raw image files */

Optional Props

  • Use the uploadButtonStyle and submitButtonStyle props to style the respective buttons
  • The MaxResolution and MaxFileSize props specify the level of compression each image incurs. By default, images have a max height or width of 1920px and a max file size of 1mb

How It Works

  • This image upload interface accepts the uploading of .png, .jpg, and .jpeg files
  • Users can swap the position of the images by using drag-and-drop, and this order will be reflected upon submission
  • Users can delete images from the list
  • Uploading the same image name will not produce a second copy of that image to appear

Under The Hood

  • Swapping of image positions is handled using in-line styles, requiring only the two individual images to be re-rendered in constant time
  • Once uploaded, images are compressed to improve browser performance
    • A reference to the raw image file is retained in memory via a hashmap
    • Compression is handled asynchronously, and a loading spinner is provided for user feedback
  • Upon submission, the individual images in the DOM are references for their order and applied to the raw files in memory, requiring only a single linear runtime operation

Contributions

  • Authored by Stephen Rivas
  • To contribute to this repo:
    • fork, clone and submit a feature branch as a pull request

image-uploader's People

Contributors

stephenscript avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.