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-virtualized-cssgrid

v0.0.3

Published

React Virtualization with CSS Grid

Downloads

4

Readme

React Virtualized CSS Grid

React Virtualized CSS Grid is a React component for efficiently rendering a large, scrollable list of items while utilizing CSS Grid. Inspired by react-virtualized to render a virtualized grid of an arbitrary number of rows and columns based on the provided row and container heights to calculate and generate virtualized list items.

Demo

TBD

Installation

npm i react-virtualized-cssgrid

Usage

Functional Stateless Component

import React from 'react';
import VirtualizedCSSGrid from 'react-virtualized-cssgrid';

function MyList({ items }) {
  return (
    <VirtualizedCSSGrid containerWidth={1080} rowHeight={240} columnWidth={360} columns={3} listLength={items.length}>
      {items.map(el => (
        <img key={el} src={`https://hiring.verkada.com/thumbs/${el}.jpg`} style={{ width: 360 }} />
      ))}
    </VirtualizedCSSGrid>
  );
}

Functional Stateless Component

import React from 'react';
import VirtualizedCSSGrid from 'react-virtualized-cssgrid';

class List extends Component {
  render() {
    return (
      <VirtualizedCSSGrid containerWidth={1080} rowHeight={240} columnWidth={360} columns={3} listLength={items.length}>
        {items.map(el => (
          <img key={el} src={`https://hiring.verkada.com/thumbs/${el}.jpg`} style={{ width: 360 }} />
        ))}
      </VirtualizedCSSGrid>
    );
  }
}

Props

children

children is required and must be provided as an array within the <VirtualizedCSSGrid /> component.

<VirtualizedCSSGrid containerWidth={1080} rowHeight={240} columnWidth={360} columns={3} listLength={items.length}>
  {items.map(el => (
    <img key={el} src={`https://hiring.verkada.com/thumbs/${el}.jpg`} style={{ width: 360 }} />
  ))}
</VirtualizedCSSGrid>

className

If className is provided, it will be attached to the outermost Grid div.

function MyList({ items }) {
  return <VirtualizedItemGrid className="my-grid-class" containerWidth={1080} rowHeight={240} columnWidth={360} columns={3} listLength={items.length} />;
}

containerWidth

className is required and must be a number or a function which returns a number.

It represents the max width of the outermost grid container div.

function getContainerWidth({ containerWidth }) {
  return containerWidth;
}

function MyList() {
  return <VirtualizedCSSGrid containerWidth={getContainerWidth} rowHeight={240} columnWidth={360} columns={3} listLength={items.length} />;
}

rowHeight

rowHeight is required and must be a number or a function which returns a number.

It represents the row height of each grid row, which will also represent the height a single grid element.

function getRowHeight({ rowHeight }) {
  return rowHeight;
}

function MyList({ items }) {
  return <VirtualizedCSSGrid containerWidth={1080} rowHeight={getRowHeight} columnWidth={360} columns={3} listLength={items.length} />;
}

columnWidth

columnWidth is required and must be a number or a function which returns a number.

It represents the column width of each grid column, which will also represent the width a single grid element.

function getColumnWidth({ columnWidth }) {
  return columnWidth;
}

function MyList({ items }) {
  return <VirtualizedCSSGrid containerWidth={1080} rowHeight={240} columnWidth={getColumnWidth} columns={3} listLength={items.length} />;
}

columns

columns is required and must be a number or a function which returns a number.

It represents the number of columns provided in each row container.

function getColumns({ columns }) {
  return columns;
}

function MyList({ items }) {
  return <VirtualizedCSSGrid containerWidth={1080} rowHeight={240} columnWidth={360} columns={getColumns} listLength={items.length} />;
}

listLength

listLength is required and must be a number or a function which returns a number.

It represents the total number of elements provided.

function getListLength({ listLength }) {
  return listLength;
}

function MyList({ items }) {
  return <VirtualizedCSSGrid containerWidth={1080} rowHeight={240} columnWidth={360} columns={3} listLength={getListLength} />;
}