All Projects β†’ synapsestudios β†’ react-drop-n-crop

synapsestudios / react-drop-n-crop

Licence: MIT license
An opinionated implementation of react-dropzone and react-cropper

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to react-drop-n-crop

Cropiwa
πŸ“ Configurable Custom Crop widget for Android
Stars: ✭ 2,185 (+12752.94%)
Mutual labels:  crop, cropper, crop-image, image-cropper
React Cropper
Cropperjs as React component
Stars: ✭ 1,600 (+9311.76%)
Mutual labels:  crop, cropper, crop-image, react-cropper
react-simple-crop
βœ‚οΈ A React component library for cropping and previewing images
Stars: ✭ 19 (+11.76%)
Mutual labels:  crop, cropper, crop-image
Krop
Small widget for image cropping in Instagram-like style
Stars: ✭ 107 (+529.41%)
Mutual labels:  crop, cropper, crop-image
xcrop
Mobile image cropping component - Vue React 移动端裁ε‰ͺη»„δ»Ά
Stars: ✭ 27 (+58.82%)
Mutual labels:  cropper, crop-image, image-cropper
Faimagecropper
Image Cropper like Instagram
Stars: ✭ 188 (+1005.88%)
Mutual labels:  cropper, crop-image, image-cropper
pikaso
Seamless and headless HTML5 Canvas library
Stars: ✭ 23 (+35.29%)
Mutual labels:  crop, cropper, crop-image
Tocropviewcontroller
A view controller for iOS that allows users to crop portions of UIImage objects
Stars: ✭ 4,210 (+24664.71%)
Mutual labels:  crop, cropper, crop-image
Croppy
Image Cropping Library for Android
Stars: ✭ 906 (+5229.41%)
Mutual labels:  crop, cropper, crop-image
Bimg
Go package for fast high-level image processing powered by libvips C library
Stars: ✭ 1,394 (+8100%)
Mutual labels:  crop, crop-image
cropimg
Another cropping jQuery plugin
Stars: ✭ 30 (+76.47%)
Mutual labels:  cropper, crop-image
Pdfcropmargins
pdfCropMargins -- a program to crop the margins of PDF files
Stars: ✭ 141 (+729.41%)
Mutual labels:  crop, cropper
Svg Autocrop
πŸš—πŸŒ½πŸ”³An NPM module to autocrop and slim down SVGs
Stars: ✭ 80 (+370.59%)
Mutual labels:  crop, crop-image
Svelte Easy Crop
A Svelte component to crop images with easy interactions
Stars: ✭ 80 (+370.59%)
Mutual labels:  crop, crop-image
Rskimagecropper
An image cropper / photo cropper for iOS like in the Contacts app with support for landscape orientation.
Stars: ✭ 2,371 (+13847.06%)
Mutual labels:  crop, cropper
Igrphototweaks
Drag, Rotate, Scale and Crop
Stars: ✭ 212 (+1147.06%)
Mutual labels:  crop, crop-image
Vue Croppie
Vue wrapper for croppie
Stars: ✭ 228 (+1241.18%)
Mutual labels:  crop, crop-image
React Easy Crop
A React component to crop images/videos with easy interactions
Stars: ✭ 1,093 (+6329.41%)
Mutual labels:  crop, crop-image
Dropzone
Dropzone is an easy to use drag'n'drop library. It supports image previews and shows nice progress bars.
Stars: ✭ 16,097 (+94588.24%)
Mutual labels:  drag-and-drop, dropzone
yii2-dropzone
This extension provides the Dropzone integration for the Yii2 framework.
Stars: ✭ 11 (-35.29%)
Mutual labels:  drag-and-drop, dropzone

@synapsestudios/react-drop-n-crop

A combined implementation of react-dropzone and react-cropper (Cropper.js) for front-end image upload/validation/cropping.

npm version react-drop-n-crop dependencies react-drop-n-crop peer dependencies

Demo

