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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-media-gallery-custom

v1.0.6

Published

A dynamic media gallery component for React applications with properly positioned buttons

Readme

React Media Gallery

A modern, responsive media gallery component for React applications with support for images and videos.

Features

  • Responsive grid and list view layouts
  • Image and video support
  • Interactive preview mode with keyboard navigation
  • Thumbnail navigation for easy browsing
  • Support for favorites, delete, info, and download actions
  • Metadata panel with detailed information
  • Fully customizable via props

Installation

npm install react-media-gallery

Basic Usage

import React from 'react';
import { MediaGallery } from 'react-media-gallery';
import 'react-media-gallery/dist/styles.css'; // Import the styles

// Sample media items
const mediaItems = [
  {
    id: 1,
    type: 'image',
    title: 'Mountain Landscape',
    description: 'Beautiful mountain landscape at sunset',
    thumbnailUrl: 'https://example.com/thumbnail1.jpg',
    fullUrl: 'https://example.com/image1.jpg',
    createdAt: '2023-05-15T10:30:00Z'
  },
  {
    id: 2,
    type: 'video',
    title: 'Ocean Waves',
    description: 'Relaxing video of ocean waves',
    thumbnailUrl: 'https://example.com/thumbnail2.jpg',
    fullUrl: 'https://example.com/video1.mp4',
    duration: '02:30',
    createdAt: '2023-05-16T14:45:00Z'
  }
];

function App() {
  const handleFavorite = (id) => {
    console.log(`Toggle favorite for item ${id}`);
  };

  const handleDelete = (id) => {
    console.log(`Delete item ${id}`);
  };

  const handleInfo = (id) => {
    console.log(`Showing info for ${id}`);
  };

  const handleDownload = (id) => {
    console.log(`Download item ${id}`);
  };
  
  // Array of favorited item IDs
  const favoriteItems = [1];

  return (
    <div className="app">
      <h1>Media Gallery</h1>
      <MediaGallery
        mediaItems={mediaItems}
        onFavorite={handleFavorite}
        onDelete={handleDelete}
        onInfo={handleInfo}
        onDownload={handleDownload}
        favoriteItems={favoriteItems}
        defaultViewType="grid" // or 'list'
        defaultMediaType="all" // or 'image', 'video'
      />
    </div>
  );
}

export default App;

Props

MediaGallery Component

| Prop | Type | Default | Description | |------|------|---------|-------------| | mediaItems | MediaItem[] | [] | Array of media items to display | | isLoading | boolean | false | Loading state of the gallery | | defaultViewType | 'grid' | 'list' | 'grid' | Initial view type | | defaultMediaType | 'all' | 'image' | 'video' | 'all' | Initial media type filter | | onFilterChange | (type: MediaType) => void | undefined | Callback when media type filter changes | | onFavorite | (id: number) => void | undefined | Callback when favorite is toggled | | onDelete | (id: number) => void | undefined | Callback when delete is clicked | | onInfo | (id: number) => void | undefined | Callback when info is clicked | | onDownload | (id: number) => void | undefined | Callback when download is clicked | | favoriteItems | number[] | [] | Array of favorited item IDs | | showInfoToggle | boolean | true | Whether to show the info toggle button | | className | string | '' | Additional CSS class name |

MediaItem Type

interface MediaItem {
  id: number;
  type: 'image' | 'video';
  title: string;
  description?: string | null;
  thumbnailUrl: string;
  fullUrl: string;
  duration?: string | null;
  createdAt: string;
}

Advanced Usage

You can also use the individual components to build custom layouts:

import { 
  GalleryGrid, 
  GalleryItem, 
  MediaPreviewModal 
} from 'react-media-gallery';

Customization

The gallery can be customized using CSS variables or by overriding the default styles.