diff --git a/.eslintrc.json b/.eslintrc.json index a429bcb..8f3beb0 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,9 +4,10 @@ "react-app", "prettier", "prettier/@typescript-eslint", - "prettier/react" + "prettier/react", + "plugin:cypress/recommended" ], - "plugins": ["@typescript-eslint/eslint-plugin"], + "plugins": ["@typescript-eslint/eslint-plugin", "cypress"], "rules": { "@typescript-eslint/explicit-function-return-type": 0, "@typescript-eslint/ban-ts-ignore": 0, diff --git a/.gitignore b/.gitignore index dc918d7..ecc7fb8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ docs/public .idea *.iml .yalc -yalc.lock \ No newline at end of file +yalc.lock +.DS_Store diff --git a/README.md b/README.md index c086676..4695789 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,11 @@ Check out the examples: - Supports any videos format supported in HTML5 - Mobile friendly +## Video tutorials from the community + +- [Create an image gallery with live cropping](https://www.youtube.com/watch?v=E_AHkWHhUz4) By [Coding With Adam](https://youtube.com/c/codingwithadam) +- [Crop an avatar and download the result](https://www.youtube.com/watch?v=RmiP1AY5HFM) By [Manish Boro](https://www.youtube.com/channel/UCyq81Ac-Ir4WIhFUgb_kyRw) + ## Installation ```shell @@ -76,39 +81,39 @@ This component requires some styles to be available in the document. By default, ## Props -| Prop | Type | Required | Description | -| :------------------------------------------------------------------------ | :---------------------------------------------------------------------------------- | :------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `image` | string | | The image to be cropped. `image` or `video` is required. | -| `video` | string or `Array<{ src: string; type?: string }>` | | The video to be cropped. `image` or `video` is required. | -| `crop` | `{ x: number, y: number }` | ✓ | Position of the media. `{ x: 0, y: 0 }` will center the media under the cropper. | -| `zoom` | number | | Zoom of the media between `minZoom` and `maxZoom`. Defaults to 1. | -| `rotation` | number (in degrees) | | Rotation of the media. Defaults to 0. | -| `aspect` | number | | Aspect of the cropper. The value is the ratio between its width and its height. The default value is `4/3` | -| `minZoom` | number | | Minimum zoom of the media. Defaults to 1. | -| `maxZoom` | number | | Maximum zoom of the media. Defaults to 3. | -| `zoomWithScroll` | boolean | | Enable zoom by scrolling. Defaults to `true` | -| `cropShape` | 'rect' \| 'round' | | Shape of the crop area. Defaults to 'rect'. | -| `cropSize` | `{ width: number, height: number }` | | Size of the crop area (in pixels). If you don't provide it, it will be computed automatically using the `aspect` prop and the media size. **You should probably not use this option and should rely on aspect instead. See https://github.com/ricardo-ch/react-easy-crop/issues/186.** | -| `showGrid` | boolean | | Whether to show or not the grid (third-lines). Defaults to `true`. | -| `zoomSpeed` | number | | Multiplies the value by which the zoom changes. Defaults to 1. | -| `objectFit` [demo](https://codesandbox.io/s/react-easy-crop-forked-p9r34) | 'contain', 'horizontal-cover' or 'vertical-cover' | | Specifies how the image is shown in the cropper:. `contain`: the image will be adjusted to be fully visible, `horizontal-cover`: the image will horizontally fill the cropper, `vertical-cover`: the image will vertically fill the cropper. Defaults to "contain". | -| `onCropChange` | crop => void | ✓ | Called everytime the crop is changed. Use it to update your `crop` state. | -| `onZoomChange` | zoom => void | | Called everytime the zoom is changed. Use it to update your `zoom` state. | -| `onRotationChange` | rotation => void | | Called everytime the rotation is changed (with mobile gestures). Use it to update your `rotation` state. | -| `onCropSizeChange` | cropSize => void | | Called when a change in either the cropSize width or the cropSize height occurs. | -| [`onCropComplete`](#onCropCompleteProp) | Function | | Called when the user stops moving the media or stops zooming. It will be passed the corresponding cropped area on the media in percentages and pixels | -| [`onCropAreaChange`](#onCropAreaChangeProp) | Function | | Very similar to [`onCropComplete`](#onCropCompleteProp) but is triggered for every user interaction instead of waiting for the user to stop. | -| `transform` | string | | CSS transform to apply to the image in the editor. Defaults to `translate(${crop.x}px, ${crop.y}px) rotate(${rotation}deg) scale(${zoom})` with variables being pulled from props. | -| `style` | `{ containerStyle: object, mediaStyle: object, cropAreaStyle: object }` | | Custom styles to be used with the Cropper. Styles passed via the style prop are merged with the defaults. | -| `classes` | `{ containerClassName: string, mediaClassName: string, cropAreaClassName: string }` | | Custom class names to be used with the Cropper. Classes passed via the classes prop are merged with the defaults. If you have CSS specificity issues, you should probably use the `disableAutomaticStylesInjection` prop. | -| `mediaProps` | object | | The properties you want to apply to the media tag ( or