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-rpg

v2.0.0

Published

A React component for responsive photo grids in square aspect ratio

Downloads

19

Readme

react-rpg :camera:

what

react-rpg is a lightweight, stateless responsive photo grid component for reactjs. Quickly create instagram-esque responsive photo grids with no CSS dependencies.

DEMO

react-rpg

The component renders an array of images in square aspect-ratio for the modern, fluid web. The react-rpg component takes 100% width of the parent container using dynamic inline styles.

Column count can be specified at 3 different breakpoints.

how

To use in a react project, first, install via npm:

npm i react-rpg --save

Then require wherever you desire and pass it an array of image objects as props. See ./demo for a more thorough example.

...
import { ReactRpg } from 'react-rpg';

const images = [
  {
    url: "absolute url to the src of the image",
    clickHandler: (url, obj) => { console.log(url) }
  },
  {
    url: "http://images.com/myimage.jpg",
    clickHandler: (url, obj) => { console.log(obj) }
  }
];


class App extends React.Component {
  render() {
    return (
      <div className="myApp">
        <ReactRpg imagesArray={images} columns={[ 1, 2, 5 ]} padding={10} />
      </div>
    );
  }
}

Props

  • imagesArray (array, default [], required YES) - An Array of objects containing an url property of the absolute url of the photos for the img's src attribute. Can also pass an optional clickHandler callback function property.
  • columns (array, default [1, 2, 3], required NO) - Sets the number of columns for the photo grid. First array element is the column count on screens under 480px wide. Second element is the desired column count at device widths above 480px and below 992px. Third array element is desired column count on devices with screen width 992px+.
  • padding (number, default 0, required NO) - Sets the padding value in px around the images.

Scaffolded with Formidable Labs' component boilerplate, thanks!

changelog

v1.0

  • link prop is depreciated.
  • Instead, pass a callback function to the clickHandler property in the imagesArray prop. This function receives the URL and React's synthetic event object for your disposal.

v2.0

  • Pass an array of size 3 to the columns prop instead of just a single integer to specify column count at 3 breakpoints so that column count is a function of device width for varying screen sizes.