npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

antd-react-cropper

v0.3.0

Published

An image cropper for Ant Design Upload using React Cropper.

Downloads

72

Readme

antd-react-cropper

Image cropper using Ant Design and React Cropper

npm npm npm bundle size

Demo

Edit antd-img-crop

Install

yarn add antd-react-cropper

Usage

import React, { useState } from 'react';
import { Upload } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import ImageCropper from 'antd-react-cropper';
import { UploadFile } from 'antd/lib/upload/interface';
import 'antd/dist/antd.css';

const ImageUploadInput = () => {
  const [fileList, setFileList] = useState<UploadFile[]>([]);
  const [file, setFile] = useState<UploadFile>();

  return (
    <>
      <Upload
        multiple={false}
        listType="picture-card"
        accept="image/*"
        showUploadList={{ showPreviewIcon: false }}
        fileList={fileList}
        beforeUpload={() => false}
        onChange={(info) => {
          if (info.fileList.length <= 0) {
            setFileList(info.fileList);
            return;
          }
          const file = info.fileList[info.fileList.length - 1];
          setFile(file);
        }}
      >
        <div>
          <PlusOutlined />
          <div style={{ marginTop: 8 }}>Upload</div>
        </div>
      </Upload>
      {file && (
        <ImageCropper
          file={file}
          aspect={16 / 9}
          onCropped={(file) => {
            setFileList([file]);
          }}
        />
      )}
    </>
  );
};

Props

| Props | Type | Default | Description | | --- | --- | --- | --- | | file | UploadFile | - | antd/lib/upload/UploadFile | | aspect | number | - | 16 / 9 | | cropperStyle | React.CSSProperties | - | - | | cropperClassName | string | - | - | | cropText | string | Crop | - | | cancelText | string | Cancel | - | | onCropped | (file: UploadFile) => void | - | - | | onCancel | () => void | - | - | | previewMaxHeight | number | 150 | - | | previewBackground | string | rgba(212, 212, 216) | - | | previewClassName | string | - | - | | previewStyle | React.CSSProperties | - | - | | title | React.ReactNode | - | AntD Modal props | | zIndex | number | - | AntD Modal props | | centered | boolean | - | AntD Modal props | | closable | boolean | - | AntD Modal props | | maskClosable | boolean | - | AntD Modal props | | width | number | 500 | AntD Modal props | | bodyStyle | React.CSSProperties | - | AntD Modal props | | zoomInButton | (onZoom) => React.ReactNode | - | Custom zoom in button | | zoomOutButton | (onZoom) => React.ReactNode | - | Custom zoom out button | | rotateLeftButton | (onRotate) => React.ReactNode | - | Custom rotate left button | | rotateRightButton | (onRotate) => React.ReactNode | - | Custom rotate right button | | customFooter | ({ onCrop, onCancel }) => React.ReactNode | - | Custom modal footer | | showLoader | boolean | true | show antd Message.loading | | exportFileType | string | image/jpeg | Cropped image file type |