Skip to content

Commit b66a0f8

Browse files
committed
first commit
0 parents commit b66a0f8

File tree

6,511 files changed

+993477
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

6,511 files changed

+993477
-0
lines changed

.babelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"presets": ["env"],
3+
"plugins": ["transform-object-rest-spread", "transform-react-jsx"]
4+
}

.gitignore

152 Bytes
Binary file not shown.

.nvmrc

16 Bytes
Binary file not shown.

README.md

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# React Virtualized CSS Grid
2+
3+
> 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.
4+
5+
## Demo
6+
7+
TBD
8+
9+
## Installation
10+
11+
```
12+
npm i react-virtualized-cssgrid
13+
```
14+
15+
## Usage
16+
17+
### Functional Stateless Component
18+
19+
```js
20+
import React from 'react';
21+
import VirtualizedCSSGrid from 'react-virtualized-cssgrid';
22+
23+
function MyList({ items }) {
24+
return (
25+
<VirtualizedCSSGrid containerWidth={1080} rowHeight={240} columnWidth={360} columns={3} listLength={items.length}>
26+
{items.map(el => (
27+
<img key={el} src={`https://hiring.verkada.com/thumbs/${el}.jpg`} style={{ width: 360 }} />
28+
))}
29+
</VirtualizedCSSGrid>
30+
);
31+
}
32+
```
33+
34+
### Functional Stateless Component
35+
36+
```js
37+
import React from 'react';
38+
import VirtualizedCSSGrid from 'react-virtualized-cssgrid';
39+
40+
class List extends Component {
41+
render() {
42+
return (
43+
<VirtualizedCSSGrid containerWidth={1080} rowHeight={240} columnWidth={360} columns={3} listLength={items.length}>
44+
{items.map(el => (
45+
<img key={el} src={`https://hiring.verkada.com/thumbs/${el}.jpg`} style={{ width: 360 }} />
46+
))}
47+
</VirtualizedCSSGrid>
48+
);
49+
}
50+
}
51+
```
52+
53+
## Props
54+
55+
### `children`
56+
57+
`children` is required and must be provided as an array within the `<VirtualizedCSSGrid />` component.
58+
59+
```js
60+
render() {
61+
return (
62+
<VirtualizedCSSGrid containerWidth={1080} rowHeight={240} columnWidth={360} columns={3} listLength={items.length}>
63+
{items.map(el => (
64+
<img key={el} src={`https://hiring.verkada.com/thumbs/${el}.jpg`} style={{ width: 360 }} />
65+
))}
66+
</VirtualizedCSSGrid>
67+
);
68+
}
69+
```
70+
71+
### `className`
72+
73+
If `className` is provided, it will be attached to the outermost Grid `div`.
74+
75+
```js
76+
function MyList({ items }) {
77+
return <VirtualizedItemGrid className="my-grid-class" containerWidth={1080} rowHeight={240} columnWidth={360} columns={3} listLength={items.length} />;
78+
}
79+
```
80+
81+
### `containerWidth`
82+
83+
`className` is required and must be a number or a function which returns a number.
84+
85+
It represents the max width of the outermost grid container `div`.
86+
87+
```js
88+
function getContainerWidth({ containerWidth }) {
89+
return containerWidth;
90+
}
91+
92+
function MyList() {
93+
return <VirtualizedCSSGrid containerWidth={getContainerWidth} rowHeight={240} columnWidth={360} columns={3} listLength={items.length} />;
94+
}
95+
```
96+
97+
### `rowHeight`
98+
99+
`rowHeight` is required and must be a number or a function which returns a number.
100+
101+
It represents the row height of each grid row, which will also represent the height a single grid element.
102+
103+
```js
104+
function getRowHeight({ rowHeight }) {
105+
return rowHeight;
106+
}
107+
108+
function MyList({ items }) {
109+
return <VirtualizedCSSGrid containerWidth={1080} rowHeight={getRowHeight} columnWidth={360} columns={3} listLength={items.length} />;
110+
}
111+
```
112+
113+
### `columnWidth`
114+
115+
`columnWidth` is required and must be a number or a function which returns a number.
116+
117+
It represents the column width of each grid column, which will also represent the width a single grid element.
118+
119+
```js
120+
function getColumnWidth({ columnWidth }) {
121+
return columnWidth;
122+
}
123+
124+
function MyList({ items }) {
125+
return <VirtualizedCSSGrid containerWidth={1080} rowHeight={240} columnWidth={getColumnWidth} columns={3} listLength={items.length} />;
126+
}
127+
```
128+
129+
### `columns`
130+
131+
`columns` is required and must be a number or a function which returns a number.
132+
133+
It represents the number of columns provided in each row container.
134+
135+
```js
136+
function getColumns({ columns }) {
137+
return columns;
138+
}
139+
140+
function MyList({ items }) {
141+
return <VirtualizedCSSGrid containerWidth={1080} rowHeight={240} columnWidth={360} columns={getColumns} listLength={items.length} />;
142+
}
143+
```
144+
145+
### `listLength`
146+
147+
`listLength` is required and must be a number or a function which returns a number.
148+
149+
It represents the total number of elements provided.
150+
151+
```js
152+
function getListLength({ listLength }) {
153+
return listLength;
154+
}
155+
156+
function MyList({ items }) {
157+
return <VirtualizedCSSGrid containerWidth={1080} rowHeight={240} columnWidth={360} columns={3} listLength={getListLength} />;
158+
}
159+
```

node_modules/.bin/acorn

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/acorn.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/atob

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/atob.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/escodegen

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/escodegen.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)