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

photo-grid-box

v2.0.4

Published

A Flickr-like photo array showcase module for ReactJS.

Downloads

12

Readme

photo-grid-box

A Flickr-like photo array showcase module for ReactJS.

Before Update

  • If you are migrating from the old version, please notice the version 2 is very different from the previous versions.

Install

$ npm install photo-grid-box

HTML

There are three ways to get the CSS file:

  1. Copy or reference the file under /node_modules/photo-grid-box/build/
  2. Download them from the build folder in the GitHub repo

After getting the file, reference it in a HTML file

<!Doctype html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="[pathToTheFilesFolder]/photo-grid-box.min.css" />
...
  1. import the css file from the module directly
import 'photo-grid-box/photo-grid-box.min.css';

Babel

import 'photo-grid-box/photo-grid-box.min.css';
import PhotoGridBox from 'photo-grid-box';

Browserify/Webpack

const PhotoGridBox = require("photo-grid-box");
  • The CSS file has to be referenced in HTML, no matter which way you decide to import the module.

Usage

  • Assuming that you are writing the code in a function component:
const [imgs, setImgs] = useState([
  // use an object as an element allows you to to build some customized feature
  {
    src: "https://c1.staticflickr.com/1/699/22812601591_12ca1ee7cf_n.jpg",
    payload: {  // you can carry more information in the payload
      title: 'mountain'
    }
  },
  {
    src: "https://c1.staticflickr.com/1/573/22409354059_ba46782c8f_n.jpg",
    payload: {
      title: 'wall'
    }
  },
  {
    src: "https://c1.staticflickr.com/6/5704/22410267477_303a090dcd_m.jpg",
    payload: {
      title: 'jet'
    }
  },
  "https://c1.staticflickr.com/1/683/22207558073_8ecdb7abc4_n.jpg"  // a string that point out the image's path is also acceptable
]);

const [rowGap, setRowGap] = useState(3)
const [colGap, setColGap] = useState(3)
const [showUnCompleteRow, setShowUnCompleteRow] = useState(false)

const imgOnClick = (e, imgConfig) => {
  console.log('img clicked!', e, imgConfig)
}
const panelHTMLSetter = (imgConfig) => {
  let result = null
  if (imgConfig && imgConfig.payload && imgConfig.payload.title) {
    result = <div className="photo-block__panel__title">{imgConfig.payload.title}</div>
  }
  return result
}

// set the states to different values to update the view
return (
  <PhotoGridBox
    imgs={imgs} // set the pictures to show
    rowGap={rowGap} // set the height between each row (optional)
    colGap={colGap} // set the width between each block (optional)
    imgOnClick={imgOnClick} // the onClick event handler for each block (optional)
    panelHTMLSetter={panelHTMLSetter} // the function that returns a JSX for adding the children on the panel (optional)
    showUnCompleteRow={showUnCompleteRow} // In default, the PhotoGridBox will hide the last row if the last row is not complete; to make it looks more natural when loading pictures chunk by chunk. When there is no more picture to load, or for any reason, you can set the prop to true cancel the feature. (optional)
  />
)
);

Links

  1. https://www.npmjs.com/package/photo-grid-box
  2. https://github.com/tabsteveyang/photo-grid-box