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

@oliverwoodings/react-pyramid

v1.0.5

Published

Responsive masonry grid with infinte scroll and lazy loading, built with react.

Downloads

5

Readme

▲ Pyramid

Travis npm package Coveralls

Responsive masonry grid with infinte scroll and lazy loading, built with react.

Todo:

  • [ ] Allow passing elements as children (instead?)
  • [ ] Allow react components as elements
  • [ ] Super secret plan

Check out the dev branch to see where this component is headed! It's going to be epic!

Demo

Fun Giphy example: http://gergeo.se/pyramid-demo/ (Source in this repo)

Basic example which combines iframes and images: http://blimp.se/ (source: https://github.com/BlimpBureau/blimpbureau.github.io)

Install

npm install react-pyramid --save

Basic usage

<Pyramid elements={elements} />

Elements is an array of objects, example:

elements = [
  {
    type: "img", //not actually needed, since it defaults to img. (optional)
    src: "images/cat.png", //local or external url. (required)
    orgWidth: 1080, //the original width of the image (required)
    orgHeight: 1080 //the original height of the image (required)
    href: "images/cat.png" //give image a link (optional)
  },
  {
    type: "iframe",
    src: "http://foo.bar/dog.html", //required
    orgWidth: 1337, //required
    orgHeight: 1337 //required
  }
]

Props

elements – Array of objects, required

The array of objects to render. See example above, or check out the source code of the demo.

numberOfColumns – Object, optional

How many columns should the pyramid have for different breakpoints? Currently only supports the px unit.

defaults setting:

numberOfColumns: {
  default: 1,
  breakpoints: {
      "768px"  : 2,
      "1024px" : 3,
      "1280px" : 4,
      "1440px" : 5 
   }
}

magicValues: Object, optional

This one is a bit tricky to explain. I will do my best.

  • An element is only rendered if it is in view (or if it has already been rendered)
  • Basically, when determening whether an element is in view or not, the magicValue is a factor which stretches the boundary so to speak. More concretely, it is "streched" by magicValue * height of pyramid.

This is really nice to have and let's you "preload" elements just before they are scrolled into view.

defaults setting:

magicValues: {
  default: 0
}

example setting:

magicValues: {
  default: 1,
  breakpoints: {
    "768px" : 0.2
  }
}

baseClass: String, optional

The "block" in BEM, when giving component class names.

Defaults to "pyramid", which in turn gives the element container the class "pyramid__element", and the element "pyramid__element__[type]", where type is the type of the element (ex: img).

gutter: Number, optional

The gutter, which is used around the pyramid and between the elements.

Default: 20

transition: String, optional

The CSS transition property value which is applied to all elements.

Default: "all 300ms linear".

Apply "none" to turn this off.

derenderIfNotInViewAnymore: Boolean, optional

Should the element be derendered if it is no longer in view? (.ie the user has scrolled past it)

Default false

style: Object, optional

Self explanatory. Used to style the pyramid component.

Default CSS:

    display: "block",
    position: "relative",
    width: "100%",
    height: "100%",
    clear: "both",
    overflowY: "auto"

onElementClick: Function, optional

In case you want to handle what happenes when clicking on an element.

Usage example:

handleElementClick(elementProps, event) {
    console.log("elementProps", elementProps);
    console.log("event", event);
}

<Pyramid elements={elements} onElementClick={this.handleElementClick} />