Gathering detailed insights and metrics for @synapsestudios/react-drop-n-crop
Gathering detailed insights and metrics for @synapsestudios/react-drop-n-crop
Gathering detailed insights and metrics for @synapsestudios/react-drop-n-crop
Gathering detailed insights and metrics for @synapsestudios/react-drop-n-crop
npm install @synapsestudios/react-drop-n-crop
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
19 Stars
37 Commits
6 Forks
30 Watching
5 Branches
39 Contributors
Updated on 02 Nov 2023
Minified
Minified + Gzipped
JavaScript (57.99%)
CSS (42.01%)
Cumulative downloads
Total Downloads
Last day
-65.5%
29
Compared to previous day
Last week
-28.6%
287
Compared to previous week
Last month
9.8%
1,389
Compared to previous month
Last year
16.3%
18,301
Compared to previous year
20
A combined implementation of react-dropzone and react-cropper (Cropper.js) for front-end image upload/validation/cropping.
A demo is available at https://synapsestudios.github.io/react-drop-n-crop/
1// yarn 2yarn add @synapsestudios/react-drop-n-crop 3 4// npm 5npm install --save @synapsestudios/react-drop-n-crop
1import DropNCrop from '@synapsestudios/react-drop-n-crop';
1// Minified, autoprefixed css 2import '@synapsestudios/react-drop-n-crop/lib/react-drop-n-crop.min.css'; 3 4// Not-minified, not-autoprefixed css 5import '@synapsestudios/react-drop-n-crop/lib/react-drop-n-crop.css';
If you are using Stylus you can import the .styl file into your build:
1@import '@synapsestudios/react-drop-n-crop/lib/react-drop-n-crop.styl';
! See the Stylus Variables section below for variables/details.
Class
and React Component State1import React, { Component } from 'react'; 2import DropNCrop from '@synapsestudios/react-drop-n-crop'; 3import '@synapsestudios/react-drop-n-crop/lib/react-drop-n-crop.min.css'; 4 5class SetStateExample extends Component { 6 state = { 7 result: null, 8 filename: null, 9 filetype: null, 10 src: null, 11 error: null, 12 }; 13 14 onChange = value => { 15 this.setState(value); 16 }; 17 18 render() { 19 return <DropNCrop onChange={this.onChange} value={this.state} />; 20 } 21} 22 23export default SetStateExample;
Props
DropNCrop is built as a controlled component. The following props must be supplied to the component:
onChange
is the callback function
invoked when an image is dropped or cropped. onChange
returns an object (in the shape of value
below).
1onChange: PropTypes.func.isRequired,
value
is the object
passed back from the onChange
function. It must be in the following shape:
1value: PropTypes.shape({
2 result: PropTypes.string, // Resulting DataURL from Cropper.js crop box
3 filename: PropTypes.string, // Original filename from uploaded file
4 filetype: PropTypes.string, // Original MIME type from uploaded file
5 src: PropTypes.string, // Original DataURL from the FileReader.result
6 error: PropTypes.string, // Error returned from fileSize/fileType validators
7}).isRequired,
Props
canvasHeight
is a string
for the container inline style height
property.
1canvasHeight: PropTypes.string, // default: '360px'
canvasWidth
is a string
for the container inline style width
property.
1canvasWidth: PropTypes.string, // default: '100%'
className
is a string
for the outermost container class name.
1className: PropTypes.string, // default: ''
cropperOptions
is an object
for customizing the cropper component. Lists of available options can be found here: https://github.com/roadmanfong/react-cropper
1cropperOptions: PropTypes.object, // default: {guides: true, viewMode: 0, autoCropArea: 1}
maxFileSize
is a maximum number
(in bytes) for file upload validation.
1maxFileSize: PropTypes.object, // default: 3145728
allowedFileTypes
is an array
(of strings) of valid MIME types for file upload validation.
1allowedFileTypes: PropTypes.array, // default: ['image/jpeg', 'image/jpg', 'image/png']
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:
1/* Theming by overriding default stylus variables with your projects colors */ 2 3$drop-n-crop--primary-color = $your-project-primary-color; 4$drop-n-crop--error-color = $your-project-error-color; 5 6$drop-n-crop--body-color = $your-project-body-color; 7$drop-n-crop--heading-color = $your-project-heading-color; 8 9$drop-n-crop--input-background-color = $your-project-background-color; 10$drop-n-crop--input-border-color = $your-project-border-color; 11 12@import '@synapsestudios.com/react-drop-n-crop/css/react-drop-n-crop.styl';
To run the project on your own computer:
yarn install
or npm install
yarn run storybook
or npm run storybook
src
directory should immediately compile and be visible in your browser.No vulnerabilities found.
Reason
no binaries found in the repo
Reason
all changesets reviewed
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
83 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More