react-crop-component
guide
- add your index html portal element
<div id='crop-portal'></div>
- use as below
//ComponentToBeCrop.jsconst ComponentToBeCrop = <div style= width: 250 height: 250 backgroundColor: '#ff44d9' color: '#fff' display: 'flex' justifyContent: 'center' alignItems: 'center' > Crop me if you can </div>
// App.js const MyApp = <> <ComponentToBeCrop /> <CropComponent portalId='crop-portal' canvasConfigs= width: 250 height: 250 innerWidth: 250 innerHeight: 250 Component=ComponentToBeCrop /></> const MyApp
type
defaultValue
prop object
buttonGroupStyle display: 'flex' alignItems: 'center' justifyContent: 'space-between'
object
modalStyle position: 'fixed' left: 0 top: 0 display: 'flex' justifyContent: 'center' alignItems: 'center' flexDirection: 'column' bottom: 0 right: 0 background: 'rgba(49, 73, 177, 0.5)' zIndex: 9999
string
canvas-portal
portalId ReactElement
null
Component object
null
canvasConfigs object
null
imgStyle object
buttonStyle padding: 8 margin: 8 background: '#273CAF' color: '#fff' border: 'none' outline: 'none'
string
'download.png'
filename object
downloadStyle padding: 8 margin: 8 background: '#36C2CE' color: '#fff'
function
DownloadButton <a onClick=onClick href=canvasElement && canvasElement download=filename style=downloadStyle > DOWNLOAD </a>
function
CancelButton ; <button style=buttonStyle onClick=onClick> CANCEL </button>
function
CropButton ; <button style=buttonStyle onClick=onClick> Crop Component </button>
Contributors
Dependency html2canvas
This project was bootstrapped with Create React App.
Available Scripts
In the project directory, you can run:
npm start
development env
npm run build
production script
npm run npmbuild
creates node_module output file