feat(cropper): expand image export API
This commit is contained in:
@@ -21,7 +21,7 @@ Add the package source to the application's Tailwind stylesheet:
|
||||
|
||||
## Cropper {#cropper}
|
||||
|
||||
Give the component an explicit width; `aspectRatio` determines its height:
|
||||
Use classes or pass `width` and `height` directly. `aspectRatio` accepts a number or a `"width:height"` string:
|
||||
|
||||
```tsx
|
||||
import { Cropper, type CropArea } from "@workspace/cropper"
|
||||
@@ -33,7 +33,7 @@ function ProductImageCropper({ src }: { src: string }) {
|
||||
<Cropper
|
||||
src={src}
|
||||
alt="Product"
|
||||
aspectRatio={4 / 3}
|
||||
aspectRatio="4:3"
|
||||
className="w-full max-w-xl rounded-xl"
|
||||
onCropAreaChange={setArea}
|
||||
/>
|
||||
@@ -43,6 +43,8 @@ function ProductImageCropper({ src }: { src: string }) {
|
||||
|
||||
Users can drag the image, scroll to zoom, or focus the Cropper and use the arrow, `+`, `-`, `0`, and `Home` keys.
|
||||
|
||||
`src` can also be a `Blob` or `File` from a file picker. The component creates a temporary object URL and revokes it when the source changes or the component unmounts.
|
||||
|
||||
## External controls {#controls}
|
||||
|
||||
Control the crop with `value` and `onValueChange` to connect a Slider or reset button. `minZoom` is clamped to at least `1`, ensuring that the image always covers the viewport.
|
||||
Control the crop with `value` and `onValueChange` to connect a Slider. For a quick reset, call `reset()` on the component ref. `minZoom` is clamped to at least `1`, ensuring that the image always covers the viewport.
|
||||
|
||||
Reference in New Issue
Block a user