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

react-images-viewer-updated

v1.8.0

Published

Create an react-images-viewer component.

Downloads

48

Readme

react-images-viewer

Build Status

jest

a fork of react-images-viewer that is updated to React 18 A react library that view photos list easily, and a simple, responsive viewer component for displaying an array of images.

Quick start

# recommended
yarn add react-images-viewer-updated

or

npm install react-images-viewer-updated --save
import React from "react";
import ImgsViewer from "react-images-viewer-updated";

export default class Demo extends React.Component {
  render() {
    return (
      <ImgsViewer
        imgs={[
          { src: "http://example.com/img1.jpg" },
          { src: "http://example.com/img2.png" },
        ]}
        currImg={this.state.currImg}
        isOpen={this.state.viewerIsOpen}
        onClickPrev={this.gotoPrevious}
        onClickNext={this.gotoNext}
        onClose={this.closeViewer}
      />
    );
  }
}

Demo & Example

Live Demo: guonanci.github.io/react-images-viewer

yarn install
yarn
yarn start

Then open localhost:8000 in a browser.

Using srcSet

Example using srcSet:

<ImgsViewer
  imgs={IMG_SET}
  ...
/>
const IMG_SET = [
  {
    src: "http://example.com/img1.svg",
    caption: "A forest",
    // As an array
    srcSet: [
      "http://example.com/img1_1024.jpg 1024w",
      "http://example.com/img1_800.jpg 800w",
      "http://example.com/img1_500.jpg 500w",
      "http://example.com/img1_320.jpg 320w",
    ],
  },
  {
    src: "http://example.com/img2.svg",
    // As a string
    srcSet:
      "http://example.com/img2_1024.jpg 1024w, http://example.com/img2_800.jpg 800w, http://example.com/img2_500.jpg 500w, http://example.com/img2_320.jpg 320w",
  },
];

Options

| Property | Type | Default | Description | | :------------------ | :--------- | :--------------- | :------------------------------------------------------------------------------------------------------------------------------ | | backdropCloseable | boolean | false | Allow users to exit the viewer by clicking the backdrop | | closeBtnTitle | str | undefined | Customize close esc title | | enableKeyboardInput | boolean | true | Supports keyboard input - space, esc, arrow left, arrow up, and arrow right, arrow down | | currImg | number | 0 | Required if you want to navigate the imgsViewer, The index of the image to display initially | | customControls | arr | undefined | An array of elements to display as custom controls on the top of viewer | | imgs | arr | undefined | Required. Array of image objects, See img opts table below | | imgCountSeparator | str | ' / ' | Customize separator in the image count | | isOpen | boolean | false | Required if you want to navigate the imgsViewer, Whether or not the viewer is displayed | | leftArrowTitle | str | undefined | Customize of left arrow title | | onClickPrev | function | undefined | Required if you want to navigate the imgsViewer, and fired on request of the previous image | | onClickNext | function | undefined | Required if you want to navigate the imgsViewer, and fired on request of the next image | | onClose | function | undefined | Required if you want to close the imgsViewer, and handle closing of the viewer | | onClickImg | function | undefined | Handle click on current image | | onClickThumbnail | function | undefined | Handle click on thumbnail | | preloadNextImg | boolean | true | Whether to preload the next available image | | rightArrowTitle | str | undefined | Customize right arrow title | | showCloseBtn | boolean | true | Optionally display a close 'X' button in top right corner | | showImgCount | boolean | true | Optionally display image index, e.g., "2 of 20" | | width | number | 1024 | Maximum width of the carousel; defaults to 1024px | | spinnerDisabled | boolean | false | Disable Spinner | | spinner | function | DefaultSpinner | Spinner component class | | spinnerColor | str | '#fff' | Color of spinner | | spinnerSize | number | 50 | Size of spinner | | preventAutoScroll | boolean | true | Determines whether auto-scrolling is prevented |

Images Object

| Property | Type | Default | Description | | :------- | :--------- | :---------- | :---------- | | src | str | undefined | Required | | srcSet | string[] | undefined | Optional | | caption | str | undefined | Optional | | alt | str | undefined | Optional |