dreamgrid

0.1.36 • Public • Published

dreamgrid

responsive react image grid component that respects aspect ratios https://withintheruins14.github.io/dreamgrid

NPM JavaScript Style Guide

Install

# Yarn 
yarn add dreamgrid
 
# NPM 
npm install --save dreamgrid
masonry dreamgrid
preserves aspect ratios
allows variable item widths
deterministic
virtualized
memoized

Usage

const images = [
  {
    height: 679,          // you can pass a ratio for height and width if you don't have them
    width: 1024,          // eg. { height: 2, width: 3 } or { height: 1, width: 1 }
    url: 'https://live.staticflickr.com/7837/46852208034_1f768a633c_b_d.jpg'
  },
  {
    height: 1024,
    width: 679,
    url: 'https://live.staticflickr.com/7856/46660570565_dd7cb62cd0_b_d.jpg'
  },
  {
    height: 1024,
    width: 679,
    url: 'https://live.staticflickr.com/7856/46660570565_dd7cb62cd0_b_d.jpg'
  }
};

const renderItem = (style, image) => (<img src={image.url} style={style} />);

Hooks (coming soon!)

import { useGrid } from 'dreamgrid';

const Grid = useGrid(
  images,
  size,
  minimumRowHeight,
  maximumRowHeight,
  renderItem
);

return (<Grid />);

Component

import DreamGrid from 'dreamgrid';

return (
  <DreamGrid
    images={images}
    size={{ height: 300, width: 600 }}
    minimumRowHeight={180}
    maximumRowHeight={350}
    renderItem={renderItem}
  />
);

Learn more at: https://withintheruins14.github.io/dreamgrid

License

MIT © withintheruins14

Dependencies (0)

    Dev Dependencies (27)

    Package Sidebar

    Install

    npm i dreamgrid

    Weekly Downloads

    2

    Version

    0.1.36

    License

    MIT

    Unpacked Size

    41.1 kB

    Total Files

    8

    Last publish

    Collaborators

    • withintheruins14