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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-photo-uploader-component

v1.0.1

Published

A React component for uploading, previewing, and managing photos with compression and validation features

Readme

React Photo Uploader Component

A modern, feature-rich React component for uploading, previewing, and managing photos with built-in compression, validation, and gallery functionality.

Features

✅ Drag and drop file uploads
✅ Image preview gallery with reordering
✅ Automatic image compression
✅ File type validation
✅ Maximum file size validation
✅ Maximum number of files limitation
✅ Full-screen image viewer
✅ TypeScript support
✅ Modern design with customizable styling

Installation

npm install react-photo-uploader-component

Or with yarn:

yarn add react-photo-uploader-component

Basic Usage

import React, { useState } from 'react';
import { PhotoUploader } from 'react-photo-uploader-component';

function App() {
  const handleChange = (files) => {
    console.log('Files changed:', files);
    // Do something with the files
  };

  return (
    <div className="App">
      <h1>Upload Your Photos</h1>
      
      <PhotoUploader
        maxFileSize={5} // 5MB
        allowedTypes={['image/jpeg', 'image/png', 'image/webp']}
        maxFiles={10}
        onChange={handleChange}
      />
    </div>
  );
}

export default App;

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | maxFileSize | number | Required | Maximum file size in MB | | allowedTypes | string[] | Required | Array of allowed MIME types (e.g., 'image/jpeg', 'image/png') | | maxFiles | number | Infinity | Maximum number of files allowed to upload | | onChange | (files: PhotoFile[]) => void | undefined | Callback function triggered when files change |

The PhotoFile Object

When files are uploaded, they are transformed into PhotoFile objects with the following structure:

interface PhotoFile {
  id: string;             // Unique identifier for the photo
  file: File;             // The compressed File object
  preview: string;        // Data URL for preview
  name: string;           // Original filename
  originalSize: number;   // Original file size in bytes
}

Advanced Usage

Custom Form Integration

import React, { useState } from 'react';
import { PhotoUploader } from 'react-photo-uploader-component';

function UploadForm() {
  const [photos, setPhotos] = useState([]);
  const [isSubmitting, setIsSubmitting] = useState(false);

  const handleSubmit = async (e) => {
    e.preventDefault();
    setIsSubmitting(true);
    
    // Create FormData for submission
    const formData = new FormData();
    photos.forEach((photo) => {
      formData.append('photos', photo.file);
    });
    
    try {
      const response = await fetch('https://your-api.com/upload', {
        method: 'POST',
        body: formData,
      });
      
      if (response.ok) {
        alert('Upload successful!');
      } else {
        throw new Error('Upload failed');
      }
    } catch (error) {
      console.error('Error uploading images:', error);
      alert('Failed to upload images');
    } finally {
      setIsSubmitting(false);
    }
  };

  return (
    <form onSubmit={handleSubmit}>
      <h2>Product Photos</h2>
      <PhotoUploader
        maxFileSize={2}
        allowedTypes={['image/jpeg', 'image/png', 'image/webp']}
        maxFiles={5}
        onChange={setPhotos}
      />
      
      <button 
        type="submit" 
        disabled={photos.length === 0 || isSubmitting}
        className="submit-button"
      >
        {isSubmitting ? 'Uploading...' : 'Submit'}
      </button>
    </form>
  );
}

Styling Customization

The component uses CSS variables for easy styling customization:

:root {
  --color-primary: #f3f4f6;         /* Main background color */
  --color-secondary: #ef4444;       /* Error/action color */
  --color-background: #ffffff;      /* Background color */
  --color-text: #333333;            /* Text color */
  --color-light-text: #ffffff;      /* Light text color */
}

Individual Components

The package also exports individual components and utilities that you can use separately:

import { 
  PhotoGallery,
  PhotoItem,
  ImageViewer,
  compressImage
} from 'react-photo-uploader-component';

Browser Support

  • Chrome, Firefox, Safari, Edge (latest versions)
  • Mobile browsers on iOS and Android

License

MIT

Development

To contribute to this project:

  1. Clone the repository
  2. Install dependencies: npm install
  3. Run development server: npm run dev
  4. Build: npm run build

Issues and Feedback

Please report any issues or suggestions on the GitHub repository.