JSPM

nidea-react-iviewer

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q32847F
  • License MIT

A React-based image previewer built with Vite. This project allows users to upload images and preview them on a canvas with interactive features.

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nidea-react-iviewer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Nidea react iViewer

    The React wrapper simplifies integration by providing context-based API access.

    This wrapper is based on this package!

    Usage

    import { ImagePreviewer } from "nidea-iviewer";
    
    export default function App() {
      return (
        <ImagePreviewer width={500} height={400}>
          <ImagePreviewer.ImageInput>
            {({ onChangeFile }) => <input type="file" onChange={onChangeFile} />}
          </ImagePreviewer.ImageInput>
          <ImagePreviewer.DownloadButton>
            {({ onDownload }) => <button onClick={onDownload}>Download</button>}
          </ImagePreviewer.DownloadButton>
          <ImagePreviewer.ProcessBlobButton>
            {({ getBlob }) => (
              <button
                onClick={async () => {
                  const file = await getBlob(); // Blob | undefined
                  // Do some stuff
                }}
              >
                Do something!
              </button>
            )}
          </ImagePreviewer.ProcessBlobButton>
        </ImagePreviewer>
      );
    }

    Example

    Let's test it here.

    Components

    • <ImagePreviewer>: Main wrapper component.
    • <ImagePreviewer.ImageInput>: Handles file selection.
    • <ImagePreviewer.ProcessBlobButton>: Provides access to the image blob.
    • <ImagePreviewer.DownloadButton>: Enables image downloading.

    License

    This project is licensed under the MIT License. Use it, break it, improve it!