A demo is available at https://synapsestudios.github.io/react-drop-n-crop/

Usage

Installing via CLI

// yarn
yarn add @synapsestudios/react-drop-n-crop

// npm
npm install --save @synapsestudios/react-drop-n-crop

Importing JS

import DropNCrop from '@synapsestudios/react-drop-n-crop';

Importing CSS

// Minified, autoprefixed css
import '@synapsestudios/react-drop-n-crop/lib/react-drop-n-crop.min.css';

// Not-minified, not-autoprefixed css
import '@synapsestudios/react-drop-n-crop/lib/react-drop-n-crop.css';

Using Stylus

If you are using Stylus you can import the .styl file into your build:

@import '@synapsestudios/react-drop-n-crop/lib/react-drop-n-crop.styl';

! See the Stylus Variables section below for variables/details.

Using with an ES6 Class and React Component State

import React, { Component } from 'react';
import DropNCrop from '@synapsestudios/react-drop-n-crop';
import '@synapsestudios/react-drop-n-crop/lib/react-drop-n-crop.min.css';

class SetStateExample extends Component {
  state = {
    result: null,
    filename: null,
    filetype: null,
    src: null,
    error: null,
  };

  onChange = value => {
    this.setState(value);
  };

  render() {
    return <DropNCrop onChange={this.onChange} value={this.state} />;
  }
}

export default SetStateExample;

API

Required Props

DropNCrop is built as a controlled component. The following props must be supplied to the component:

onChange: (required)

onChange is the callback function invoked when an image is dropped or cropped. onChange returns an object (in the shape of value below).

onChange: PropTypes.func.isRequired,

value: (required)

value is the object passed back from the onChange function. It must be in the following shape:

value: PropTypes.shape({
  result: PropTypes.string, // Resulting DataURL from Cropper.js crop box
  filename: PropTypes.string, // Original filename from uploaded file
  filetype: PropTypes.string, // Original MIME type from uploaded file
  src: PropTypes.string, // Original DataURL from the FileReader.result
  error: PropTypes.string, // Error returned from fileSize/fileType validators
}).isRequired,

Optional Props

canvasHeight:

canvasHeight is a string for the container inline style height property.

canvasHeight: PropTypes.string, // default: '360px'

canvasWidth:

canvasWidth is a string for the container inline style width property.

canvasWidth: PropTypes.string, // default: '100%'

className:

className is a string for the outermost container class name.

className: PropTypes.string, // default: ''

cropperOptions:

cropperOptions is an object for customizing the cropper component. Lists of available options can be found here: https://github.com/roadmanfong/react-cropper

cropperOptions: PropTypes.object, // default: {guides: true, viewMode: 0, autoCropArea: 1}

maxFileSize:

maxFileSize is a maximum number (in bytes) for file upload validation.

maxFileSize: PropTypes.object, // default: 3145728

allowedFileTypes:

allowedFileTypes is an array (of strings) of valid MIME types for file upload validation.

allowedFileTypes: PropTypes.array, // default: ['image/jpeg', 'image/jpg', 'image/png']

Stylus Variables

react-drop-n-crop comes with a set of stylus variables that can be overridden to add your own project-specific theming, as shown below:

/* Theming by overriding default stylus variables with your projects colors */

$drop-n-crop--primary-color = $your-project-primary-color;
$drop-n-crop--error-color = $your-project-error-color;

$drop-n-crop--body-color = $your-project-body-color;
$drop-n-crop--heading-color = $your-project-heading-color;

$drop-n-crop--input-background-color = $your-project-background-color;
$drop-n-crop--input-border-color = $your-project-border-color;

@import '@synapsestudios.com/react-drop-n-crop/css/react-drop-n-crop.styl';

Contributing

To run the project on your own computer:

  • Clone this repository
  • yarn install or npm install
  • yarn run storybook or npm run storybook
  • Visit http://localhost:5000/
  • Changes made to files in the src directory should immediately compile and be visible in your browser.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].